Filtergram#

class sdo.aia.Filtergram(inputs=0, outputs=0, axis_time='time', axis_wavelength='wavelength', axis_detector_x='detector_x', axis_detector_y='detector_y')[source]#

Bases: FunctionArray[ExplicitTemporalSpectralWcsPositionalVectorArray, ScalarArray]

A representation of an AIA image sequence using any number of filters.

Attributes

axes

A tuple of str representing the names of each dimension of this array.

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_detector_x

The logical axis corresponding to changes in detector \(x\)-coordinate.

axis_detector_y

The logical axis corresponding to changes in detector \(y\)-coordinate.

axis_time

The logical axis corresponding to changes in time.

axis_wavelength

The logical axis corresponding to changes in wavelength.

broadcasted

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

explicit

Converts this array to an instance of named_arrays.AbstractExplicitArray.

indices

Compute the index of each element of this array.

inputs

The inputs of the function.

length

L2-norm of this array.

ndim

Number of dimensions of the array.

outputs

The outputs of the function.

shape

The number of elements along each axis of the array.

size

Total number of elements in the array.

type_abstract

The named_arrays.AbstractArray type corresponding to this array.

type_explicit

The named_arrays.AbstractExplicitArray type corresponding to this array.

value

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

Methods

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

add_axes(axes)

Add new singleton axes to this array.

all([axis, where])

Return True if all of the elements along the given axes are True.

any([axis, where])

Return True if any of the elements along the given axes are True.

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

Copy of the array cast to a specific data type.

broadcast_to(shape[, append])

A new view of this array with the specified shape.

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()

Create a deep copy of this array.

copy_shallow()

Create a shallow copy of this array.

empty(shape_base, shape_wcs[, axis_time, ...])

Create an empty Filtergrams object.

from_fits(path, wavelength[, axis_time, ...])

Given a single FITS file or an array of FITS files with the same OBSID, construct a SpectrographObservation object.

from_scalar_array(a[, like])

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

from_time_range(time_start, time_stop, ...)

Given a time range and a wavelength, download the corresponding AIA filtergram.

index(value[, axis])

index_secant(value[, axis])

interp_linear(item)

Linearly interpolate this array to find its value at the given fractional index.

max([axis, initial, where])

The maximum value of this array along the given axes.

mean([axis, where])

The mean value of this array along the given axes.

median([axis])

The median value of this array along the given axes.

min([axis, initial, where])

The minimum value of this array along the given axes.

ndindex([axis_ignored])

An iterator that yields the index of each element of this array.

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

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

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

The requested percentile of this array along the given axes.

ptp([axis])

The peak-to-peak value of this array along the given axes.

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)

Reorganize this array into a new shape.

rms([axis, where])

The root-mean-square of this array along the given axes.

std([axis, where])

The standard deviation of this array along the given axes.

sum([axis, where])

The sum of each element of this array along the given axes.

to(unit[, equivalencies, copy])

Convert this array to a new unit.

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.

to_value(unit[, equivalencies])

The numerical value of this array, possibly in a different unit.

transpose([axes])

Reorder the axes of this array to the given sequence.

var([axis, where])

The variance of this array along the given axes.

vmr([axis, where])

The variance-to-mean ratio of this array along the given axes.

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 sdo.aia.Filtergram
Parameters:
  • inputs (InputsT)

  • outputs (OutputsT)

  • axis_time (str)

  • axis_wavelength (str)

  • axis_detector_x (str)

  • axis_detector_y (str)

classmethod empty(shape_base, shape_wcs, axis_time='time', axis_wavelength='wavelength', axis_detector_x='detector_x', axis_detector_y='detector_y')[source]#

Create an empty Filtergrams object.

