lacosmic_spec

ndmapper.lib.cosmetics.lacosmic_spec(input_ndd, x_order=None, y_order=None, sigclip=4.5, sigfrac=0.32, objlim=1.0, niter=5, sepmed=True, cleantype='meanmask')[source] [edit on github]

Detect and clean cosmic rays in a 2D wavelength-dispersed image, using the well-known LA Cosmic algorithm of van Dokkum (2001)*, as implemented in McCully’s optimized version for Python, “lacosmicx”+.

lacosmicx is an optional dependency, whose absence will cause this function to fail with an ImportError. For the time being, the slightly modified fork at https://github.com/jehturner/lacosmicx must be used.

Currently, input and output bad pixel masks are expected to be found in the NDDataArray flags attribute, but this will likely change to mask in future (throughout NDMapper).

Parameters:

input_ndd : NDDataArray-like

Input image in which cosmic rays are to be detected.

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.

sigclip : 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 neighbor 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.

niter : int, optional

Number of iterations of the LA Cosmic algorithm to perform. Default: 5.

sepmed : boolean, optional

Use the separable median filter instead of the full median filter. The separable median is not identical to the full median filter, but they are approximately the same and the separable median filter is significantly faster and still detects cosmic rays well. Default: True

cleantype : {‘median’, ‘medmask’, ‘meanmask’, ‘idw’}, optional

Set which clean algorithm is used: ‘median’: An umasked 5x5 median filter ‘medmask’: A masked 5x5 median filter ‘meanmask’: A masked 5x5 mean filter ‘idw’: A masked 5x5 inverse distance weighted interpolation Default: “meanmask”.

Returns:

NDLater

A cleaned copy of the input, with cosmic ray detections added to its flags array (with a value of 8).