Bases: object
A Superclass for array-based data in Astropy.
The key distinction from raw numpy arrays is the presence of additional metadata such as uncertainties, a mask, units, flags, and/or a coordinate system.
Parameters: |
uncertainty : NDUncertainty, optional
mask : ndarray-like, optional
flags : ndarray-like or FlagCollection, optional
wcs : undefined, optional
meta : dict-like object, optional
unit : UnitBase instance or str, optional
|
---|---|
Raises: | ValueError :
|
Notes
NDData objects can be easily converted to a regular Numpy array using numpy.asarray
For example:
>>> from astropy.nddata import NDData
>>> import numpy as np
>>> x = NDData([1,2,3])
>>> np.asarray(x)
array([1, 2, 3])
If the NDData object has a mask, numpy.asarray will return a Numpy masked array.
This is useful, for example, when plotting a 2D image using matplotlib:
>>> from astropy.nddata import NDData
>>> from matplotlib import pyplot as plt
>>> x = NDData([[1,2,3], [4,5,6]])
>>> plt.imshow(x)
Attributes Summary
dtype | numpy.dtype of this object’s data. |
flags | |
mask | |
ndim | integer dimensions of this object’s data |
shape | shape tuple of this object’s data. |
size | integer size of this object’s data. |
uncertainty | |
unit |
Methods Summary
add(operand[, propagate_uncertainties]) | Add another dataset (operand) to this dataset. |
convert_unit_to(unit[, equivalencies]) | Returns a new NDData object whose values have been converted to a new unit. |
divide(operand[, propagate_uncertainties]) | Divide another dataset (operand) to this dataset. |
multiply(operand[, propagate_uncertainties]) | Multiply another dataset (operand) to this dataset. |
read(*args, **kwargs) | Read in data |
subtract(operand[, propagate_uncertainties]) | Subtract another dataset (operand) to this dataset. |
write(data, *args, **kwargs) | Write out data |
Attributes Documentation
numpy.dtype of this object’s data.
integer dimensions of this object’s data
shape tuple of this object’s data.
integer size of this object’s data.
Methods Documentation
Add another dataset (operand) to this dataset.
Parameters: | operand : NDData
propagate_uncertainties : bool
|
---|---|
Returns: | result : NDData
|
Notes
This method requires the datasets to have identical WCS properties, equivalent units, and identical shapes. Flags and meta-data get set to None in the resulting dataset. The unit in the result is the same as the unit in self. Uncertainties are propagated, although correlated errors are not supported by any of the built-in uncertainty classes. If uncertainties are assumed to be correlated, a warning is issued by default (though this can be disabled via the astropy.nddata.conf.warn_unsupported_correlated configuration item). Values masked in either dataset before the operation are masked in the resulting dataset.
Returns a new NDData object whose values have been converted to a new unit.
Parameters: | unit : astropy.units.UnitBase instance or str
equivalencies : list of equivalence pairs, optional
|
---|---|
Returns: | result : NDData
|
Raises: | UnitsError
|
Notes
Flags are set to None in the result.
Divide another dataset (operand) to this dataset.
Parameters: | operand : NDData
propagate_uncertainties : bool
|
---|---|
Returns: | result : NDData
|
Notes
This method requires the datasets to have identical WCS properties, equivalent units, and identical shapes. Flags and meta-data get set to None in the resulting dataset. The unit in the result is the same as the unit in self. Uncertainties are propagated, although correlated errors are not supported by any of the built-in uncertainty classes. If uncertainties are assumed to be correlated, a warning is issued by default (though this can be disabled via the astropy.nddata.conf.warn_unsupported_correlated configuration item). Values masked in either dataset before the operation are masked in the resulting dataset.
Multiply another dataset (operand) to this dataset.
Parameters: | operand : NDData
propagate_uncertainties : bool
|
---|---|
Returns: | result : NDData
|
Notes
This method requires the datasets to have identical WCS properties, equivalent units, and identical shapes. Flags and meta-data get set to None in the resulting dataset. The unit in the result is the same as the unit in self. Uncertainties are propagated, although correlated errors are not supported by any of the built-in uncertainty classes. If uncertainties are assumed to be correlated, a warning is issued by default (though this can be disabled via the astropy.nddata.conf.warn_unsupported_correlated configuration item). Values masked in either dataset before the operation are masked in the resulting dataset.
Read in data
The arguments passed to this method depend on the format
Subtract another dataset (operand) to this dataset.
Parameters: | operand : NDData
propagate_uncertainties : bool
|
---|---|
Returns: | result : NDData
|
Notes
This method requires the datasets to have identical WCS properties, equivalent units, and identical shapes. Flags and meta-data get set to None in the resulting dataset. The unit in the result is the same as the unit in self. Uncertainties are propagated, although correlated errors are not supported by any of the built-in uncertainty classes. If uncertainties are assumed to be correlated, a warning is issued by default (though this can be disabled via the astropy.nddata.conf.warn_unsupported_correlated configuration item). Values masked in either dataset before the operation are masked in the resulting dataset.
Write out data
The arguments passed to this method depend on the format