Parameters:
  • shape_base (dict[str, int]) – The shape of the result excluding the axes handled by WCS.

  • shape_wcs (dict[str, int]) – The shape of the axes handled by WCS.

  • axis_time (str) – The logical axis corresponding to changes in time.

  • axis_wavelength (str) – The logical axis corresponding to changes in wavelength.

  • axis_detector_x (str) – The logical axis corresponding to changes in detector \(x\)-coordinate.

  • axis_detector_y (str) – The logical axis corresponding to changes in detector \(y\)-coordinate.

Return type:

Self

classmethod from_fits(path, wavelength, axis_time='time', axis_wavelength='wavelength', axis_detector_x='detector_x', axis_detector_y='detector_y')[source]#

Given a single FITS file or an array of FITS files with the same OBSID, construct a SpectrographObservation object.

Parameters:
  • path (Path | ScalarArray[Path]) – A single FITS file or an array of FITS files to load.

  • window – The spectral window to load.

  • axis_time (str) – The logical axis corresponding to changes in time.

  • axis_wavelength (str) – The logical axis corresponding to changes in wavelength.

  • axis_detector_x (str) – The logical axis corresponding to changes in detector \(x\)-coordinate.

  • axis_detector_y (str) – The logical axis corresponding to changes in detector \(y\)-coordinate.

  • wavelength (Quantity | ScalarArray)

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

classmethod from_time_range(time_start, time_stop, wavelength, user_email=None, series='aia.lev1_euv_12s', axis_time='time', axis_detector_x='detector_x', axis_detector_y='detector_y', limit=None)[source]#

Given a time range and a wavelength, download the corresponding AIA filtergram.

Important

Your email must be registered with JSOC to use this method.

Parameters:
  • time_start (str | Time) – The start time of the search period

  • time_stop (str | Time) – The end time of the search period.

  • wavelength (Quantity | ScalarArray) – The wavelengths to download. Must be a valid AIA wavelength.

  • user_email (None | str) – An email address used to notify the user that their JSOC request is complete. This email must be registered with JSOC before using this function. If None, the value is taken from the JSOC_EMAIL environment variable.

  • series (Literal['aia.lev1_euv_12s', 'aia.lev1_uv_24s']) – The data series to download. See the sunpy documentation for more information.

  • axis_time (str) – The logical axis corresponding to changes in time.

  • axis_detector_x (str) – The logical axis corresponding to changes in detector \(x\)-coordinate.

  • axis_detector_y (str) – The logical axis corresponding to changes in detector \(y\)-coordinate.

  • limit (None | int) – The maximum number of files to download for each wavelength.

add_axes(axes)#

Add new singleton axes to this array.

Parameters:

axes (str | Sequence[str]) – Either a single axis name or a sequence of axis names add to this array.

Return type:

FunctionArray

See also

named_arrays.add_axes()

A functional version of this method.

all(axis=None, where=<no value>)#

Return True if all of the elements along the given axes are True.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

See also

numpy.all()

A functional version of this method.

any(axis=None, where=<no value>)#

Return True if any of the elements along the given axes are True.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

See also

numpy.any()

A functional version of this method.

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)#

A new view of this array with the specified shape.

Parameters:
  • shape (dict[str, int]) – The shape of the new array.

  • append (bool) – If True, shape will be appended to the current shape of this array before broadcasting.

  • self (Self)

Return type:

Self

See also

named_arrays.broadcast_to()

A functional version of this method.

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()#

Create a deep copy of this array.

Parameters:

self (Self)

Return type:

Self

copy_shallow()#

Create a shallow copy of this array.

Parameters:

self (Self)

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)#

Linearly interpolate this array to find its value at the given fractional index.

Parameters:

item (dict[str, AbstractArray]) – A fractional index at which to evaluate the array.

Return type:

FunctionArray

max(axis=None, initial=<no value>, where=<no value>)#

The maximum value of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • initial (ArrayLike) – The initial value of the minimum, required if where provided.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

See also

numpy.max()

A functional version of this method.

mean(axis=None, where=<no value>)#

The mean value of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

See also

numpy.mean()

A functional version of this method.

median(axis=None)#

The median value of this array along the given axes.

