Level_0#

class esis.data.Level_0(inputs, outputs, camera, timeline=None, *, axis_time='time', axis_channel='channel', axis_x='detector_x', axis_y='detector_y')[source]#

Bases: SensorData, AbstractChannelData

Representation of ESIS Level-0 images, the raw data gathered by the instrument.

The Data Acquisition and Control System (DACS) reads out the cameras and saves the resulting images as FITS files. This represents those FITS files as a Python class.

Attributes

active

A new copy of these images without the bias and overscan columns.

axes

A tuple of str representing the names of each dimension of ndarray.

axes_center

Return keys corresponding to all input axes representing bin centers

axes_flattened

Combine axes into a single str.

axes_vertex

Return keys corresponding to all input axes representing bin vertices

axis_channel

The name of the logical axis corresponding to the different channels.

axis_time

The name of the logical axis corresponding to changing time.

axis_x

The name of the horizontal axis.

axis_xy

A tuple containing axis_x and axis_y.

axis_y

The name of the vertical axis.

broadcasted

if this array has multiple components, broadcast them against each other.

camera

A model of the sensor used to capture these images.

channel

The name of each ESIS channel in a human-readable format.

dark

The master dark image for each channel.

dark_subtracted

Subtract the master dark from each image in the sequence.

darks

The dark images used to construct the master dark image.

darks_down

The dark images collected on the downleg of the trajectory.

darks_up

The dark images collected on the upleg of the trajectory.

despiked

Remove cosmic rays using astroscrappy.detect_cosmics().

electrons

A new copy of these images in units of electrons.

explicit

Converts this array to an instance of named_arrays.AbstractExplicitArray

indices

inputs

A vector which contains the FITS header for each image.

length

L2-norm of this array.

lights

The sequence of solar images taken during the flight.

ndim

Number of dimensions of the array.

num_x

The number of pixels along the horizontal axis.

num_y

The number of pixels along the vertical axis.

outputs

The underlying array storing the image data.

shape

Shape of the array.

size

Total number of elements in the array.

taps

Split the data into separate images for each tap.

time_mission_start

The \(T=0\) time of the mission.

timeline

The sequence of NSROC events associated with these images.

type_abstract

The AbstractArray type corresponding to this array

type_explicit

The AbstractExplicitArray type corresponding to this array

unbiased

A new copy of these images where the bias has been removed.

value

Returns a new array with its units removed, if they exist

Methods

__init__(inputs, outputs, camera[, ...])

add_axes(axes)

Add new singleton axes to this array

all([axis, where])

animate([ax, cmap, norm, vmin, vmax, ...])

Create an animation using the frames in this dataset.

any([axis, where])

astype(dtype[, order, casting, subok, copy])

Copy of the array cast to a specific data type.

broadcast_to(shape[, append])

cell_centers([axis, random])

Convert an array from cell vertices to cell centers.

combine_axes([axes, axis_new])

Combine some of the axes of the array into a single new axis.

copy()

copy_shallow()

from_fits(path, camera[, axis_x, axis_y, ...])

Load an image or an array of images from a FITS file or an array of files.

from_scalar_array(a[, like])

Constructs a new version of this array using a as the underlying data.

from_taps(taps)

Create a new copy of this object by concatenating the data from taps.

index(value[, axis])

index_secant(value[, axis])

interp_linear(item)

max([axis, initial, where])

mean([axis, where])

median([axis])

min([axis, initial, where])

ndindex([axis_ignored])

pcolormesh(axs, input_component_x, ...[, ...])

Plot a FunctionArray via matplotlib.pyplot.pcolormesh().

percentile(q[, axis, out, overwrite_input, ...])

ptp([axis])

regrid(inputs[, axis, method, weights])

Resample this function array onto a new set of input coordinates using named_arrays.regridding.regrid().

replace(**changes)

A method version of dataclasses.replace() for named arrays.

reshape(shape)

rms([axis, where])

std([axis, where])

sum([axis, where])

to(unit[, equivalencies, copy])

Convert this array to a new unit.

to_jshtml([ax, cmap, norm, vmin, vmax, ...])

Create a Javascript animation ready to be displayed in a Jupyter notebook.

to_string([prefix, multiline])

Convert this array instance to a string representation.

to_string_array([format_value, format_unit, ...])

Convert to an array of strings where each string has an appropriately-formatted unit attached to the value.

transpose([axes])

var([axis, where])

vmr([axis, where])

volume_cell(axis)

Computes the n-dimensional volume of each cell formed by interpreting this array as a logically-rectangular grid of vertices.

weights(inputs[, axis, method])

