contam_corr

jwst.wfss_contam.wfss_contam.contam_corr(input_model, waverange, photom, max_cores, orders=None, magnitude_limit=None, max_pixels_per_chunk=50000.0, oversample_factor=2, polyfit_degree=None, n_iterations=1, l2_alpha=0.1, rejection_threshold=0.1)[source]

Correct contamination in WFSS spectral cutouts.

Parameters:
input_modelMultiSlitModel

Input data model containing 2D spectral cutouts. May be modified by processing: make a copy before calling this function, if needed.

waverangeWavelengthrangeModel

Wavelength range reference file model

photomNrcWfssPhotomModel or NisWfssPhotomModel

Photom (flux cal) reference file model

max_coresstr or int

Number of cores to use for multiprocessing. If set to ‘none’ (the default), then no multiprocessing will be done. The other allowable string values are ‘quarter’, ‘half’, and ‘all’, which indicate the fraction of cores to use for multi-proc. The total number of cores includes the SMT cores (Hyper Threading for Intel). If an integer is provided, it will be the exact number of cores used.

orderslist, optional

List of spectral orders to process. If None, all orders defined in the wavelengthrange file will be processed.

magnitude_limitfloat, optional

Isophotal AB magnitude limit for sources to be included in the contamination correction. The magnitude limit is applied per spectral order, where the orders are scaled relative to order 0 based on their photometric response as read from the photom reference file. This means that generally fewer sources will be dispersed in higher orders. If None, no magnitude limit is applied and all sources are included.

max_pixels_per_chunkint, optional

Maximum number of pixels to disperse simultaneously.

oversample_factorint, optional

Wavelength oversampling factor.

polyfit_degreeint, optional

Degree of polynomial fit to spectral shape. If None (the default), do not attempt polynomial fitting and just use the flat-spectrum simulated slit.

n_iterationsint, optional

Number of times to iterate the contamination correction. On each iteration the polynomial fit is re-run using the contamination-corrected spectrum from the previous iteration, yielding a progressively better estimate of each source’s true spectral shape (and therefore a better contamination estimate for its neighbors). Requires polyfit_degree to be set; if polyfit_degree is None this parameter is ignored and a single iteration is performed.

l2_alphafloat, optional

L2 regularization strength for the polynomial spectral fit, passed to fit_slit_by_basis_images.

rejection_thresholdfloat, optional

Threshold for rejecting fits based on the fitted constant term coefficient, passed to fit_slit_by_basis_images.

Returns:
output_modelMultiSlitModel

A copy of the input_model that has been corrected

simul_modelImageModel

Full-frame simulated image of the grism exposure

contam_modelMultiSlitModel

Contamination estimate images for each source slit