PixelReplacement
- class jwst.pixel_replace.pixel_replace.PixelReplacement(input_model, **pars)[source]
Bases:
objectMain class for performing pixel replacement.
This class controls loading the input data model, selecting the method for pixel replacement, and executing each step. This class should provide modularization to allow for multiple options and possible future reference files.
- Parameters:
- input_model
JwstDataModel Datamodel with bad pixels to replace. Updated in-place.
- **parsdict, optional
Optional parameters to modify how pixel replacement will execute.
- input_model
Attributes Summary
Methods Summary
custom_slice(dispaxis, index)Construct slice for ease of use with varying dispersion axis.
fit_profile(arrays)Replace pixels with the profile fit method.
mingrad(arrays)Replace pixels with the minimum gradient replacement method.
profile_mse(scale, median, current)Calculate mean-squared error of fitted profile.
replace()Unpack model and apply pixel replacement algorithm.
Attributes Documentation
- DO_NOT_USE = 1
- FLUX_ESTIMATED = 268435456
- HORIZONTAL = 1
- LOG_SLICE = ['column', 'row']
- NON_SCIENCE = 512
- VERTICAL = 2
Methods Documentation
- custom_slice(dispaxis, index)[source]
Construct slice for ease of use with varying dispersion axis.
- Parameters:
- dispaxisint
Using module-defined:
1 = HORIZONTAL
2 = VERTICAL
- indexint or list
Index or indices of cross-dispersion vectors to slice
- Returns:
- tuple
Slice constructed using numpy
- fit_profile(arrays)[source]
Replace pixels with the profile fit method.
Fit a profile to adjacent columns, scale profile to column with missing pixel(s), and find flux estimate from scaled profile.
Error and variance values for the replaced pixels are similarly estimated, using the scales from the profile fit to the data.
- Parameters:
- arrays
PixelReplaceArrays Pixel arrays and dispersion direction for the 2D spectrum to process. Arrays are modified in place.
- arrays
- Returns:
- arrays
PixelReplaceArrays The input with bad pixels now flagged with FLUX_ESTIMATED and holding a flux value estimated from the spatial profile.
- arrays
- mingrad(arrays)[source]
Replace pixels with the minimum gradient replacement method.
Test the gradient along the spatial and spectral axes using immediately adjacent pixels. Pick whichever dimension has the minimum absolute gradient and replace the missing pixel with the average of the two adjacent pixels along that dimension.
This aims to make the process extremely local; near point sources it should do the replacement along the spectral axis avoiding sampling issues, while near bright extended emission line the replacement should be along the spatial axis. May still be suboptimal near bright emission lines from unresolved point sources.
Does not attempt any replacement if a NaN value is bordered by another NaN value along a given axis.
- Parameters:
- arrays
PixelReplaceArrays Pixel arrays and dispersion direction for the 2D spectrum to process. Arrays are modified in-place.
- arrays
- Returns:
- arrays
PixelReplaceArrays The input with flagged bad pixels now flagged with FLUX_ESTIMATED and holding a flux value estimated from adjacent pixels.
- arrays
- profile_mse(scale, median, current)[source]
Calculate mean-squared error of fitted profile.
- Parameters:
- scalefloat
Initial estimate of scale factor to bring normalized median profile up to current profile
- medianndarray
Median profile constructed from neighboring profile slices
- currentndarray
Current profile with bad pixels to be replaced
- Returns:
- float
Mean-squared error for minimization purposes
- replace()[source]
Unpack model and apply pixel replacement algorithm.
Process the input
JwstDataModel, unpack any model that holds more than one 2D spectrum, then apply selected algorithm to each 2D spectrum in input.