clean_pixels

ndmapper.lib.gemini.clean_pixels(*args, **kwargs)[source] [edit on github]

Replace each pixel whose corresponding flags value matches one or more non-zero bits of the bitmask with a (locally- or globally-) interpolated estimate of its true, uncontaminated value.

This currently works on 2D images.

Parameters:

inputs : DataFileList or DataFile

Input images, containing extracted, row-stacked fibre spectra with linearized wavelength co-ordinates.

out_names : str-like or list of str-like, optional

Names of output images, each containing a 1D spectrum. If None (default), the names of the DataFile instances returned will be constructed from those of the corresponding input files, prefixed with ‘p’.

method : {‘local’, ‘global’}

Method to use for interpolating good data to generate replacement values; either ‘local’ interpolation along the narrowest dimension of each contiguous bad region using IRAF’s proto.fixpix (with linterp=INDEF and cinterp=INDEF) or a ‘global’ fit to each row or column using fit1d. The default is ‘global’.

grow : float, optional

The radius in pixels (default 1.5) by which to expand the rejection of regions matching the bitmask in the flags array when generating replacement values. This does not cause additional pixels to be replaced, it merely avoids basing replacement values on the immediately-surrounding pixels, where those are also contaminated at a lower level.

bitmask : int, optional

The bit-wise OR of flags bits used to trigger pixel replacement. The default of 65535 causes all pixels with DQ > 0 in the input to be replaced in the output, while bitmask=0 would copy the input unchanged, with intermediate values used to reject some defects but not others (eg. 9 flags cosmic rays (8) and detector defects (1) in Gemini IRAF).

axis : {0, 1}

The image axis (Python convention) along which to fit 1D Chebyshev models when using method ‘global’ (default 1, ie. rows).

order : int or None, optional

The order of the 1D Chebyshev fits when using method ‘global’. With the default of None, a value is selected automatically by ‘gemfix’.

low_reject, high_reject : int, optional

Lower and upper thresholds, in standard deviations, for rejection of nominally-good pixels (in addition to those excluded by the flags array) when performing ‘global’ fits, to help avoid any residual contamination when generating replacement values. These default to 3.0 and 2.3, respectively (avoiding the statistically high values associated with common defects such as cosmic rays more aggressively than low ones).

iterations : int, optional

The number of pixel rejection and re-fitting iterations to perform to obtain a final fit when using the ‘global’ method (default 5).

See “help gemfix” in IRAF for more detailed information.

Returns:

outimages : DataFileList

The 1D spectra produced by gfapsum.