Stage 3

Created on Thurs Jul 21 17:33 2022

@author: MCR

Custom JWST DMS pipeline steps for Stage 3 (1D spectral extraction).

class exotedrf.stage3.Extract1DStep(input_data, extract_method, st_teff=None, st_logg=None, st_met=None, planet_letter='b', output_dir='./')

Wrapper around default calwebb_spec2 1D Spectral Extraction step, with custom modifications.

run(soss_width=40, specprofile=None, centroids=None, save_results=True, force_redo=False, do_plot=False, show_plot=False, use_pastasoss=False, soss_estimate=None)

Method to run the step.

class exotedrf.stage3.SpecProfileStep(datafiles, output_dir='./')

Wrapper around custom SpecProfile Reference Construction step.

run(force_redo=False, empirical=True)

Method to run the step.

exotedrf.stage3.box_extract_soss(datafiles, centroids, soss_width, do_plot=False, show_plot=False, save_results=True, output_dir='./')

Perform a simple box aperture extraction on SOSS orders 1 and 2.

Parameters:
  • datafiles (array-like[str], array-like[jwst.RampModel]) – Input datamodels or paths to datamodels for each segment.

  • centroids (dict) – Dictionary of centroid positions for all SOSS orders.

  • soss_width (int, str) – Width of extraction box. Or ‘optimize’.

  • do_plot (bool) – If True, do the step diagnostic plot.

  • show_plot (bool) – If True, show the step diagnostic plot instead of/in addition to saving it to file.

  • output_dir (str) – Directory to which to output results.

  • save_results (bool) – If True, save results to file.

Returns:

  • wave_o1 (array_like[float]) – 2D wavelength solution for order 1.

  • flux_o1 (array_like[float]) – 2D extracted flux for order 1.

  • ferr_o1 (array_like[float]) – 2D flux errors for order 1.

  • wave_o2 (array_like[float]) – 2D wavelength solution for order 2.

  • flux_o2 (array_like[float]) – 2D extracted flux for order 2.

  • ferr_o2 (array_like[float]) – 2D flux errors for order 2.

  • soss_width (int) – Optimized aperture width.

exotedrf.stage3.do_box_extraction(cube, err, ypos, width, extract_start=0, extract_end=None, progress=True)

Do intrapixel aperture extraction.

Parameters:
  • cube (array-like(float)) – Data cube.

  • err (array-like(float)) – Error cube.

  • ypos (array-like(float)) – Detector Y-positions to extract.

  • width (int) – Full-width of the extraction aperture to use.

  • extract_start (int) – Detector X-position at which to start extraction.

  • extract_end (int, None) – Detector X-position at which to end extraction.

  • progress (bool) – if True, show extraction progress bar.

Returns:

  • f (np.array(float)) – Extracted flux values.

  • ferr (np.array(float)) – Extracted error values.

exotedrf.stage3.do_ccf(wave, flux, err, mod_flux, nsteps=1000)

Perform a cross-correlation analysis between an extracted and model stellar spectrum to determine the appropriate wavelength shift between the two.

Parameters:
  • wave (array-like[float]) – Wavelength axis.

  • flux (array-like[float]) – Extracted spectrum.

  • err (array-like[float]) – Errors on extracted spectrum.

  • mod_flux (array-like[float]) – Model spectrum.

  • nsteps (int) – Number of wavelength steps to test.

Returns:

shift – Wavelength shift between the model and extracted spectrum in microns.

Return type:

float

exotedrf.stage3.format_extracted_spectra(datafiles, times, extract_params, target_name, st_teff=None, st_logg=None, st_met=None, throughput=None, pwcpos=None, output_dir='./', save_results=True, use_pastasoss=False)

Unpack the outputs of the 1D extraction and format them into lightcurves at the native detector resolution.

Parameters:
  • datafiles (array-like[str], array-like[MultiSpecModel], tuple) – Input extract1d data files.

  • times (array-like[float]) – Time stamps corresponding to each integration.

  • output_dir (str) – Directory to which to save outputs.

  • save_results (bool) – If True, save outputs to file.

  • extract_params (dict) – Dictonary of parameters used for the 1D extraction.

  • target_name (str) – Name of the target.

  • st_teff (float, None) – Stellar effective temperature.

  • st_logg (float, None) – Stellar log surface gravity.

  • st_met (float, None) – Stellar metallicity as [Fe/H].

  • throughput (str) – Path to JWST spectrace reference file.

  • pwcpos (float) – Filter wheel position. Only necessary is use_pastasoss is True.

  • use_pastasoss (bool) – If True, use pastasoss package to predict wavelength solution based on pupil wheel position. Note that this will only allow the extraction of order 2 from 0.6 - 0.85µm.

Returns:

spectra – 1D stellar spectra at the native detector resolution.

Return type:

dict

exotedrf.stage3.get_soss_estimate(atoca_spectra, output_dir)

Convert the AtocaSpectra output of ATOCA into the format expected for a soss_estimate.

Parameters:
  • atoca_spectra (str, MultiSpecModel) – AtocaSpectra datamodel, or path to the datamodel.

  • output_dir (str) – Directory to which to save results.

Returns:

estimate_filename – Path to soss_estimate file.

Return type:

str

exotedrf.stage3.run_stage3(results, save_results=True, root_dir='./', force_redo=False, extract_method='box', specprofile=None, centroids=None, soss_width=40, st_teff=None, st_logg=None, st_met=None, planet_letter='b', output_tag='', do_plot=False, show_plot=False, **kwargs)

Run the exoTEDRF Stage 3 pipeline: 1D spectral extraction, using a combination of the official STScI DMS and custom steps.

Parameters:
  • results (array-like[str], array-like[CubeModel]) – exoTEDRF Stage 2 outputs for each segment.

  • save_results (bool) – If True, save the results of each step to file.

  • root_dir (str) – Directory from which all relative paths are defined.

  • force_redo (bool) – If True, redo steps even if outputs files are already present.

  • extract_method (str) – Either ‘box’ or ‘atoca’. Runs the applicable 1D extraction routine.

  • specprofile (str, None) – Specprofile reference file; only neceessary for ATOCA extractions.

  • centroids (str, None) – Path to file containing trace positions for each order.

  • soss_width (int) – Width around the trace centroids, in pixels, for the 1D extraction.

  • st_teff (float, None) – Stellar effective temperature.

  • st_logg (float, None) – Stellar log surface gravity.

  • st_met (float, None) – Stellar metallicity as [Fe/H].

  • planet_letter (str) – Letter designation for the planet.

  • output_tag (str) – Name tag to append to pipeline outputs directory.

  • do_plot (bool) – If True, make step diagnostic plot.

  • show_plot (bool) – Only necessary if do_plot is True. Show the diagnostic plots in addition to/instead of saving to file.

Returns:

specra – 1D stellar spectra for each wavelength bin at the native detector resolution.

Return type:

dict

exotedrf.stage3.specprofilestep(datafiles, empirical=True, output_dir='./')

Wrapper around the APPLESOSS module to construct a specprofile reference file tailored to the particular TSO being analyzed.

Parameters:
  • datafiles (array-like[str], array-like[jwst.RampModel]) – Input datamodels or paths to datamodels for each segment.

  • empirical (bool) – If True, construct profiles using only the data. If False, fall back on WebbPSF for the trace wings. Note: The current WebbPSF wings are known to not accurately match observations. This mode is therefore not advised.

  • output_dir (str) – Directory to which to save outputs.

Returns:

filename – Name of the output file.

Return type:

str