Compute the resampling weights of this array using named_arrays.regridding.weights().

Inheritance Diagram

Inheritance diagram of esis.data.Level_0
Parameters:
add_axes(axes)#

Add new singleton axes to this array

Parameters:

axes (str | Sequence[str]) – New axes to add to the array

Return type:

Array with new axes added

all(axis=None, where=<no value>)#
Parameters:
Return type:

Self

animate(ax=None, cmap=None, norm=None, vmin=None, vmax=None, cbar_fraction=0.1)#

Create an animation using the frames in this dataset.

Parameters:
Return type:

FuncAnimation

any(axis=None, where=<no value>)#
Parameters:
Return type:

Self

astype(dtype, order='K', casting='unsafe', subok=True, copy=True)#

Copy of the array cast to a specific data type.

Equivalent to numpy.ndarray.astype().

Parameters:
Return type:

FunctionArray

broadcast_to(shape, append=False)#
Parameters:
Return type:

Self

cell_centers(axis=None, random=False)#

Convert an array from cell vertices to cell centers.

Parameters:
  • axis (None | str | Sequence[str]) – The axes of the array to average over.

  • random (bool) – If true, select a random point within each cell instead of the geometric center.

Return type:

AbstractExplicitArray

combine_axes(axes=None, axis_new=None)#

Combine some of the axes of the array into a single new axis.

Parameters:
  • axes (Sequence[str]) – The axes to combine into a new axis

  • axis_new (str) – The name of the new axis

Return type:

Array with the specified axes combined

copy()#
Parameters:

self (Self)

Return type:

Self

copy_shallow()#
Parameters:

self (Self)

Return type:

Self

classmethod from_fits(path, camera, axis_x='detector_x', axis_y='detector_y', timeline=None)[source]#

Load an image or an array of images from a FITS file or an array of files.

Parameters:
  • path (str | Path | AbstractScalarArray) – Either a single path or an array of paths pointing to the FITS files to load.

  • camera (AbstractCamera) – A model of the camera used to capture these images.

  • axis_x (str) – The name of the logical axis representing the horizontal dimension of the images.

  • axis_y (str) – The name of the logical axis representing the vertical dimension of the images.

  • timeline (None | Timeline)

Return type:

Self

classmethod from_scalar_array(a, like=None)#

Constructs a new version of this array using a as the underlying data.

Parameters:
Return type:

Self

from_taps(taps)#

Create a new copy of this object by concatenating the data from taps.

This method does not concatenate the taps.inputs.pixel coordinates. Instead, this method creates a new set of coordinates from the final shape.

Parameters:

taps (TapData) – The data from each tap.

Return type:

Self

index(value, axis=None)#
Parameters:
Return type:

dict[str, Self]

index_secant(value, axis=None)#
Parameters:
Return type:

dict[str, Self]

interp_linear(item)#
Parameters:

item (dict[str, AbstractArray])

Return type:

FunctionArray

max(axis=None, initial=<no value>, where=<no value>)#
Parameters:
Return type:

Self

mean(axis=None, where=<no value>)#
Parameters:
Return type:

Self

median(axis=None)#
Parameters:

axis (None | str | Sequence[str])

min(axis=None, initial=<no value>, where=<no value>)#
Parameters:
Return type:

Self

ndindex(axis_ignored=None)#
Parameters:
Return type:

Iterator[dict[str, int]]

pcolormesh(axs, input_component_x, input_component_y, input_component_row=None, input_component_column=None, index=None, output_component_color=None, **kwargs)#

Plot a FunctionArray via matplotlib.pyplot.pcolormesh().

FunctionArray.pcolormesh() takes in an axes object, or array of axes objects, along with components to be plotted along the x and y plot axes (input_component_x and input_component_y). Additional components can be tiled along subplot row/column and are specified in input_component_row and input_component_column.

import named_arrays as na
import numpy as np
import astropy.units as u
import matplotlib.pyplot as plt

position = na.Cartesian2dVectorLinearSpace(
    start=-10,
    stop=10,
    axis=na.Cartesian2dVectorArray(
        x='position_x',
        y='position_y',
    ),
    num=21,
) * u.m

x_width = 5 * u.m
y_width = 2 * u.m
velocity = 1 * u.m/u.s
time = na.ScalarLinearSpace(
    start=0 * u.s,
    stop=3 * u.s,
    num=4,
    axis='time'
)

intensity = np.exp(-(((position.x + velocity*time)/x_width) ** 2 + ((position.y + 2*velocity*time)/y_width)** 2))
scene = na.FunctionArray(
    inputs=position,
    outputs=intensity,
)

