lacosmic¶
- lacosmic.lacosmic(data, contrast, cr_threshold, neighbor_threshold, error=None, mask=None, background=None, effective_gain=None, readnoise=None, maxiter=4, border_mode='mirror')[source]¶
Remove cosmic rays from an astronomical image using the L.A.Cosmic algorithm.
The L.A.Cosmic algorithm is based on Laplacian edge detection and is described in van Dokkum (2001; PASP 113, 1420).
- Parameters:
- dataarray_like
The 2D array of the image.
- contrastfloat
Contrast threshold between the Laplacian image and the fine-structure image. If your image is critically sampled, use a value around 2. If your image is undersampled (e.g., HST data), a value of 4 or 5 (or more) is more appropriate. If your image is oversampled, use a value between 1 and 2. For details, please see PASP 113, 1420 (2001), which calls this parameter \(f_{\mbox{lim}}\). In particular, Figure 4 shows the approximate relationship between the
contrast
parameter and the full-width half-maximum (in pixels) of stars in your image.- cr_thresholdfloat
The Laplacian signal-to-noise ratio threshold for cosmic-ray detection.
- neighbor_thresholdfloat
The Laplacian signal-to-noise ratio threshold for detection of cosmic rays in pixels neighboring the initially-identified cosmic rays.
- errorarray_like, optional
The 1-sigma errors of the input
data
. Iferror
is not input, theneffective_gain
andreadnoise
will be used to construct an approximate model of theerror
. Iferror
is input, it will override theeffective_gain
andreadnoise
parameters.error
must have the same shape asdata
.- maskarray_like (bool), optional
A boolean mask, with the same shape as
data
, where aTrue
value indicates the corresponding element ofdata
is masked. Masked pixels are ignored when identifying cosmic rays. It is highly recommended that saturated stars be included inmask
.- backgroundfloat or array_like, optional
The background level previously subtracted from the input
data
.background
may either be a scalar value or a 2D image with the same shape as the inputdata
. If the inputdata
has not been background subtracted, then setbackground=None
(default).- effective_gainfloat, array-like, optional
Ratio of counts (e.g., electrons or photons) to the units of
data
. For example, if your inputdata
are in units of ADU, theneffective_gain
should represent electrons/ADU. If your inputdata
are in units of electrons/s theneffective_gain
should be the exposure time (or an exposure time map).effective_gain
andreadnoise
must be specified iferror
is not input.- readnoisefloat, optional
The read noise (in electrons) in the input
data
.effective_gain
andreadnoise
must be specified iferror
is not input.- maxiterfloat, optional
The maximum number of iterations. The default is 4. The routine will automatically exit if no additional cosmic rays are identified in an iteration. If the routine is still identifying cosmic rays after four iterations, then you are likely digging into sources (e.g., saturated stars) and/or the noise. In that case, try inputing a
mask
or increasing the value ofcr_threshold
.- border_mode{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional
The mode in which the array borders are handled during convolution and median filtering. For ‘constant’, the fill value is 0. The default is ‘mirror’, which matches the original L.A.Cosmic algorithm.
- Returns: