exotic_miri.stage_2

class exotic_miri.stage_2.InspectDQFlagsStep(*args: Any, **kwargs: Any)[source]

Bases: Step

Inspect DQ flags step.

process(input)[source]

Inspect the data quality flags present in your rate-images. This step does not alter any data, it simply computes the number of each type of DQ flag that are present, and optionally display where they are on the detector. It is quite decent, would recommend some visual inspection with this step.

NB. DQ array bit values as per: https://jwst-pipeline.readthedocs.io/en/latest/jwst/references_general/references_general.html?#data-quality-flags.

Parameters:
  • input (jwst.datamodels.CubeModel) – This is an rateints.fits loaded data segment.

  • draw_dq_flags (boolean) – Plot the DQ flags on the detector for each integration.

Returns:

input – The same model, unaltered from input.

Return type:

jwst.datamodels.CubeModel

class exotic_miri.stage_2.CleanOutliersStep(*args: Any, **kwargs: Any)[source]

Bases: Step

Clean outliers step.

process(input)[source]

Clean outliers using deviations from a spatial profile, following Horne 1986, and/or values from the data quality array.

NB. DQ array bit values as per: https://jwst-pipeline.readthedocs.io/en/latest/jwst/references_general/references_general.html?#data-quality-flags.

Parameters:
  • input (jwst.datamodels.CubeModel) – This is a rateints.fits loaded data segment.

  • window_heights (list of integers) – The size of the windows in pixels, in the dispersion direction, to use when fitting polynomials to the spatial profile. The size of the window iterates cyclically through the list until the total height of the detector is reached. Recommended to use smaller window sizes at the shorter wavelengths (larger row indexes) as the throughput * stellar spectra show larger variations here. For example, [150, 100, 50, 50, 20, 20, 20].

  • dq_bits_to_mask (list of integers) – A list of data quality flags to clean. These pixels are replaced by the spatial profile values. See link above for definitions of the DQ bit values. For example, [0, ] cleans pixes marked as 2**0 (do_not_use) in the DQ array.

  • poly_order (integer) – Polynomial order for fitting to the windows of data. Default is 4.

  • outlier_threshold (float) – Number of standard deviations away from the spatial profile for a pixel to be determined as an outlier. Default is 4.0.

  • spatial_profile_left_idx (integer) – Start index of the columns which should be included in the spatial profile. Default is 26.

  • spatial_profile_right_idx (integer) – End index of the columns which should be included in the spatial profile. Default is 47.

  • draw_cleaning_col (boolean) – Plot the cleaning interactively. Useful for understanding the process and getting a feel for the hyperparams.

  • draw_spatial_profiles (boolean) – Plot the spatial profiles after each integration is cleaned.

  • no_clean (boolean) – Override, and just remove any nans. This is for quick tests.

Returns:

output, spatial profile cube, outlier counts cube – A CubeModel with outliers cleaned, a 3D array of the fitted spatial profiles, and a count of the number of outliers cleaned within 0-4 pixels of the spectral trace (column index 36).

Return type:

tuple(CubeModel, np.ndarray, np.ndarray)

class exotic_miri.stage_2.BackgroundSubtractStep(*args: Any, **kwargs: Any)[source]

Bases: Step

Background subtraction step.

process(input)[source]

Subtract the background from the rate-images.

Parameters:
  • input (jwst.datamodels.CubeModel) – This is a rateints.fits loaded data segment.

  • method (string) – The background subtraction method: constant, the background is estimated as a median over the entire background region; row_wise, the background is estimated as a median per row; col_wise, the background is estimated within a row as a linear function of column number. Default is row_wise.

  • bkg_col_left_start (integer) – The column index of the start of the background region on the left side of the spectral trace. Default is 8.

  • bkg_col_left_end (integer) – The column index of the end of the background region on the left side of the spectral trace. Default is 17.

  • bkg_col_right_start (integer) – The column index of the start of the background region on the right side of the spectral trace. Default is 56.

  • bkg_col_right_end (integer) – The column index of the end of the background region on the right side of the spectral trace. Default is 72.

  • smoothing_length (integer) – If not None, the number of rows to median smooth the estimated background values over. Default is no smoothing.

Returns:

output – A CubeModel with the background subtracted from each integration.

Return type:

jwst.datamodels.CubeModel

class exotic_miri.stage_2.Extract1DBoxStep(*args: Any, **kwargs: Any)[source]

Bases: Step

Box extraction step.

process(input, wavelength_map)[source]

Extract time-series 1D stellar spectra using a box aperture.

