NDData

class astropy.nddata.NDData(data, uncertainty=None, mask=None, wcs=None, meta=None, unit=None, copy=False)[source] [edit on github]

Bases: astropy.nddata.NDDataBase

A container for ndarray-based datasets, using the NDDataBase interface.

The key distinction from raw numpy.ndarray is the presence of additional metadata such as uncertainty, mask, unit, a coordinate system and/or a dict containg further meta information. This class only provides a container for storing such datasets. For further functionality take a look at the See also section.

Parameters:

data : ndarray-like or NDData-like

The dataset.

uncertainty : any type, optional

Uncertainty in the dataset. Should have an attribute uncertainty_type that defines what kind of uncertainty is stored, for example "std" for standard deviation or "var" for variance. If the uncertainty has no such attribute the uncertainty is stored inside an UnknownUncertainty . A metaclass defining such an interface is NDUncertainty but isn’t mandatory. Defaults to None.

mask : any type, optional

Mask for the dataset. Masks should follow the numpy convention that valid data points are marked by False and invalid ones with True. Defaults to None.

wcs : any type, optional

A world coordinate system (WCS) for the dataset. Default is None.

meta : dict-like object, optional

Meta information about the dataset. If no meta is provided an empty collections.OrderedDict is created.

unit : Unit-like or str, optional

Unit for the dataset. Default is None.

copy : bool, optional

Save the attributes as copy or as reference. True copies every attribute before saving it while False tries to save every parameter as reference. Note however that it is not always possible to save each input as reference. Default is False.

Raises:

TypeError:

In case any parameter does not fulfill the classes restrictions.

Notes

Each attribute can be accessed through the homonymous instance attribute, such as data in a NDData object can be accessed through the data attribute.

For example:

>>> from astropy.nddata import NDData
>>> nd = NDData([1,2,3])
>>> nd.data
array([1, 2, 3])

Given an implicit parameter and an explicit one during initialization, for example the data is a Quantity and the unit parameter is not None. Then the implicit parameter is replaced (without conversion) by the explicit one and a warning is issued:

>>> import numpy as np
>>> import astropy.units as u
>>> q = np.array([1,2,3,4]) * u.m
>>> nd2 = NDData(q, unit=u.cm)  
INFO: Overwriting Quantity's current unit with specified
unit [astropy.nddata.nddata]
>>> nd2.data  
array([ 1.,  2.,  3.,  4.])
>>> nd2.unit  
Unit("cm")

Attributes Summary

data ndarray-like : The stored dataset.
mask any type : Mask for the dataset, if any.
meta dict-like : Meta information about the dataset, if any.
uncertainty any type : Uncertainty in the dataset, if any.
unit Unit : Unit for the dataset, if any.
wcs any type : A world coordinate system (WCS) for the dataset, if any.

Attributes Documentation

data

ndarray-like : The stored dataset.

mask

any type : Mask for the dataset, if any.

Masks should follow the numpy convention that valid data points are marked by False and invalid ones with True.

meta

dict-like : Meta information about the dataset, if any.

uncertainty

any type : Uncertainty in the dataset, if any.

Should have an attribute uncertainty_type that defines what kind of uncertainty is stored, such as 'std' for standard deviation or 'var' for variance. A metaclass defining such an interface is NDUncertainty but isn’t mandatory.

unit

Unit : Unit for the dataset, if any.

wcs

any type : A world coordinate system (WCS) for the dataset, if any.