reduction.crrej.medfilt_bpm

reduction.crrej.medfilt_bpm(
    ccd,
    cadd=1e-10,
    std_model='std',
    gain=1.0,
    rdnoise=0.0,
    snoise=0.0,
    size=5,
    sigclip_kw=None,
    std_section=None,
    footprint=None,
    mode='reflect',
    cval=0.0,
    origin=0,
    med_sub_clip=None,
    med_rat_clip=None,
    std_rat_clip=None,
    dtype='float32',
    update_header=True,
    verbose=False,
    logical='and',
    full=False,
)

Find bad pixels from median filtering technique (non standard..?)

Parameters

ccd : ~astropy.nddata.CCDData

The CCD to find the bad pixels.

cadd : float, optional. = 1e-10

A very small const to be added to the input array to avoid resulting value of 0.0 in the median filtered image which raises zero-division in median ratio (image/|median_filtered|).

std_model : {\"std\", \"ccd\"}, ~numpy.ndarray, numeric, optional. = 'std'

The model used to calculate the std (standard deviation) map.

  • "std": Simple standard deviation is calculated.
  • "ccd": Using CCD noise model (``sqrt{(1 + snoise)*med_filt/gain
    • (rdnoise/gain)**2}``)
  • ndarray: A pre-calculated std map to be used as the std map.

For 'std', the arguments std_section and sigclip_kw are used, while if 'ccd', arguments gain, rdnoise, snoise will be used.

size : optional. = 5

The parameters to obtain the median-filtered map. See ~scipy.ndimage.median_filter.

footprint : optional. = 5

The parameters to obtain the median-filtered map. See ~scipy.ndimage.median_filter.

mode : optional. = 5

The parameters to obtain the median-filtered map. See ~scipy.ndimage.median_filter.

cval : optional. = 5

The parameters to obtain the median-filtered map. See ~scipy.ndimage.median_filter.

origin : optional. = 5

The parameters to obtain the median-filtered map. See ~scipy.ndimage.median_filter.

sigclip_kw : dict, optional. = None

The scalar sigma-clipping parameters used when estimating the sky standard deviation at std_section. Supported keys are sigma, sigma_lower, sigma_upper, maxiters, cenfunc, stdfunc, and std_ddof. This is ignored if std_model='ccd'. Default is dict(sigma=3.0, maxiters=5, std_ddof=1).

std_section : str, optional. = None

The region in FITS standard (1-indexing, end-inclusive, xyz order) to estimate the sky standard deviation to obtain the std_ratio. If None (default), the full region of the given array is used, which is many times not desirable due to the celestial objects in the FOV and computational cost. This is ignored if std_model='ccd'.

gain : float, optional. = 1.0

The gain (electrons/ADU), readout noise (electrons), and sensitivity noise (fractional error from flat fielding) of the frame. These are ignored if std_model="std".

rdnoise : float, optional. = 1.0

The gain (electrons/ADU), readout noise (electrons), and sensitivity noise (fractional error from flat fielding) of the frame. These are ignored if std_model="std".

snoise : float, optional. = 1.0

The gain (electrons/ADU), readout noise (electrons), and sensitivity noise (fractional error from flat fielding) of the frame. These are ignored if std_model="std".

med_sub_clip : list of two float or None, optional. = None

The thresholds to find bad pixel by med_sub = ccd.data - median_filter(ccd.data). The clipping will be turned off if it is None (default). If a list, must be in the order of [lower, upper] and at most two of these can be None.

med_rat_clip : list of two float or None, optional. = None

The thresholds to find bad pixel by med_ratio = ccd.data/np.abs(median_filter(ccd.data)). The clipping will be turned off if it is None (default). If a list, must be in the order of [lower, upper] and at most two of these can be None.

std_rat_clip : list of two float or None, optional. = None

The thresholds to find bad pixel by std_ratio = (ccd - median_filter(ccd))/std. The clipping will be turned off if it is None (default). If a list, must be in the order of [lower, upper] and at most two of these can be None.

logical : ('and', '&', 'or', '|') = 'and'

The logic to propagate masks determined by the _clip’s. The mask is propagated such as posmask = med_sub > med_sub_clip[1] &/| med_ratio > med_rat_clip[1] &/| std_ratio > std_rat_clip[1]. If a list, it must contain two str of these, in the order of [logical_negmask, logical_posmask].

Returns

ccd : ~astropy.nddata.CCDData

The badpixel removed result.

: The followings are returned as dict only if full=True.
: posmask, negmask : ndarray of bool

The masked pixels by positive/negative criteria.

sky_std : float

The (sigma-clipped) sky standard deviation. Returned only if full=True.

Notes

med_sub_clip is usually unnecessary, but can be useful for detecting hot pixels in dark frames. The method generates median-subtracted, median-ratio, and stddev-ratio maps, combines the positive and negative masks with the requested logic, and replaces masked pixels with the median filtered frame.