AdaptiveTraceModelStep

class jwst.adaptive_trace_model.adaptive_trace_model_step.AdaptiveTraceModelStep(name=None, parent=None, config_file=None, _validate_kwds=True, **kws)[source]

Bases: JwstStep

Fit an adaptive trace model to a spectral image.

Create a Step instance.

Parameters:
namestr

The name of the Step instance. Used in logging messages and in cache filenames. If not provided, one will be generated based on the class name.

parentStep

The parent step of this step. Used to determine a fully-qualified name for this step, and to determine the mode in which to run this step.

config_filestr or pathlib.Path

The path to the config file that this step was initialized with. Use to determine relative path names of other config files.

_validate_kwdsbool

Validate given kws against specs/config.

**kwsdict

Additional parameters to set. These will be set as member variables on the new Step instance.

Attributes Summary

class_alias

spec

Methods Summary

process(input_data)

Fit an adaptive trace model to a spectral image.

Attributes Documentation

class_alias = 'adaptive_trace_model'
spec
fit_threshold = float(default=10.0) # Limiting sigma for fitting splines
oversample = float(default=1.0) # Use the trace model to oversample the data by this factor
slope_limit = float(default=0.1) # Slope limit for using splines in oversample
psf_optimal = boolean(default=False) # Model the target as a simple point source; ignore slope_limit and fit_threshold.
save_intermediate_results = boolean(default=False)  # Save the full spline model and residuals.
skip = boolean(default=True) # By default, skip the step.
output_use_model = boolean(default=True) # Use input filenames in the output models

Methods Documentation

process(input_data)[source]

Fit an adaptive trace model to a spectral image.

For each spectral region in the input (i.e. a slice or a slit), the algorithm fits a univariate basis spline to the spatial data within a window of each dispersion element. A spectral region may be ignored if its signal-to-noise ratio is too low. This decision is controlled by the fit_threshold parameter: lower values will create spline models for more slices.

After fitting, a further check is performed, using the slope_limit parameter to identify bright, compact source regions for which the spline models are likely to be valid. The set of spline models is then evaluated at each pixel within a compact source region to create a model of the spectral trace.

If no oversample factor is specified, the only change to the datamodel is to attach the resulting spectral trace image, in the trace_model attribute.

If an oversample factor is specified, the input flux, error, and variance images are replaced with interpolated data scaled to a new pixel grid. The DQ and wavelength images are also oversampled and the trace model image is attached, but any additional images (e.g. pathloss corrections) are not propagated.

To perform this oversampling, the trace model is used in combination with a linear interpolation at each dispersion element. Which model is used at each pixel depends on some heuristic decisions derived from the data: bright, compact source regions use the spline model; faint, diffuse regions use the linear interpolation. The slope_limit parameter can be modified to impact the decision on whether sources are bright and compact enough to use the spline models. Lower values will use the spline model for fainter sources.

Parameters:
input_datastr or IFUImageModel or ModelContainer

The input datamodel, container, or filename containing spectral data. If the input is a container, each contained model is separately processed.

Returns:
output_modelIFUImageModel or ModelContainer

The input model, updated with the fit trace model.