remove_cosmics#
- lacosmic.remove_cosmics(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
contrastparameter 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. Iferroris not input, theneffective_gainandreadnoisewill be used to construct an approximate model of theerror. Iferroris input, it will override theeffective_gainandreadnoiseparameters.errormust have the same shape asdata.- maskarray_like (bool), optional
A boolean mask, with the same shape as
data, where aTruevalue indicates the corresponding element ofdatais 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.backgroundmay either be a scalar value or a 2D image with the same shape as the inputdata. If the inputdatahas 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 inputdataare in units of ADU, theneffective_gainshould represent electrons/ADU. If your inputdataare in units of electrons/s theneffective_gainshould be the exposure time (or an exposure time map).effective_gainandreadnoisemust be specified iferroris not input.- readnoisefloat, optional
The read noise (in electrons) in the input
data.effective_gainandreadnoisemust be specified iferroris 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
maskor increasing the value ofcr_threshold.- border_modestr, optional
The mode in which the array borders are handled during convolution and median filtering. The options are ‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, or ‘wrap’. For ‘constant’, the fill value is 0. The default is ‘mirror’, which matches the original L.A.Cosmic algorithm.
- Returns: