NDData¶
-
class
astropy.nddata.NDData(data, uncertainty=None, mask=None, wcs=None, meta=None, unit=None, copy=False)[source]¶ Bases:
astropy.nddata.NDDataBaseA container for
numpy.ndarray-based datasets, using theNDDataBaseinterface.The key distinction from raw
numpy.ndarrayis the presence of additional metadata such as uncertainty, mask, unit, a coordinate system and/or a dictionary containing further meta information. This class only provides a container for storing such datasets. For further functionality take a look at theSee alsosection.See also: http://docs.astropy.org/en/stable/nddata/
Parameters: - data :
numpy.ndarray-like orNDData-like The dataset.
- uncertainty : any type, optional
Uncertainty in the dataset. Should have an attribute
uncertainty_typethat defines what kind of uncertainty is stored, for example"std"for standard deviation or"var"for variance. A metaclass defining such an interface isNDUncertainty- but isn’t mandatory. If the uncertainty has no such attribute the uncertainty is stored asUnknownUncertainty. Defaults toNone.- mask : any type, optional
Mask for the dataset. Masks should follow the
numpyconvention that valid data points are marked byFalseand invalid ones withTrue. Defaults toNone.- wcs : any type, optional
World coordinate system (WCS) for the dataset. Default is
None.- meta :
dict-like object, optional Additional meta information about the dataset. If no meta is provided an empty
collections.OrderedDictis created. Default isNone.- unit :
Unit-like or str, optional Unit for the dataset. Strings that can be converted to a
Unitare allowed. Default isNone.- copy :
bool, optional Indicates whether to save the arguments as copy.
Truecopies every attribute before saving it whileFalsetries to save every parameter as reference. Note however that it is not always possible to save the input as reference. Default isFalse.New in version 1.2.
Raises: - TypeError
In case
dataormetadon’t meet the restrictions.
See also
Notes
Each attribute can be accessed through the homonymous instance attribute:
datain aNDDataobject can be accessed through thedataattribute:>>> from astropy.nddata import NDData >>> nd = NDData([1,2,3]) >>> nd.data array([1, 2, 3])
Given a conflicting implicit and an explicit parameter during initialization, for example the
datais aQuantityand the unit parameter is notNone, 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
datandarray-like : The stored dataset.maskany type : Mask for the dataset, if any. metadict-like : Additional meta information about the dataset.uncertaintyany type : Uncertainty in the dataset, if any. unitUnit: Unit for the dataset, if any.wcsany type : A world coordinate system (WCS) for the dataset, if any. Attributes Documentation
-
mask¶ any type : Mask for the dataset, if any.
Masks should follow the
numpyconvention that valid data points are marked byFalseand invalid ones withTrue.
-
uncertainty¶ any type : Uncertainty in the dataset, if any.
Should have an attribute
uncertainty_typethat defines what kind of uncertainty is stored, such as'std'for standard deviation or'var'for variance. A metaclass defining such an interface isNDUncertaintybut isn’t mandatory.
-
wcs¶ any type : A world coordinate system (WCS) for the dataset, if any.
- data :