CCDData#
- class astropy.nddata.CCDData(*args, **kwd)[source]#
Bases:
NDDataArrayA class describing basic CCD data.
The CCDData class is based on the NDData object and includes a data array, uncertainty frame, mask frame, flag frame, meta data, units, and WCS information for a single CCD image.
- Parameters:
- data
CCDDataastropy:-like or array_like The actual data contained in this
CCDDataobject. Note that the data will always be saved by reference, so you should make a copy of thedatabefore passing it in if that’s the desired behavior.- uncertainty
StdDevUncertainty,VarianceUncertainty,InverseVariance,numpy.ndarrayorNone, optional Uncertainties on the data. If the uncertainty is a
numpy.ndarray, it it assumed to be, and stored as, aStdDevUncertainty. Default isNone.- mask
numpy.ndarrayorNone, optional Mask for the data, given as a boolean Numpy array with a shape matching that of the data. The values must be
Falsewhere the data is valid andTruewhen it is not (like Numpy masked arrays). Ifdatais a numpy masked array, providingmaskhere will causes the mask from the masked array to be ignored. Default isNone.- flags
numpy.ndarrayorFlagCollectionorNone, optional Flags giving information about each pixel. These can be specified either as a Numpy array of any type with a shape matching that of the data, or as a
FlagCollectioninstance which has a shape matching that of the data. Default isNone.- wcs
WCSorNone, optional WCS-object containing the world coordinate system for the data. Default is
None.- metadict-like
objectorNone, optional Metadata for this object. “Metadata” here means all information that is included with this object but not part of any other attribute of this particular object, e.g. creation date, unique identifier, simulation parameters, exposure time, telescope name, etc.
- unit
Unitorstr, optional The units of the data. Default is
None.Warning
If the unit is
Noneor not otherwise specified it will raise aValueError- psf
numpy.ndarrayorNone, optional Image representation of the PSF at the center of this image. In order for convolution to be flux-preserving, this should generally be normalized to sum to unity.
- data
- Raises:
ValueErrorIf the
uncertaintyormaskinputs cannot be broadcast (e.g., match shape) ontodata.
Notes
CCDDataobjects can be easily converted to a regularNumpy array using
numpy.asarray.
For example:
>>> from astropy.nddata import CCDData >>> import numpy as np >>> x = CCDData([1,2,3], unit='adu') >>> np.asarray(x) array([1, 2, 3])
This is useful, for example, when plotting a 2D image using matplotlib.
>>> from astropy.nddata import CCDData >>> from matplotlib import pyplot as plt >>> x = CCDData([[1,2,3], [4,5,6]], unit='adu') >>> plt.imshow(x)
- Attributes:
- known_invalid_fits_unit_strings
A dictionary that maps commonly-used fits unit name strings that are technically invalid to the correct valid unit type (or unit string). This is primarily for variant names like “ELECTRONS/S” which are not formally valid, but are unambiguous and frequently enough encountered that it is convenient to map them to the correct unit.
Methods
read(*args, **kwargs)
Classmethodto create an CCDData instance based on aFITSfile. This method usesfits_ccddata_reader()with the provided parameters.write(*args, **kwargs)
Writes the contents of the CCDData instance into a new
FITSfile. This method usesfits_ccddata_writer()with the provided parameters.Attributes Summary
ndarray-like : The stored 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.
Methods Summary
add(operand[, operand2])copy()Return a copy of the CCDData object.
divide(operand[, operand2])multiply(operand[, operand2])subtract(operand[, operand2])to_hdu([hdu_mask, hdu_uncertainty, ...])Creates an HDUList object from a CCDData object.
Attributes Documentation
- data#
- header#
- known_invalid_fits_unit_strings = {'ELECTRONS': Unit("electron"), 'ELECTRONS/S': Unit("electron / s"), 'electrons': Unit("electron")}#
- psf#
- uncertainty#
- unit#
- wcs#
Methods Documentation
- classmethod add(operand, operand2=None, **kwargs)#
- classmethod divide(operand, operand2=None, **kwargs)#
- classmethod multiply(operand, operand2=None, **kwargs)#
- classmethod subtract(operand, operand2=None, **kwargs)#
- to_hdu(hdu_mask='MASK', hdu_uncertainty='UNCERT', hdu_flags=None, wcs_relax=True, key_uncertainty_type='UTYPE', as_image_hdu=False, hdu_psf='PSFIMAGE')[source]#
Creates an HDUList object from a CCDData object.
- Parameters:
- hdu_mask, hdu_uncertainty, hdu_flags, hdu_psf
strorNone, optional If it is a string append this attribute to the HDUList as
ImageHDUwith the string as extension name. Flags are not supported at this time. IfNonethis attribute is not appended. Default is'MASK'for mask,'UNCERT'for uncertainty,'PSFIMAGE'for psf, andNonefor flags.- wcs_relaxbool
Value of the
relaxparameter to use in converting the WCS to a FITS header usingto_header. The commonCTYPERA---TAN-SIPandDEC--TAN-SIPrequiresrelax=Truefor the-SIPpart of theCTYPEto be preserved.- key_uncertainty_type
str, optional The header key name for the class name of the uncertainty (if any) that is used to store the uncertainty type in the uncertainty hdu. Default is
UTYPE.New in version 3.1.
- as_image_hdubool
If this option is
True, the first item of the returnedHDUListis aImageHDU, instead of the defaultPrimaryHDU.
- hdu_mask, hdu_uncertainty, hdu_flags, hdu_psf
- Returns:
- hdulist
HDUList
- hdulist
- Raises:
ValueErrorIf
self.maskis set but not anumpy.ndarray.If
self.uncertaintyis set but not a astropy uncertainty type.If
self.uncertaintyis set but has another unit thenself.data.
NotImplementedErrorSaving flags is not supported.