Extract1dStep

class jwst.extract_1d.Extract1dStep(name=None, parent=None, config_file=None, _validate_kwds=True, **kws)[source]

Bases: JwstStep

Extract a 1D spectrum from 2D data.

subtract_background

A flag which indicates whether the background should be subtracted. If None, the value in the extract_1d reference file will be used. If not None, this parameter overrides the value in the extract_1d reference file.

Type:

bool or None

apply_apcorr

Switch to select whether to apply an APERTURE correction during the Extract1dStep. Default is True.

Type:

bool

extraction_type

If ‘box’, a standard extraction is performed, summing over an aperture box. If ‘optimal’, a PSF-based extraction is performed. If None, optimal extraction is attempted whenever use_source_posn is True. Currently, optimal extraction is only available for MIRI LRS Fixed Slit data.

Type:

str or None

use_source_posn

If True, the source and background extraction regions specified in the extract1d reference file will be shifted to account for the computed position of the source in the data. If None (the default), this parameter is set to True for point sources in NIRSpec and MIRI LRS fixed slit modes.

Type:

bool or None

position_offset

Number of pixels to offset the source and background extraction regions in the cross-dispersion direction. This is intended to allow a manual tweak to the aperture defined via reference file; the default value is 0.0.

Type:

float

model_nod_pair

If True, and the extraction type is ‘optimal’, then a negative trace from nod subtraction is modeled alongside the positive source during extraction. Even if set to True, this will be attempted only if the input data has been background subtracted and the dither pattern indicates that only 2 nods were used.

Type:

bool

optimize_psf_location

If True, and the extraction type is ‘optimal’, then the placement of the PSF model for the source location (and negative nod, if present) will be iteratively optimized. This parameter is recommended if negative nods are modeled.

Type:

bool

smoothing_length

If not None, the background regions (if any) will be smoothed with a boxcar function of this width along the dispersion direction. This should be an odd integer.

Type:

int or None

bkg_fit

A string indicating the type of fitting to be applied to background values in each column (or row, if the dispersion is vertical). Allowed values are poly, mean, and median. Default is None.

Type:

str

bkg_order

If not None, a polynomial with order bkg_order will be fit to each column (or row, if the dispersion direction is vertical) of the background region or regions. For a given column (row), one polynomial will be fit to all background regions. The polynomial will be evaluated at each pixel of the source extraction region(s) along the column (row), and the fitted value will be subtracted from the data value at that pixel. If both smoothing_length and bkg_order are not None, the boxcar smoothing will be done first.

Type:

int or None

log_increment

if log_increment is greater than 0 (the default is 50) and the input data are multi-integration (which can be CubeModel or SlitModel), a message will be written to the log with log level INFO every log_increment integrations. This is intended to provide progress information when invoking the step interactively.

Type:

int

save_profile

If True, the spatial profile containing the extraction aperture is saved to disk. Ignored for IFU and NIRISS SOSS extractions.

Type:

bool

save_scene_model

If True, a model of the 2D flux as defined by the extraction aperture is saved to disk. Ignored for IFU and NIRISS SOSS extractions.

Type:

bool

save_residual_image

If True, the residual image (from the input minus the scene model) is saved to disk. Ignored for IFU and NIRISS SOSS extractions.

Type:

bool

center_xy

A list of 2 pixel coordinate values at which to place the center of the IFU extraction aperture, overriding any centering done by the step. Two values, in x,y order, are used for extraction from IFU cubes. Default is None.

Type:

int or None

ifu_autocen

Switch to turn on auto-centering for point source spectral extraction in IFU mode. Default is False.

Type:

bool

bkg_sigma_clip

Background sigma clipping value to use on background to remove outliers and maximize the quality of the 1d spectrum. Used for IFU mode only.

Type:

float

ifu_rfcorr

Switch to select whether or not to apply a 1d residual fringe correction for MIRI MRS IFU spectra. Default is True.

Type:

bool

ifu_set_srctype

For MIRI MRS IFU data override srctype and set it to either POINT or EXTENDED.

Type:

str

ifu_rscale

For MRS IFU data a value for changing the extraction radius. The value provided is the number of PSF FWHMs to use for the extraction radius. Values accepted are between 0.5 to 3.0. The default extraction size is set to 2 * FWHM. Values below 2 will result in a smaller radius, a value of 2 results in no change to the radius and a value above 2 results in a larger extraction radius.

Type:

float

ifu_covar_scale

Scaling factor by which to multiply the ERR values in extracted spectra to account for covariance between adjacent spaxels in the IFU data cube.

Type:

float

soss_atoca

Switch to toggle extraction of SOSS data with the ATOCA algorithm. WARNING: ATOCA results not fully validated, and require the photom step be turned off. Default is False, meaning SOSS data use box extraction.

Type:

bool, default=False

soss_threshold

Threshold value above which a pixel will be included when modeling the SOSS trace in ATOCA. Default is 0.01.

Type:

float

soss_n_os

Oversampling factor of the underlying wavelength grid when modeling the SOSS trace in ATOCA. Default is 2.

Type:

int

