subtract_overscan

ccdproc.subtract_overscan(ccd, overscan=None, overscan_axis=1, fits_section=None, median=False, model=None)[source]

Subtract the overscan region from an image.

Parameters:
ccdCCDData

Data to have overscan frame corrected.

overscanCCDData or None, optional

Slice from ccd that contains the overscan. Must provide either this argument or fits_section, but not both. Default is None.

overscan_axis0, 1 or None, optional

Axis along which overscan should combined with mean or median. Axis numbering follows the python convention for ordering, so 0 is the first axis and 1 is the second axis.

If overscan_axis is explicitly set to None, the axis is set to the shortest dimension of the overscan section (or 1 in case of a square overscan). Default is 1.

fits_sectionstr or None, optional

Region of ccd from which the overscan is extracted, using the FITS conventions for index order and index start. See Notes and Examples below. Must provide either this argument or overscan, but not both. Default is None.

medianbool, optional

If true, takes the median of each line. Otherwise, uses the mean. Default is False.

modelModel or None, optional

Model to fit to the data. If None, returns the values calculated by the median or the mean. Default is None.

add_keywordstr, Keyword or dict-like, optional

Item(s) to add to metadata of result. Set to False or None to completely disable logging. Default is to add a dictionary with a single item: The key is the name of this function and the value is a string containing the arguments the function was called with, except the value of this argument.

Returns:
ccdCCDData

CCDData object with overscan subtracted.

Raises:
TypeError

A TypeError is raised if either ccd or overscan are not the correct objects.

Notes

The format of the fits_section string follow the rules for slices that are consistent with the FITS standard (v3) and IRAF usage of keywords like TRIMSEC and BIASSEC. Its indexes are one-based, instead of the python-standard zero-based, and the first index is the one that increases most rapidly as you move through the array in memory order, opposite the python ordering.

The ‘fits_section’ argument is provided as a convenience for those who are processing files that contain TRIMSEC and BIASSEC. The preferred, more pythonic, way of specifying the overscan is to do it by indexing the data array directly with the overscan argument.

Examples

Creating a 100x100 array containing ones just for demonstration purposes:

>>> import numpy as np
>>> from astropy import units as u
>>> arr1 = CCDData(np.ones([100, 100]), unit=u.adu)

The statement below uses all rows of columns 90 through 99 as the overscan:

>>> no_scan = subtract_overscan(arr1, overscan=arr1[:, 90:100])
>>> assert (no_scan.data == 0).all()

This statement does the same as the above, but with a FITS-style section:

>>> no_scan = subtract_overscan(arr1, fits_section='[91:100, :]')
>>> assert (no_scan.data == 0).all()

Spaces are stripped out of the fits_section string.