NDCube

class ndcube.NDCube(data, wcs, uncertainty=None, mask=None, meta=None, unit=None, extra_coords=None, copy=False, missing_axis=None, **kwargs)[source] [edit on github]

Bases: ndcube.ndcube.NDCubeBase, ndcube.mixins.NDCubePlotMixin, astropy.nddata.mixins.ndarithmetic.NDArithmeticMixin

Attributes Summary

dimensions ‘shape’ gives the shape of the data dimensions; ‘axis_types’ gives the WCS axis type of each dimension, e.g.
extra_coords Dictionary of extra coords where each key is the name of an extra coordinate supplied by user during instantiation of the NDCube.
world_axis_physical_types Returns an iterable of strings describing the physical type for each world axis.

Methods Summary

axis_world_coords(*axes) Returns WCS coordinate values of all pixels for all axes.
crop_by_coords(lower_corner[, …]) Crops an NDCube given minimum values and interval widths along axes.
crop_by_extra_coord(coord_name, …) Crops an NDCube given a minimum value and interval width along an extra coord.
pixel_to_world(*quantity_axis_list) Convert a pixel coordinate to a data (world) coordinate by using all_pix2world.
world_to_pixel(*quantity_axis_list) Convert a world coordinate to a data (pixel) coordinate by using all_world2pix.

Attributes Documentation

dimensions

‘shape’ gives the shape of the data dimensions; ‘axis_types’ gives the WCS axis type of each dimension, e.g. WAVE or HPLT-TAN for wavelength of helioprojected latitude.

Type:Returns a named tuple with two attributes
extra_coords

Dictionary of extra coords where each key is the name of an extra coordinate supplied by user during instantiation of the NDCube.

The value of each key is itself a dictionary with the following keys:
‘axis’: int
The number of the data axis to which the extra coordinate corresponds.
‘value’: astropy.units.Quantity or array-like
The value of the extra coordinate at each pixel/array element along the
corresponding axis (given by the ‘axis’ key, above). Note this means
that the length of ‘value’ must be equal to the length of the data axis
to which is corresponds.
world_axis_physical_types

Returns an iterable of strings describing the physical type for each world axis.

The strings conform to the International Virtual Observatory Alliance standard, UCD1+ controlled Vocabulary. For a description of the standard and definitions of the different strings and string components, see http://www.ivoa.net/documents/latest/UCDlist.html.

Methods Documentation

axis_world_coords(*axes) [edit on github]

Returns WCS coordinate values of all pixels for all axes.

Parameters:axes (int or str, or multiple int or str) – Axis number in numpy ordering or unique substring of world_axis_physical_types of axes for which real world coordinates are desired. axes=None implies all axes will be returned.
Returns:axes_coords (list of astropy.units.Quantity) – Real world coords for axes in order requested by user.

Example

>>> NDCube.all_world_coords(('lat', 'lon')) # doctest: +SKIP
>>> NDCube.all_world_coords(2) # doctest: +SKIP
crop_by_coords(lower_corner, interval_widths=None, upper_corner=None, units=None) [edit on github]

Crops an NDCube given minimum values and interval widths along axes.

Parameters:
  • lower_corner (iterable of astropy.units.Quantity or float) – The minimum desired values along each relevant axis after cropping described in physical units consistent with the NDCube’s wcs object. The length of the iterable must equal the number of data dimensions and must have the same order as the data.
  • interval_widths (iterable of astropy.units.Quantity or float) – The width of the region of interest in each dimension in physical units consistent with the NDCube’s wcs object. The length of the iterable must equal the number of data dimensions and must have the same order as the data. This argument will be removed in versions 2.0, please use upper_corner argument.
  • upper_corner (iterable of astropy.units.Quantity or float) – The maximum desired values along each relevant axis after cropping described in physical units consistent with the NDCube’s wcs object. The length of the iterable must equal the number of data dimensions and must have the same order as the data.
  • units (iterable of astropy.units.quantity.Quantity, optionnal) – If the inputs are set without units, the user must set the units inside this argument as str. The length of the iterable must equal the number of data dimensions and must have the same order as the data.
Returns:

result (NDCube)

crop_by_extra_coord(coord_name, min_coord_value, max_coord_value) [edit on github]

Crops an NDCube given a minimum value and interval width along an extra coord.

Parameters:
  • coord_name (str) – Name of extra coordinate by which to crop.
  • min_coord_value (Single value astropy.units.Quantity) – The minimum desired value of the extra coord after cropping. Unit must be consistent with the extra coord on which cropping is based.
  • min_coord_value – The maximum desired value of the extra coord after cropping. Unit must be consistent with the extra coord on which cropping is based.
Returns:

result (ndcube.NDCube)

pixel_to_world(*quantity_axis_list) [edit on github]

Convert a pixel coordinate to a data (world) coordinate by using all_pix2world.

Parameters:
  • quantity_axis_list (iterable) – An iterable of Quantity with unit as pixel pix. Note that these quantities must be entered as separate arguments, not as one list.
  • origin (int.) – Origin of the top-left corner. i.e. count from 0 or 1. Normally, origin should be 0 when passing numpy indices, or 1 if passing values from FITS header or map attributes. See wcs_pix2world for more information. Default is 0.
Returns:

coord (list) – A list of arrays containing the output coordinates reverse of the wcs axis order.

world_to_pixel(*quantity_axis_list) [edit on github]

Convert a world coordinate to a data (pixel) coordinate by using all_world2pix.

Parameters:
  • quantity_axis_list (iterable) – A iterable of Quantity. Note that these quantities must be entered as separate arguments, not as one list.
  • origin (int) – Origin of the top-left corner. i.e. count from 0 or 1. Normally, origin should be 0 when passing numpy indices, or 1 if passing values from FITS header or map attributes. See wcs_world2pix for more information. Default is 0.
Returns:

coord (list) – A list of arrays containing the output coordinates reverse of the wcs axis order.