Integration
- class jwst.extract_1d.soss_extract.soss_extract.Integration(scidata, scierr, scimask, refmask, order_models, box_weights, do_bkgsub=True, extract_order3=True, save_intermediate=False, order2_separation_cutoff=(0.77, 0.95))[source]
Bases:
objectClass to handle extraction of a single integration.
- Parameters:
- scidatandarray
2D science data array.
- scierrndarray
2D science error array.
- scimaskndarray
2D boolean mask array for the science data.
Truevalues are masked.- refmaskndarray
2D boolean mask array for the reference pixels.
Truevalues are masked.- order_modelslist of
DetectorModelOrder Models of the detector and trace properties, one per spectral order.
- box_weightsdict
A dictionary of the weights for each order.
- do_bkgsubbool, optional
Whether to perform background subtraction. Default is
True.- extract_order3bool, optional
Whether to extract order 3. Default is
True.- save_intermediatebool, optional
Whether to save intermediate products for debugging. Default is
False.- order2_separation_cutofftuple(float, float), optional
Wavelengths short of which to consider Order 2 to be well-separated from order 1. Two values are defined. The first is the cutoff longwave of which should be included in the combined extraction; the second is the cutoff shortwave of which should be included in the extraction of just that order. Some overlap is helpful to avoid numerical issues.
Methods Summary
decontaminate_image(tracemodels)Perform decontamination of the image based on the trace models.
estim_flux_first_order([threshold])Roughly estimate the underlying flux of the target spectrum.
extract_image(decontaminated_data[, ...])Perform the box-extraction on the image using the trace model to correct for contamination.
make_decontamination_grid(estimate[, rtol, ...])Create the grid to use for the simultaneous extraction of order 1 and 2.
model_image(wave_grid[, estimate, ...])Extract the uncontaminated spectra of using the ATOCA algorithm.
Methods Documentation
- decontaminate_image(tracemodels)[source]
Perform decontamination of the image based on the trace models.
- Parameters:
- tracemodelsdict
Dictionary of the modeled detector images for each order.
- Returns:
- decontaminated_datadict
Dictionary of the decontaminated data for each order.
- estim_flux_first_order(threshold=0.0001)[source]
Roughly estimate the underlying flux of the target spectrum.
This is done by simply masking out order 2 and retrieving the flux from order 1.
- Parameters:
- thresholdfloat, optional
The pixels with an
aperture[order 2] > thresholdare considered contaminated and will be masked.
- Returns:
- func
A spline estimator that provides the underlying flux as a function of wavelength
- extract_image(decontaminated_data, bad_pix='model', tracemodels=None, verbose=False)[source]
Perform the box-extraction on the image using the trace model to correct for contamination.
- Parameters:
- decontaminated_datandarray
A single background subtracted NIRISS SOSS detector image.
- bad_pixstr
How to handle the bad pixels. Options are ‘masking’ and ‘model’. ‘masking’ will simply mask the bad pixels, such that the number of pixels in each column in the box extraction will not be constant, while the ‘model’ option uses
tracemodelsto replace the bad pixels.- tracemodelsdict
Dictionary of the modeled detector images for each order.
- verbosebool
Print bad pixel imputation messages to INFO-level logging?
- Returns:
- fluxes, fluxerrs, npixelsdict
Each output is a dictionary, with each extracted order as a key.
- make_decontamination_grid(estimate, rtol=0.0001, max_grid_size=20000, n_os=2)[source]
Create the grid to use for the simultaneous extraction of order 1 and 2.
The grid is made by:
requiring that it satisfies the oversampling
n_os,trying to reach the specified tolerance for the spectral range shared between order 1 and 2, and
trying to reach the specified tolerance in the rest of spectral range.
The
max_grid_sizeoverrules steps 2 and 3, so the precision may not be reached if the grid size needed is too large.- Parameters:
- estimate
UnivariateSpline Estimate of the target flux as a function of wavelength in microns.
- rtolfloat, optional
The relative tolerance needed on a pixel model.
- max_grid_sizeint, optional
Maximum grid size allowed.
- n_osint, optional
The oversampling factor of the wavelength grid used when solving for the uncontaminated flux.
- estimate
- Returns:
- wave_gridndarray
The 1D grid of the pixels boundaries at the native sampling.
- model_image(wave_grid, estimate=None, tikfacs_in=None, threshold=0.01)[source]
Extract the uncontaminated spectra of using the ATOCA algorithm.
The model consists of three separate extractions:
A simultaneous extraction of orders 1 and 2.
An extraction of the blue (uncontaminated) part of order 2.
An extraction of order 3, if requested.
For each of these extractions, the Tikhonov factor can either be provided using the
tikfacs_indictionary, or else determined via a grid search.- Parameters:
- wave_gridndarray or None
The wavelength grid to use for the simultaneous extraction of orders 1 and 2.
- estimatefunc, optional
An estimate of the target flux as a function of wavelength in microns. This is used to generate the wavelength grid if
wave_gridis None, and to estimate the Tikhonov factor if not provided intikfacs_in. Ifwave_gridis given and the Tikhonov factor for order 1 is provided intikfacs_in, this is not needed. If either is not provided, this must be given.- tikfacs_indict, optional
A dictionary with keys “Order 1”, “Order 2”, and “Order 3” and values giving the Tikhonov factor to use for each order. If None (default), the Tikhonov factor that minimizes the chi-squared for each order will be determined via a grid search.
- thresholdfloat, optional
The threshold (between 0 and 1) for determining which pixels to include in the extraction. Pixels with a normalized flux contribution from the spectral trace above this threshold will be included. Default is 1e-2.
- Returns:
- tracemodelsdict
A dictionary with keys “Order 1”, “Order 2”, and “Order 3” (if extracted) and values giving the modeled detector image for each order.
- spec_listlist of
SpecModel A list of the extracted spectra for each order. If the Tikhonov factor was determined via a grid search, this will include the intermediate spectra for each factor tested, with the best-fitting spectrum last in the list.
- tikfacs_outdict
A dictionary with keys “Order 1”, “Order 2”, and “Order 3” (if extracted) and values giving the Tikhonov factor used for each order.