fig, axs = plt.subplots(
    nrows=scene.outputs.shape['time'],
    squeeze=False,
    sharex=True,
    subplot_kw=dict(aspect='equal'),
)
scene.pcolormesh(
    axs=axs,
    input_component_x='x',
    input_component_y='y',
    input_component_row='time',
)
../_images/esis.data.Level_0_0_0.png
Parameters:
  • axs (ndarray)

  • input_component_x (str)

  • input_component_y (str)

  • input_component_row (None | str)

  • input_component_column (None | str)

  • index (None | dict[str, int])

  • output_component_color (None | str)

  • kwargs (Any)

percentile(q, axis=None, out=None, overwrite_input=False, method='linear', keepdims=False)#
Parameters:
ptp(axis=None)#
Parameters:
Return type:

Self

regrid(inputs, axis=None, method='multilinear', weights=None)#

Resample this function array onto a new set of input coordinates using named_arrays.regridding.regrid().

Parameters:
  • inputs (AbstractArray) – The new input coordinates on which to resample the outputs.

  • axis (None | str | tuple[str]) – The logical axes of the input over which to resample.

  • method (Literal['multilinear', 'conservative']) – The resampling method to use.

  • weights (None | tuple[AbstractScalar, dict[str, int], dict[str, int]]) – Optional weights which can be computed in advance using weights() to greatly speed repeated resampling of the same inputs.

Return type:

Self

See also

weights()

If you need to resample the same coordinates more than once.

replace(**changes)#

A method version of dataclasses.replace() for named arrays.

Parameters:

changes – The fields of the dataclass to be overwritten

Return type:

Self

reshape(shape)#
Parameters:
Return type:

Self

rms(axis=None, where=<no value>)#
Parameters:
Return type:

Self

std(axis=None, where=<no value>)#
Parameters:
Return type:

Self

sum(axis=None, where=<no value>)#
Parameters:
Return type:

Self

to(unit, equivalencies=[], copy=True)#

Convert this array to a new unit.

Equivalent to astropy.units.Quantity.to().

Parameters:
  • unit (UnitBase) – New unit of the returned array

  • equivalencies (None | list[tuple[Unit, Unit]]) – A list of equivalence pairs to try if the units are not directly convertible.

  • copy (bool) – Boolean flag controlling whether to copy the array.

Return type:

FunctionArray

to_jshtml(ax=None, cmap=None, norm=None, vmin=None, vmax=None, cbar_fraction=0.1, fps=None)#

Create a Javascript animation ready to be displayed in a Jupyter notebook.

Converts the output of animate() to Javascript using matplotlib.animation.Animation.to_jshtml(), and then wraps the html string in IPython.display.HTML.

Parameters:
  • ax (None | Axes | AbstractArray) – The Axes instance(s) to use. If None, a new set of axes will be created.

  • cmap (None | str | Colormap) – The colormap used to map scalar data to colors.

  • norm (None | str | Normalize) – The normalization method used to scale data into the range [0, 1] before mapping to colors.

  • vmin (None | int | float | complex | ndarray | Quantity | AbstractArray) – The minimum value of the data range. If norm is None, this parameter will be ignored.

  • vmax (None | int | float | complex | ndarray | Quantity | AbstractArray) – The maximum value of the data range. If norm is None, this parameter will be ignored.

  • cbar_fraction (float) – The fraction of the space to use for the colorbar axes.

  • fps (None | float) – The frames per second of the animation.

Return type:

HTML

to_string(prefix=None, multiline=None)#

Convert this array instance to a string representation.

Parameters:
  • prefix (None | str) – the length of this string is used to align the output

  • multiline (None | bool) – flag which controls if the output should be spread over multiple lines.

Return type:

array represented as a str

to_string_array(format_value='%.2f', format_unit='latex_inline', pad_unit='$\\,$')#

Convert to an array of strings where each string has an appropriately-formatted unit attached to the value.

Parameters:
  • format_value (str) – The string used to format the numeric value of each element.

  • format_unit (str) – The string used to format the units of each element.

  • pad_unit (str) – The string used to add horizontal space between the value and unit.

transpose(axes=None)#
Parameters:
Return type:

Self

var(axis=None, where=<no value>)#
Parameters:
Return type:

Self

vmr(axis=None, where=<no value>)#
Parameters:
volume_cell(axis)#

Computes the n-dimensional volume of each cell formed by interpreting this array as a logically-rectangular grid of vertices.

Note that this method is usually only used for sorted arrays.

If self is a scalar, this method computes the length of each edge, and is equivalent to numpy.diff(). If self is a 2d vector, this method computes the area of each quadrilateral, and if self is a 3d vector, this method computes the volume of each cuboid.

