NDData¶
- class astropy.nddata.NDData(data, uncertainty=None, mask=None, wcs=None, meta=None, unit=None, copy=False, psf=None)[source]¶
Bases:
NDDataBase
A container for
numpy.ndarray
-based datasets, using theNDDataBase
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 dictionary containing further meta information. This class only provides a container for storing such datasets. For further functionality take a look at theSee also
section.See also: https://docs.astropy.org/en/stable/nddata/
- Parameters:
- data
numpy.ndarray
astropy:-like orNDData
astropy:-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. 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
numpy
convention that valid data points are marked byFalse
and invalid ones withTrue
. Defaults toNone
.- wcs
any
type, optional World coordinate system (WCS) for the dataset. Default is
None
.- meta
dict
astropy:-likeobject
, optional Additional meta information about the dataset. If no meta is provided an empty
collections.OrderedDict
is created. Default isNone
.- unitastropy:unit-like, optional
Unit for the dataset. Strings that can be converted to a
Unit
are allowed. Default isNone
.- copy
bool
, optional Indicates whether to save the arguments as copy.
True
copies every attribute before saving it whileFalse
tries 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.
- psf
numpy.ndarray
orpython: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:
TypeError
In case
data
ormeta
don’t meet the restrictions.
See also
Notes
Each attribute can be accessed through the homonymous instance attribute:
data
in aNDData
object can be accessed through thedata
attribute:>>> 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
data
is aQuantity
and 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
ndarray
-like : The stored dataset.any type : Mask for the dataset, if any.
dict
-like : Additional meta information about the dataset.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
numpy
convention that valid data points are marked byFalse
and invalid ones withTrue
.
- meta¶
dict
-like : Additional meta information about the dataset.
- psf¶
- 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 isNDUncertainty
but isn’t mandatory.
- wcs¶
any type : A world coordinate system (WCS) for the dataset, if any.