cosmicray_lacosmic

ccdproc.cosmicray_lacosmic(ccd, error_image=None, thresh=5, fthresh=5, gthresh=1.5, b_factor=2, mbox=5, min_limit=0.01, gbox=0, rbox=0, f_conv=None)[source]

Identify cosmic rays through the lacosmic technique. The lacosmic 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) [R1].

Parameters:

ccd: `~ccdproc.CCDData` or `numpy.ndarray`

Data to have cosmic ray cleaned

error_image : numpy.ndarray

Error level in the image. It should have the same shape as data as data. This is the same as the noise array in lacosmic.cl

thresh : float

Threshold for detecting cosmic rays. This is the same as sigmaclip in lacosmic.cl

fthresh : float

Threshold for differentiating compact sources from cosmic rays. This is the same as objlim in lacosmic.cl

gthresh : float

Threshold for checking for surrounding cosmic rays from source. This is the same as sigclip*sigfrac from lacosmic.cl

b_factor : int

Factor for block replication

mbox : int

Median box for detecting cosmic rays

min_limit: float

Minimum value for all pixels so as to avoid division by zero errors

gbox : int

Box size to grow cosmic rays. If zero, no growing will be done.

rbox : int

Median box for calculating replacement values. If zero, no pixels will be replaced.

f_conv: `numpy.ndarray`, optional

Convolution kernal for detecting edges. The default kernel is np.array([[0, -1, 0], [-1, 4, -1], [0, -1, 0]]).

{log}

Returns:

nccd : CCDData or ndarray

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.

nccd : ndarray

If an ndarray is provided as ccd, a boolean ndarray with the cosmic rays identified will also be returned.

Notes

Implementation of the cosmic ray identification L.A.Cosmic: http://www.astro.yale.edu/dokkum/lacosmic/

References

[R1](1, 2) 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

Examples

  1. Given an numpy.ndarray object, the syntax for running cosmicrar_lacosmic would be:

    >>> newdata, mask = cosmicray_lacosmic(data, error_image=error_image,
                                           thresh=5, mbox=11, rbox=11, 
                                           gbox=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.

  2. Given an CCDData object with an uncertainty frame, the syntax for running cosmicrar_lacosmic would be:

    >>> newccd = cosmicray_lacosmic(ccd, thresh=5, mbox=11, rbox=11, gbox=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.