soss_wave_grid_in

Filename or SossWaveGrid containing the wavelength grid used by ATOCA to model each pixel valid pixel of the detector. If not given, the grid is determined based on an estimate of the flux (soss_estimate), the relative tolerance (soss_rtol) required on each pixel model and the maximum grid size (soss_max_grid_size).

Type:

str or SossWaveGrid or None

soss_wave_grid_out

Filename to hold the wavelength grid calculated by ATOCA.

Type:

str or None

soss_estimate

Filename or SpecModel of the estimate of the target flux. The estimate must be a SpecModel with wavelength and flux values.

Type:

str or SpecModel or None

soss_rtol

The relative tolerance needed on a pixel model. It is used to determine the sampling of the soss_wave_grid when not directly given.

Type:

float

soss_max_grid_size

Maximum grid size allowed. It is used when soss_wave_grid is not provided to make sure the computation time or the memory used stays reasonable.

Type:

int

soss_tikfac

The regularization factor used for extraction in ATOCA. If left to default value of None, ATOCA will find an optimized value.

Type:

float

soss_width

Aperture width used to extract the SOSS spectrum from the decontaminated trace in ATOCA. Default is 40.

Type:

float

soss_bad_pix

Method used to handle bad pixels, accepts either “model” or “masking”. Default method is “model”.

Type:

str

soss_modelname

Filename for optional model output of ATOCA traces and pixel weights.

Type:

str

Create a Step instance.

Parameters:
  • name (str, optional) – 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.

  • parent (Step instance, optional) – 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_file (str or pathlib.Path, optional) – The path to the config file that this step was initialized with. Use to determine relative path names of other config files.

  • **kws (dict) – Additional parameters to set. These will be set as member variables on the new Step instance.

Attributes Summary

class_alias

reference_file_types

spec

Methods Summary

process(input_data)

Execute the step.

Attributes Documentation

class_alias = 'extract_1d'
reference_file_types: ClassVar = ['extract1d', 'apcorr', 'pastasoss', 'specprofile', 'speckernel', 'psf']
spec
subtract_background = boolean(default=None)  # subtract background?
apply_apcorr = boolean(default=True)  # apply aperture corrections?

extraction_type = option("box", "optimal", None, default="box") # Perform box or optimal extraction
use_source_posn = boolean(default=None)  # use source coords to center extractions?
position_offset = float(default=0)  # number of pixels to shift source trace in the cross-dispersion direction
model_nod_pair = boolean(default=True)  # For optimal extraction, model a negative nod if possible
optimize_psf_location = boolean(default=True)  # For optimal extraction, optimize source location
smoothing_length = integer(default=None)  # background smoothing size
bkg_fit = option("poly", "mean", "median", None, default=None)  # background fitting type
bkg_order = integer(default=None, min=0)  # order of background polynomial fit
log_increment = integer(default=50)  # increment for multi-integration log messages
save_profile = boolean(default=False)  # save spatial profile to disk
save_scene_model = boolean(default=False)  # save flux model to disk
save_residual_image = boolean(default=False)  # save residual image to disk

center_xy = float_list(min=2, max=2, default=None)  # IFU extraction x/y center
ifu_autocen = boolean(default=False) # Auto source centering for IFU point source data.
bkg_sigma_clip = float(default=3.0)  # background sigma clipping threshold for IFU
ifu_rfcorr = boolean(default=True) # Apply 1d residual fringe correction (MIRI MRS only)
ifu_set_srctype = option("POINT", "EXTENDED", None, default=None) # user-supplied source type
ifu_rscale = float(default=None, min=0.5, max=3) # Radius in terms of PSF FWHM to scale extraction radii
ifu_covar_scale = float(default=1.0) # Scaling factor to apply to errors to account for IFU cube covariance

soss_atoca = boolean(default=True)  # use ATOCA algorithm
soss_threshold = float(default=1e-2)  # TODO: threshold could be removed from inputs. Its use is too specific now.
soss_n_os = integer(default=2)  # minimum oversampling factor of the underlying wavelength grid used when modeling trace.
soss_wave_grid_in = input_file(default = None)  # Input wavelength grid used to model the detector
soss_wave_grid_out = string(default = None)  # Output wavelength grid solution filename
soss_estimate = input_file(default = None)  # Estimate used to generate the wavelength grid
soss_rtol = float(default=1.0e-4)  # Relative tolerance needed on a pixel model
soss_max_grid_size = integer(default=20000)  # Maximum grid size, if wave_grid not specified
soss_tikfac = float(default=None)  # regularization factor for NIRISS SOSS extraction
soss_width = float(default=40.)  # aperture width used to extract the 1D spectrum from the de-contaminated trace.
soss_bad_pix = option("model", "masking", default="masking")  # method used to handle bad pixels
soss_modelname = output_file(default = None)  # Filename for optional model output of traces and pixel weights

Methods Documentation

process(input_data)[source]

Execute the step.

Parameters:

input_data (DataModel) – The input model.

Returns:

This will be input_model if the step was skipped; otherwise, it will be a model containing 1-D extracted spectra.

Return type:

DataModel