CCDData

class ccdproc.CCDData(*args, **kwd)[source]

Bases: astropy.nddata.NDDataArray

A class describing basic CCD data

The CCDData class is based on the NDData object and includes a data array, uncertainty frame, mask frame, meta data, units, and WCS information for a single CCD image.

Parameters:

data : ndarray or CCDData

The actual data contained in this CCDData object. Note that this will always be copies by reference , so you should make copy the data before passing it in if that’s the desired behavior.

uncertainty : StdDevUncertainty or ndarray,

optional Uncertainties on the data.

mask : ndarray, optional

Mask for the data, given as a boolean Numpy array with a shape matching that of the data. The values must be False where the data is valid and True when it is not (like Numpy masked arrays). If data is a numpy masked array, providing mask here will causes the mask from the masked array to be ignored.

flags : ndarray or FlagCollection, 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 FlagCollection instance which has a shape matching that of the data.

wcs : WCS object, optional

WCS-object containing the world coordinate system for the data.

meta : dict-like object, 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 : Unit instance or str, optional

The units of the data.

Raises:

ValueError

If the uncertainty or mask inputs cannot be broadcast (e.g., match shape) onto data.

Notes

CCDData objects can be easily converted to a regular
Numpy array using numpy.asarray

For example:

>>> from ccdproc 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 ccdproc import CCDData   
>>> from matplotlib import pyplot as plt   
>>> x = CCDData([[1,2,3], [4,5,6]], unit='adu') 
>>> plt.imshow(x)   

Methods

read(*args, **kwargs) Classmethod to create an CCDData instance based on a FITS file. This method uses fits_ccddata_reader() with the provided parameters.
write(*args, **kwargs) Writes the contents of the CCDData instance into a new FITS file. This method uses fits_ccddata_writer() with the provided parameters.

Attributes Summary

data
dtype
header
meta
shape
size
uncertainty
unit
wcs

Methods Summary

add(other[, compare_wcs])
copy() Return a copy of the CCDData object.
divide(other[, compare_wcs])
multiply(other[, compare_wcs])
subtract(other[, compare_wcs])
to_hdu([hdu_mask, hdu_uncertainty, hdu_flags]) Creates an HDUList object from a CCDData object.

Attributes Documentation

data
dtype
header
meta
shape
size
uncertainty
unit
wcs

Methods Documentation

add(other, compare_wcs=u'first_found')[source]
copy()[source]

Return a copy of the CCDData object.

divide(other, compare_wcs=u'first_found')[source]
multiply(other, compare_wcs=u'first_found')[source]
subtract(other, compare_wcs=u'first_found')[source]
to_hdu(hdu_mask=u'MASK', hdu_uncertainty=u'UNCERT', hdu_flags=None)[source]

Creates an HDUList object from a CCDData object.

Parameters:

hdu_mask, hdu_uncertainty, hdu_flags : str or None, optional

If it is a string append this attribute to the HDUList as ImageHDU with the string as extension name. Flags are not supported at this time. If None this attribute is not appended. Default is 'MASK' for mask, 'UNCERT' for uncertainty and None for flags.

Returns:

hdulist : astropy.io.fits.HDUList object

Raises:

ValueError

  • If self.mask is set but not a ndarray.
  • If self.uncertainty is set but not a StdDevUncertainty.
  • If self.uncertainty is set but has another unit then self.data.

NotImplementedError

Saving flags is not supported.