Parameters:
  • input (jwst.datamodels.CubeModel) – This is a rateints.fits loaded data segment.

  • wavelength_map (np.ndarray) – The wavelength map. This is output from exotic_miri.reference.GetWavelengthMap.

  • trace_position (string) – The method for locating the spectral trace per detector row. constant: uses the value specified by aperture_center. gaussian_fits: fit a Gaussian to each row to find the centre.

  • aperture_center (integer) – The defined centre of the spectral trace in terms of column index. Default is 36.

  • aperture_left_width (integer) – The half-width of the box aperture in pixels away from the aperture_center to the left. Default is 4, and so this aperture would include the aperture_center, say column 36, and 4 columns to the left of this.

  • aperture_right_width (integer) – The half-width of the box aperture in pixels away from the aperture_center to the right. Default is 4, and so this aperture would include the aperture_center, say column 36, and 4 columns to the right of this.

  • draw_psf_fits (boolean) – Plot Gaussina fits to the PSF.

  • draw_aperture (boolean) – Plot the defined aperture.

  • draw_spectra (boolean) – Plot the extracted 1D spectra.

Returns:

wavelengths, spectra, spectra_uncertainties, trace_widths – Arrays of wavelengths (n_rows,), spectra (n_ints, n_rows), spectra_uncertainties (n_ints, n_rows), trace_widths (n_ints,).

Return type:

tuple(np.ndarray, np.ndarray, np.ndarray, np.ndarray)

class exotic_miri.stage_2.Extract1DOptimalStep(*args: Any, **kwargs: Any)[source]

Bases: Step

Optimal extraction step.

process(input, wavelength_map, P, readnoise)[source]

Extract time-series 1D stellar spectra using optimal extraction as detailed in Horne 1986. The spatial profile must be pre-computed and input.

Parameters:
  • input (jwst.datamodels.CubeModel) – This is a rateints.fits loaded data segment.

  • wavelength_map (np.ndarray) – The wavelength map. This is output from exotic_miri.reference.GetWavelengthMap.

  • P (np.ndarray) – A cube of spatial profiles, one for each integration, of shape (n_ints, n_rows, n_cols). The should be normalised within each row (cross-disperion direction). These data can be made using exotic_miri.stage_2.CleanOutliersStep.

  • readnoise (np.ndarray) – A cube of readnoise values, one for each integration, of shape (n_ints, n_rows, n_cols).

  • median_spatial_profile (boolean) – If True, median the spatial profiles through time. Default is True.

  • trace_position (string) – The method for locating the spectral trace per detector row. constant: uses the value specified by aperture_center. gaussian_fits: fit a Gaussian to each row to find the centre.

  • aperture_center (integer) – The defined centre of the spectral trace in terms of column index. Default is 36.

  • aperture_left_width (integer) – The half-width of the box aperture in pixels away from the aperture_center. Default is 4, and so this aperture would include the aperture_center, say column 36, and 4 columns to the left of this.

  • aperture_right_width (integer) – The half-width of the box aperture in pixels away from the aperture_center. Default is 4, and so this aperture would include the aperture_center, say column 36, and 4 columns to the right of this.

  • draw_psf_fits (boolean) – Plot Gaussina fits to the PSF.

  • draw_aperture (boolean) – Plot the defined aperture, within which optimal extraction is applied.

  • draw_spectra (boolean) – Plot the extracted 1D spectra.

Returns:

wavelengths, spectra, spectra_uncertainties, trace_widths – Arrays of wavelengths (n_rows,), spectra (n_ints, n_rows), spectra_uncertainties (n_ints, n_rows), trace_widths (n_ints,).

Return type:

tuple(np.ndarray, np.ndarray, np.ndarray, np.ndarray)

class exotic_miri.stage_2.AlignSpectraStep(*args: Any, **kwargs: Any)[source]

Bases: Step

Align spectra step.

process(input, spec, spec_unc)[source]

Align the 1D stellar spectra. This step measures, by cross-correlation, the x- and y-positions of the spectral trace through time. These positions are returned and the spectra can optionally be realigned by the y-positions.

Parameters:
  • input (jwst.datamodels.CubeModel) – This is a rateints.fits loaded data segment.

  • align_spectra (boolean) – If True the spectra are realigned by the measured y-positions. Default is True.

  • draw_cross_correlation_fits (boolean) – Plot the cross-correlation function and the fit to this determining the trace position.

  • draw_trace_positions (boolean) – Plot the measured trace positions.

Returns:

spectra, spectra_uncertainties, x_shifts, y_shifts – The time-series spectra and their uncertainties each with shape (n_ints, n_wavelengths) and the measured trace shifts in x and y each with shape (n_ints,).

Return type:

tuple(np.ndarray, np.ndarray, np.ndarray, np.ndarray)