reduction.preproc.ccdred

reduction.preproc.ccdred(
    ccd,
    output=None,
    extension=None,
    trimsec=None,
    mbiaspath=None,
    mdarkpath=None,
    mflatpath=None,
    mfrinpath=None,
    mbias=None,
    mdark=None,
    mflat=None,
    mfrin=None,
    fringe_flat_fielded=True,
    fringe_scale=None,
    fringe_scale_region=None,
    fringe_scale_kw=None,
    gain=1,
    gain_key='GAIN',
    gain_unit=u.electron / u.adu,
    rdnoise=0,
    rdnoise_key='RDNOISE',
    rdnoise_unit=u.electron,
    exptime_key='EXPTIME',
    exptime_frin=None,
    exptime_dark=None,
    exptime_data=None,
    dark_scale=False,
    pixel_min=None,
    pixel_min_fill=0,
    pixel_max=None,
    pixel_max_fill=65535,
    flat_mask=0,
    flat_fill=1,
    flat_norm_value=1,
    do_crrej=False,
    crrej_kw=None,
    propagate_crmask=False,
    verbose_crrej=False,
    verbose_bdf=1,
    output_verify='fix',
    overwrite=True,
    dtype='float32',
)

Run the basic CCD calibration sequence.

The operations run in this order when their master frame is supplied: trim, bias subtraction, dark subtraction, fringe subtraction (before or after flat correction according to fringe_flat_fielded), flat correction, and optional cosmic-ray rejection. Pixel limits and output dtype are applied last.

Parameters

ccd : FITS - like

CCDData, FITS HDU, array, path, or number accepted by _parse_image.

output : path-like or None = None

Save the reduced CCD to this path. Default: None.

extension : extension selector = None

FITS extension passed to _parse_image. Default: None.

trimsec : str or None = None

FITS-style section applied to the science and supplied calibration frames. Default: None.

mbiaspath : path-like or None = None

Paths to master bias, dark, flat, and fringe frames. A corresponding m* object takes precedence when both are supplied; the path is still recorded in the output header. Defaults: None.

mdarkpath : path-like or None = None

Paths to master bias, dark, flat, and fringe frames. A corresponding m* object takes precedence when both are supplied; the path is still recorded in the output header. Defaults: None.

mflatpath : path-like or None = None

Paths to master bias, dark, flat, and fringe frames. A corresponding m* object takes precedence when both are supplied; the path is still recorded in the output header. Defaults: None.

mfrinpath : path-like or None = None

Paths to master bias, dark, flat, and fringe frames. A corresponding m* object takes precedence when both are supplied; the path is still recorded in the output header. Defaults: None.

mbias : ~astropy.nddata.CCDData or None = None

In-memory master calibration frames. Defaults: None.

mdark : ~astropy.nddata.CCDData or None = None

In-memory master calibration frames. Defaults: None.

mflat : ~astropy.nddata.CCDData or None = None

In-memory master calibration frames. Defaults: None.

mfrin : ~astropy.nddata.CCDData or None = None

In-memory master calibration frames. Defaults: None.

fringe_flat_fielded : bool = True

If True, subtract the fringe after flat correction. If False, subtract it before flat correction. Default: True.

fringe_scale : numeric, ~numpy.ndarray, callable, str, or None = None

Fringe scaling passed to frincor. Exposure modes are "exp", "exposure", and "exptime". Default: None.

fringe_scale_region : ~numpy.ndarray or str = None

Mask or FITS-style section used by a callable fringe scale. Default: None.

fringe_scale_kw : dict or None = None

Keywords passed to a callable fringe scale. Default: None.

gain : numeric or ~astropy.units.Quantity = 1

Detector gain and read noise used only for cosmic-ray rejection. Values without units use gain_unit and rdnoise_unit. Defaults: 1 and 0.

rdnoise : numeric or ~astropy.units.Quantity = 1

Detector gain and read noise used only for cosmic-ray rejection. Values without units use gain_unit and rdnoise_unit. Defaults: 1 and 0.

gain_key : str = 'GAIN'

