NDData#
- class astropy.nddata.NDData(data, uncertainty=None, mask=None, wcs=None, meta=None, unit=None, copy=False, psf=None)[source]#
 Bases:
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: https://docs.astropy.org/en/stable/nddata/
- Parameters:
 - data
numpy.ndarrayastropy:-like orNDDataastropy:-like The dataset.
- uncertainty
anytype, 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
anytype, optional Mask for the dataset. Masks should follow the
numpyconvention that valid data points are marked byFalseand invalid ones withTrue. Defaults toNone.- wcs
anytype, optional World coordinate system (WCS) for the dataset. Default is
None.- meta
dictastropy:-likeobject, optional Additional meta information about the dataset. If no meta is provided an empty dict is created. Default is
None.- unitastropy:unit-like, 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.Added in version 1.2.
- psf
numpy.ndarrayorpython:None, optional Image representation of the PSF. In order for convolution to be flux- preserving, this should generally be normalized to sum to unity.
- data
 - Raises:
 TypeErrorIn 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([100., 200., 300., 400.]) >>> nd2.unit Unit("cm")
Attributes Summary
ndarray-like : The stored dataset.any type : Mask for the dataset, if any.
Image representation of the PSF for the dataset.
any type : Uncertainty in the dataset, if any.
Unit: Unit for the dataset, if any.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
numpyconvention that valid data points are marked byFalseand invalid ones withTrue.
- meta = None#
 
- psf#
 
- 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.