clean_cosmic_rays

ndmapper.lib.cosmetics.clean_cosmic_rays(*args, **kwargs)[source] [edit on github]

Identify pixels contaminated by cosmic ray flux, using McCully’s version of the LACosmic algorithm (see lacosmic_spec), record the detections in a copy of the input flags array and replace bad values with an estimate of the clean value, based on a masked mean of surrounding pixels. This works on 2D images (with fitting disabled) and spectra.

Parameters:

inputs : DataFileList or DataFile

2D bias-subtracted input images to be cleaned.

out_names : str-like or list of str-like, optional

Names of cleaned output images. If None (default), the names of the DataFile instances returned will be constructed from those of the corresponding input files, prefixed with ‘x’, as in Gemini IRAF.

x_order, y_order : int or None, optional

Order for fitting and subtracting object continuum and sky line models, prior to running the main cosmic ray detection algorithm. When None, defaults are used, according to the image size (as in the IRAF task gemcrspec). When 0, no fit is done.

sigma : float, optional

Laplacian-to-noise limit for cosmic ray detection. Lower values will flag more pixels as cosmic rays. Default: 4.5.

sigfrac : float, optional

Fractional detection limit for neighboring pixels. For cosmic ray neighbour pixels, a lapacian-to-noise detection limit of sigfrac * sigclip will be used. Default: 0.32.

objlim : float, optional

Minimum contrast between Laplacian image and the fine structure image. Increase this value if cores of bright stars are flagged as cosmic rays. Default: 1.0.

iterations : int, optional

Number of iterations of the detection algorithm to perform. Default: 5.

Returns:

DataFileList

A copy of the input data with cosmic ray detections included in its flags arrays and the corresponding data values replaced by local masked mean values.