Header keywords used when gain or rdnoise is not supplied. Defaults: "GAIN" and "RDNOISE".

rdnoise_key : str = 'GAIN'

Header keywords used when gain or rdnoise is not supplied. Defaults: "GAIN" and "RDNOISE".

gain_unit : ~astropy.units.Unit = u.electron / u.adu

Units for header or explicit gain and read-noise values. Defaults: u.electron / u.adu and u.electron.

rdnoise_unit : ~astropy.units.Unit = u.electron / u.adu

Units for header or explicit gain and read-noise values. Defaults: u.electron / u.adu and u.electron.

exptime_key : str = 'EXPTIME'

Header keyword used for dark/fringe exposure scaling. Default: "EXPTIME".

exptime_frin : numeric or None = None

Explicit fringe, dark, and science exposure times. Missing values are read from exptime_key when the relevant scaling is enabled. Defaults: None.

exptime_dark : numeric or None = None

Explicit fringe, dark, and science exposure times. Missing values are read from exptime_key when the relevant scaling is enabled. Defaults: None.

exptime_data : numeric or None = None

Explicit fringe, dark, and science exposure times. Missing values are read from exptime_key when the relevant scaling is enabled. Defaults: None.

dark_scale : bool = False

Scale the dark by exptime_data / exptime_dark before subtraction. Default: False.

pixel_min : numeric or None = None

Replace science values below/above the limit with pixel_min_fill/ pixel_max_fill. Defaults: None.

pixel_max : numeric or None = None

Replace science values below/above the limit with pixel_min_fill/ pixel_max_fill. Defaults: None.

pixel_min_fill : numeric = 0

Replacement values for the pixel limits. Defaults: 0 and 65535.

pixel_max_fill : numeric = 0

Replacement values for the pixel limits. Defaults: 0 and 65535.

flat_mask : numeric or ~numpy.ndarray = 0

Flat pixels selected by this threshold or mask are replaced with flat_fill. Default: 0.

flat_fill : numeric = 1

Replacement value for selected flat pixels. Default: 1.

flat_norm_value : numeric or None = 1

Divide the flat by this value before correction. None uses its mean. Default: 1.

do_crrej : bool = False

Run crrej after bias, dark, and flat processing. Default: False.

crrej_kw : dict or None = None

Keyword arguments passed to crrej. None uses the package’s L.A. Cosmic defaults and logs a warning. Default: None.

Choose parameters for the data; defaults are suitable only for a quick check and differ across IRAF, IDL, and Python implementations. Inspect astroscrappy.detect_cosmics.__doc__ for available options, or see https://nbviewer.jupyter.org/github/ysbach/AO2019/blob/master/Notebooks/07-Cosmic_Ray_Rejection.ipynb

propagate_crmask : bool = False

Add the cosmic-ray mask to the CCD mask. Default: False.

verbose_crrej : bool = False

Enable cosmic-ray rejection logging. Default: False.

verbose_bdf : int = 1

Verbosity for bias, dark, flat, fringe, and output logging. Default: 1.

output_verify : str = 'fix'

FITS verification mode: "fix", "silentfix", "ignore", "warn", or "exception". Combine "fix" or "silentfix" with "+ignore", "+warn", or "+exception" as needed, for example "fix+warn". Default: "fix". See http://docs.astropy.org/en/stable/io/fits/api/verification.html#verify

overwrite : bool = True

Overwrite output when it exists. Default: True.

dtype : dtype - like = 'float32'

Output data type. Default: "float32".

Returns

: ~astropy.nddata.CCDData

Reduced CCD. The input is copied before processing.

Notes

Existing uncertainty attributes on input and calibration frames are ignored.

The old names calc_err, unit, dark_exposure, data_exposure, exposure_key, exposure_unit, normalize_exposure, normalize_average, normalize_median, flat_min_value, and crrej_kwargs are not parameters of this API. Use exptime_dark, exptime_data, and exptime_key for available exposure scaling, flat_norm_value for flat normalization, and crrej_kw for cosmic-ray options. Supply units on the input CCDData; no separate unit argument is accepted.