create_extraction

jwst.extract_1d.extract.create_extraction(input_model, slit, output_model, extract_ref_dict, slitname, sp_order, exp_type, apcorr_ref_model=None, log_increment=50, save_profile=False, save_scene_model=False, save_residual_image=False, **kwargs)[source]

Extract spectra from an input model and append to an output model.

Input data, specified in the slit or input_model, should contain data with consistent wavelengths, target positions, and spectral image cutouts, suitable for extraction with a shared aperture. Extraction parameters are determined collectively, then multiple integrations, if present, are each extracted separately.

The output model must be a MultiSpecModel or TSOMultiSpecModel, created before calling this function, and passed as output_model. It is updated in place, with new spectral tables appended as they are created.

The process is:

  1. Retrieve extraction parameters from extract_ref_dict and set defaults for any missing values as needed.

  2. Define an extraction aperture from the input parameters, as well as the nominal RA, Dec, and 1D wavelength arrays for the output spectrum.

  3. Set up an aperture correction to apply to each spectrum, if apcorr_ref_model is not None.

  4. Loop over integrations to extract all spectra.

For each integration, the extraction process is:

  1. Extract summed flux and variance values from the aperture.

  2. Compute an average value (from flux / npixels), to be stored as the surface brightness.

  3. Convert the summed flux to flux density (Jy).

  4. Compute an error spectrum from the square root of the sum of the variance components.

  5. Set a DQ array, with DO_NOT_USE flags set where the flux is NaN.

  6. Create a spectral table to contain all extracted values and store it in a SpecModel.

  7. Apply the aperture correction to the spectral table, if available.

  8. Append the new SpecModel to the output_model.

Parameters:
input_modelDataModel

Top-level datamodel containing metadata for the input data. If slit is not specified, input_model must also contain the spectral image(s) to extract, in the data attribute.

slitSlitModel or None

One slit from an input MultiSlitModel or similar. If not None, slit must contain the spectral image(s) to extract, in the data attribute, along with appropriate WCS metadata.

output_modelMultiSpecModel, TSOMultiSpecModel

The output model to append spectral tables to.

extract_ref_dictdict or None

Extraction parameters read in from the extract_1d reference file, or None, if there was no reference file.

slitnamestr

Slit name for the input data.

sp_orderint

Spectral order for the input data.

exp_typestr

Exposure type for the input data.

apcorr_ref_modelDataModel or None, optional

The aperture correction reference datamodel, containing the APCORR reference file data.

log_incrementint, optional

If greater than 0 and the input data are multi-integration, a message will be written to the log every log_increment integrations.

save_profilebool, optional

If True, the spatial profile created for the aperture will be returned as an ImageModel. If False, the return value is None.

save_scene_modelbool, optional

If True, the flux model created during extraction will be returned as an ImageModel or CubeModel. If False, the return value is None.

save_residual_imagebool, optional

If True, the residual image (from input minus scene model) will be returned as an ImageModel or CubeModel. If False, the return value is None.

**kwargs

Additional options to pass to get_extract_parameters.

Returns:
profile_modelImageModel or None

If save_profile is True, the return value is an ImageModel containing the spatial profile with aperture weights, used in extracting all integrations.

scene_modelImageModel, CubeModel, or None

If save_scene_model is True, the return value is an ImageModel or CubeModel matching the input data, containing the flux model generated during extraction.

residualImageModel, CubeModel, or None

If save_residual_image is True, the return value is an ImageModel or CubeModel matching the input data, containing the residual image.