Parameters:

axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

See also

numpy.median()

A functional version of this method.

min(axis=None, initial=<no value>, where=<no value>)#

The minimum value of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • initial (ArrayLike) – The initial value of the minimum, required if where provided.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

See also

numpy.min()

A functional version of this method.

ndindex(axis_ignored=None)#

An iterator that yields the index of each element of this array.

Parameters:
  • axis_ignored (None | str | Sequence[str]) – The of the array to ignore when generating the iterator.

  • self (Self)

Return type:

Iterator[dict[str, int]]

See also

named_arrays.ndindex()

A functional version of this method.

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/sdo.aia.Filtergram_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)#

The requested percentile of this array along the given axes.

Parameters:
  • q (int | float | Quantity | Self) – The percentile to compute.

  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • out (None | Self) – An optional output array in which to place the result.

  • overwrite_input (bool) – Whether to overwrite the input array.

  • method (str) – How to interpolate the result.

  • keepdims (bool) – A boolean flag indicating whether to keep the reduced dimensions.

  • self (Self)

See also

numpy.percentile()

A functional version of this method.

ptp(axis=None)#

The peak-to-peak value of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • self (Self)

Return type:

Self

See also

numpy.ptp()

A functional version of this method.

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)#

Reorganize this array into a new shape.

Parameters:
  • shape (dict[str, int]) – The new shape of the array, must be compatible with this array.

  • self (Self)

Return type:

Self

rms(axis=None, where=<no value>)#

The root-mean-square of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

std(axis=None, where=<no value>)#

The standard deviation of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

See also

numpy.std()

A functional version of this method.

sum(axis=None, where=<no value>)#

The sum of each element of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

See also

numpy.sum()

A functional version of this method.

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_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.

to_value(unit, equivalencies=[])#

The numerical value of this array, possibly in a different unit.

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

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.

Return type:

FunctionArray

transpose(axes=None)#

Reorder the axes of this array to the given sequence.

Parameters:
  • axes (None | Sequence[str]) – The new axis ordering of this array.

  • self (Self)

Return type:

Self

See also

numpy.transpose()

The numpy version of this method.

var(axis=None, where=<no value>)#

The variance of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • where (Self) – An optional mask which selects which elements to be considered.

  • self (Self)

Return type:

Self

See also

numpy.var()

A functional version of this method.

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

The variance-to-mean ratio of this array along the given axes.

Parameters:
  • axis (None | str | Sequence[str]) – The logical axis or axes along which the operation is computed.

  • where (Self) – An optional mask which selects which elements to be considered.

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 axes: tuple[str, ...]#

A tuple of str representing the names of each dimension of this array.

Must have the same length as the number of dimensions of this array.

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_detector_x: str = 'detector_x'#

The logical axis corresponding to changes in detector \(x\)-coordinate.

axis_detector_y: str = 'detector_y'#

The logical axis corresponding to changes in detector \(y\)-coordinate.

axis_time: str = 'time'#

The logical axis corresponding to changes in time.

axis_wavelength: str = 'wavelength'#

The logical axis corresponding to changes in wavelength.

property broadcasted: FunctionArray#

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

Equivalent to a.broadcast_to(a.shape).

property explicit: FunctionArray#

Converts this array to an instance of named_arrays.AbstractExplicitArray.

property indices: dict[str, ScalarArrayRange]#

Compute the index of each element of this array.

See also

named_arrays.indices()

A functional version of this method.

inputs: InputsT = 0#

The inputs of the function.

property length: FunctionArray#

L2-norm of this array.

property ndim: int#

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

outputs: OutputsT = 0#

The outputs of the function.

property shape: dict[str, int]#

The number of elements along each axis 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 type_abstract: Type[AbstractFunctionArray]#

The named_arrays.AbstractArray type corresponding to this array.

property type_explicit: Type[FunctionArray]#

The named_arrays.AbstractExplicitArray type corresponding to this array.

property value: FunctionArray#

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