cosmicray_lacosmic(ccd, sigclip=4.5, sigfrac=0.3, objlim=5.0, gain=1.0, readnoise=6.5, satlevel=65535.0, pssl=0.0, niter=4, sepmed=True, cleantype='meanmask', fsmode='median', psfmodel='gauss', psffwhm=2.5, psfsize=7, psfk=None, psfbeta=4.765, verbose=False, gain_apply=True)¶
Identify cosmic rays through the L.A. Cosmic technique. The L.A. Cosmic technique identifies cosmic rays by identifying pixels based on a variation of the Laplacian edge detection. The algorithm is an implementation of the code describe in van Dokkum (2001)  as implemented by McCully (2014) . If you use this algorithm, please cite these two works.
Data to have cosmic ray cleaned.
- gain_applybool, optional
True, return gain-corrected data, with correct units, otherwise do not gain-correct the data. Default is
Trueto preserve backwards compatibility.
- sigclipfloat, optional
Laplacian-to-noise limit for cosmic ray detection. Lower values will flag more pixels as cosmic rays. Default: 4.5.
- sigfracfloat, optional
Fractional detection limit for neighboring pixels. For cosmic ray neighbor pixels, a Laplacian-to-noise detection limit of sigfrac * sigclip will be used. Default: 0.3.
- objlimfloat, 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: 5.0.
- psslfloat, optional
Previously subtracted sky level in ADU. We always need to work in electrons for cosmic ray detection, so we need to know the sky level that has been subtracted so we can add it back in. Default: 0.0.
- gainfloat or
Gain of the image (electrons / ADU). We always need to work in electrons for cosmic ray detection. Default: 1.0
- readnoisefloat, optional
Read noise of the image (electrons). Used to generate the noise model of the image. Default: 6.5.
- satlevelfloat, optional
Saturation level of the image (electrons). This value is used to detect saturated stars and pixels at or above this level are added to the mask. Default: 65535.0.
- niterint, optional
Number of iterations of the LA Cosmic algorithm to perform. Default: 4.
- sepmedbool, 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, the separable median filter is significantly faster, and still detects cosmic rays well. Note, this is a performance feature, and not part of the original L.A. Cosmic. Default: True
- cleantypestr, optional
Set which clean algorithm is used:
"median": An unmasked 5x5 median filter.
"medmask": A masked 5x5 median filter.
"meanmask": A masked 5x5 mean filter.
"idw": A masked 5x5 inverse distance weighted interpolation.
- fsmodestr, optional
Method to build the fine structure image:
"median": Use the median filter in the standard LA Cosmic algorithm.
"convolve": Convolve the image with the psf kernel to calculate the fine structure image.
- psfmodelstr, optional
Model to use to generate the psf kernel if fsmode == ‘convolve’ and psfk is None. The current choices are Gaussian and Moffat profiles:
"moffat"produce circular PSF kernels.
"gaussy"produce Gaussian kernels in the x and y directions respectively.
- psffwhmfloat, optional
Full Width Half Maximum of the PSF to use to generate the kernel. Default: 2.5.
- psfsizeint, optional
Size of the kernel to calculate. Returned kernel will have size psfsize x psfsize. psfsize should be odd. Default: 7.
numpy.ndarray(with float dtype) or None, optional
PSF kernel array to use for the fine structure image if
fsmode == 'convolve'. If None and
fsmode == 'convolve', we calculate the psf kernel using
psfmodel. Default: None.
- psfbetafloat, optional
Moffat beta parameter. Only used if
psfmodel=='moffat'. Default: 4.765.
- verbosebool, optional
Print to the screen or not. Default: False.
An object of the same type as ccd is returned. If it is a
CCDData, the mask attribute will also be updated with areas identified with cosmic rays masked. By default, the image is multiplied by the gain. You can control this behavior with the
numpy.ndarrayis provided as ccd, a boolean ndarray with the cosmic rays identified will also be returned.
Implementation of the cosmic ray identification L.A.Cosmic: http://www.astro.yale.edu/dokkum/lacosmic/
van Dokkum, P; 2001, “Cosmic-Ray Rejection by Laplacian Edge Detection”. The Publications of the Astronomical Society of the Pacific, Volume 113, Issue 789, pp. 1420-1427. doi: 10.1086/323894
McCully, C., 2014, “Astro-SCRAPPY”, https://github.com/astropy/astroscrappy
Given an numpy.ndarray object, the syntax for running cosmicrar_lacosmic would be:
>>> newdata, mask = cosmicray_lacosmic(data, sigclip=5)
where the error is an array that is the same shape as data but includes the pixel error. This would return a data array, newdata, with the bad pixels replaced by the local median from a box of 11 pixels; and it would return a mask indicating the bad pixels.
CCDDataobject with an uncertainty frame, the syntax for running cosmicrar_lacosmic would be:
>>> newccd = cosmicray_lacosmic(ccd, sigclip=5)
The newccd object will have bad pixels in its data array replace and the mask of the object will be created if it did not previously exist or be updated with the detected cosmic rays.