Parameters:

axis (None | str | Sequence[str]) – The axis or axes defining the logically-rectangular grid. If self is a physical scalar, there should only be one axis. If self is a physical vector, there should be one axis for each component of the vector.

Return type:

AbstractScalar

weights(inputs, axis=None, method='multilinear')#

Compute the resampling weights of this array using named_arrays.regridding.weights(). The output of this method is designed to be used by regrid().

Parameters:
  • inputs (AbstractArray) – The new input coordinates on which to resample the outputs.

  • axis (None | str | tuple[str]) – The logical axes of the input over which to resample.

  • method (Literal['multilinear', 'conservative']) – The resampling method to use.

Return type:

tuple[AbstractScalar, dict[str, int], dict[str, int]]

See also

regrid()

A method designed to use these weights.

property active: Self#

A new copy of these images without the bias and overscan columns.

property axes: tuple[str, ...]#

A tuple of str representing the names of each dimension of ndarray.

Must have the same length as the number of dimensions of ndarray.

property axes_center: tuple(str)#

Return keys corresponding to all input axes representing bin centers

property axes_flattened: str#

Combine axes into a single str.

This is useful for functions like numpy.flatten() which returns an array with only one dimension.

property axes_vertex: tuple(str)#

Return keys corresponding to all input axes representing bin vertices

axis_channel: str = 'channel'#

The name of the logical axis corresponding to the different channels.

axis_time: str = 'time'#

The name of the logical axis corresponding to changing time.

axis_x: str = 'detector_x'#

The name of the horizontal axis.

property axis_xy#

A tuple containing axis_x and axis_y.

axis_y: str = 'detector_y'#

The name of the vertical axis.

property broadcasted: FunctionArray#

if this array has multiple components, broadcast them against each other.

Equivalent to a.broadcast_to(a.shape)

camera: AbstractCamera = <dataclasses._MISSING_TYPE object>#

A model of the sensor used to capture these images.

property channel: ScalarArray[ndarray[Any, dtype[str]]]#

The name of each ESIS channel in a human-readable format.

property dark: Self#

The master dark image for each channel.

Calculated by taking the mean of darks.despiked along axis_time.

property dark_subtracted#

Subtract the master dark from each image in the sequence.

property darks: Self#

The dark images used to construct the master dark image.

This is a concatenation of darks_up and darks_down.

property darks_down: Self#

The dark images collected on the downleg of the trajectory.

This considers all the images after the parachute deployment since there is a transient, anomalous signal that occurs during atmospheric re-entry.

property darks_up: Self#

The dark images collected on the upleg of the trajectory.

This considers all the images up until the moment the shutter door is opened.

Any images without an exposure time close to the median exposure time are ignored. This is intended to remove the first 1 or 2 images from the beginning of each exposure sequence since these images often have a different exposure time than the rest of the sequence.

property despiked: Self#

Remove cosmic rays using astroscrappy.detect_cosmics().

property electrons: Self#

A new copy of these images in units of electrons.

property explicit: FunctionArray#

Converts this array to an instance of named_arrays.AbstractExplicitArray

property indices: dict[str, ScalarArrayRange]#
inputs: ImageHeader = <dataclasses._MISSING_TYPE object>#

A vector which contains the FITS header for each image.

property length: FunctionArray#

L2-norm of this array.

property lights: Self#

The sequence of solar images taken during the flight.

This uses only the images where the ring-laser gyroscope was enabled, so this should represent the images with the best-possible pointing stability.

property ndim: int#

Number of dimensions of the array. Equivalent to numpy.ndarray.ndim.

property num_x: int#

The number of pixels along the horizontal axis.

property num_y: int#

The number of pixels along the vertical axis.

outputs: na.ScalarArray = <dataclasses._MISSING_TYPE object>#

The underlying array storing the image data.

property shape: dict[str, int]#

Shape of the array. Analogous to numpy.ndarray.shape but represented as a dict where the keys are the axis names and the values are the axis sizes.

property size: int#

Total number of elements in the array. Equivalent to numpy.ndarray.size

property taps: TapData#

Split the data into separate images for each tap.

property time_mission_start: Time#

The \(T=0\) time of the mission.

timeline: None | Timeline = None#

The sequence of NSROC events associated with these images.

property type_abstract: Type[AbstractFunctionArray]#

The AbstractArray type corresponding to this array

property type_explicit: Type[FunctionArray]#

The AbstractExplicitArray type corresponding to this array

property unbiased: Self#

A new copy of these images where the bias has been removed.

property value: FunctionArray#

Returns a new array with its units removed, if they exist