Additional API

msaexp.pipeline Module

Manual extractions of NIRSpec MSA spectra

Functions

query_program([prog, download, detectors, ...])

Query and download MSA exposures for a given program from MAST

exposure_groups([files, split_groups, verbose])

Group files by MSAMETFL, grating, filter, detector

Classes

NirspecPipeline([mode, files, verbose, ...])

Container class for NIRSpec data, generally in groups split by grating/filter/detector

msaexp.pipeline_extended Module

Extend CRDS reference files for fixed-slit observations

Functions

step_reference_files(step, input_model)

Get reference filenames for a jwst pipeline step

extend_wavelengthrange([ref_file, ranges])

Extend limits of wavelengthrange reference file

extend_fs_fflat(fflat_filename[, ...])

Extend fflat reference for EXP_TYPE = NRS_FIXEDSLIT

extend_quad_fflat(fflat_filename[, ...])

Extend fflat reference for EXP_TYPE = NRS_MSASPEC

extend_sflat(sflat_filename[, full_range, ...])

Extend NIRSpec sflat reference file

extend_dflat(dflat_filename[, full_range, ...])

Extend NIRSpec sflat reference file

extend_photom(phot_filename[, ranges])

Extend wavelength ranges in photom reference file

run_pipeline(file[, slit_index, all_slits, ...])

Pipeline for extending reference files

msaexp.utils Package

Functions

array_to_bin_edges(array)

Compute bin edges of an input array where the bin widths are the array steps

available_lookup_psf_files()

Return a list of the available LookupTablePSF files in msaexp/data

build_regular_wavelength_wcs(slits[, ...])

Create a spatial/spectral WCS covering footprint of the input

build_slit_centered_wcs(slit, waves[, ...])

Build a 2D WCS centered on the target in a slit

cache_badpix_arrays()

Load bad pixel arrays into global dictionaries

calculate_psf_fwhm()

Use WebbPSF to calculate the FWHM as a function of wavelength assuming 0.2" fixed slit

combine_2d_with_rejection(drizzled_slits[, ...])

Combine single drizzled arrays with outlier detection

drizzle_2d_pipeline(slits[, output_root, ...])

Drizzle list of background-subtracted slitlets

drizzle_slits_2d(slits[, build_data, ...])

Run jwst.resample.resample_spec.ResampleSpecData on a list of List of jwst.datamodels.slit.SlitModel objects.

drizzled_hdu_figure(hdul[, tick_steps, ...])

Figure showing drizzled HDU

exposure_ramp_saturation([file, ...])

Get maximum of an uncal ramp for flagging saturation

extra_slit_dq_flags(slit[, dq_arr])

Set extra DQ flags, including a big stuck open shutter on NRS1.

extract_all()

demo [not used]

fixed_rectified_slit_header(slit_wcs, ...)

Merge 2D WCS header from a slit WCS to a rectified WCS, e.g., from build_slit_centered_wcs.

fixed_slit_flat_field(slit[, slit_data, ...])

Fixed slit cross-dispersion profile flat field

get_default_resolution_curve([grating, ...])

Parameters

get_miri_lrs_disp([wave, range, nstep, ...])

Generate a placeholder resolution curve for MIRI LRS fit from the reference file jwst_miri_specwcs_0010.fits

get_muse_lsf([wave, range, step])

MUSE resolution curve from Guerou et al. (2017).

get_nircam_wfss_disp([wave, range, nstep, rstep])

Generate placeholder resolution curve for NIRCam WFSS

get_nirspec_psf_fwhm(wave)

Get PSF FWHM in pix from tabulated array derived from webbpsf

get_normalization_correction(wavelengths, ...)

Normalization correction derived from empty sky slits, analagous to a correction to the SFLAT calibration

get_prism_bar_correction(scaled_yshutter[, ...])

Generate the msaexp prism bar-shadow correction

get_prism_wave_bar_correction(...[, ...])

Generate the msaexp prism bar-shadow correction including wavelength dependence

get_slit_coordinates(slit[, trace_with_ypos])

Get wavelength and cross-dispersion coordinate arrays for a 2D slitlet

get_slit_data(slit[, wrap])

Parse slit coordinates and attributes

get_slit_sign(slit)

sign convention for slit pixels

get_standard_wavelength_grid(grating[, ...])

Get a fixed wavelength grid for a given grating

glob_sorted(text[, func, reverse])

Return result of a file listing from glob sorted by file creation date

line_flam_to_fnu([wave, flam_unit])

Convert from flambda cgs to microJansky

load_sflat_data(flat_file, **kwargs)

Load MSAEXP MSA quadrant/detector S-flat reference data

longslit_header_from_wcs(wcs)

Generate a FITS-compliant long-slit header from a NIRSpec spectral WCS

make_nirspec_gaussian_profile(waves[, ...])

Make a pixel-integrated Gaussian profile

module_data_path()

Get the path to the data directory inside the module

msa_slit_sflat([slit, qxy, flat_file, ...])

Field dependent S-Flat for MSA slitlets derived from empty sky spectra

objfun_prf(params, waves, sci2d, wht2d, ...)

Objective function for fitting the 2D profile

pixfrac_steps(oversample, pixfrac)

Grid for oversampling cross dispersion axis

rename_source(source_name)

This function takes a source name as input and returns the adjusted name according to the following rules:

resize_subarray_to_full(file[, overwrite])

Resize a subarray exposure to the FULL 2048 x 2048 dimensions

set_bad_pixel_flag()

Set the global BAD_PIXEL_FLAG variable

set_plot_style([style_file])

Load plot defaults with plt.style.use(style_file).

shutter_xcen_ycen_from_id(shutter_id)

Get MSA shutter xcen and ycen from the shutter_id

slit_data_from_extended_reference(slit)

Check if slit produced by msaexp.pipeline_extended

slit_extended_flux_calibration(slit[, ...])

Get flux calibration for extended-wavelength extractions

slit_hot_pixels(slit[, max_allowed_flagged, ...])

Flag hot pixels with grizli.jwst_utils.flag_nirspec_hot_pixels

slit_normalization_correction(slit, **kwargs)

Run get_normalization_correction for a SlitModel object

slit_shutter_scale(slit)

Pixel scale of the slit_frame coordinate

slit_trace_center(slit[, with_source_xpos, ...])

Get detector coordinates along the center of a slit

square_axes(fig, ax[, aspect])

Shrink axis to force a specified axis ratio

tight_colorbar(color_result, fig, ax[, sx, ...])

Insert a colorbar at the corners/edges of a plot axis

trapz(y[, x, dx, axis])

Integrate along the given axis using the composite trapezoidal rule.

update_slit_dq_mask(slit[, mask_padded, ...])

Update slit dq array and masking for padded slits and barshadow

update_slit_metadata(slit)

Try to update missing slit metadata.

Classes

ClippedColormap([cmap, max_lightness, norm, ...])

Color map with Lightness clipped to a maximum value

LineList([data])

Tools for working with a table of lines

LookupTablePSF([psf_file])

Fast lookup table PSF derived from point sources in the fixed slit.

MolecularHydrogen(**kwargs)

Tools for working with molecular hydrogen lines using the helpful relations from Aditya Togi and J.

msaexp.drizzle Module

Tools for drizzle-combining MSA spectra

Functions

center_wcs(slit, waves[, center_on_source, ...])

Derive a 2D spectral WCS centered on the expected source position along the slit

drizzle_slitlets(id[, wildcard, files, ...])

Implementing more direct drizzling of multiple 2D slitlets

extract_from_hdul(hdul[, prf_center, ...])

Run 1D extraction on arrays from a combined dataset

get_xlimits_from_lines(hdul[, sn_thresh, ...])

Find emission lines in 2D spectrum

make_optimal_extraction(waves, sci2d, wht2d)

Optimal extraction from 2D arrays

metadata_tuple(slit)

Tuple of (msa_metadata_file, msa_metadata_id)

show_drizzled_product(hdul[, figsize, ...])

Make a figure showing drizzled product

show_drizzled_slits(slits, sci, ivar, hdul)

Make a figure showing drizzled slitlets

msaexp.slit_combine Module

Functions

split_visit_groups(files[, join, gratings, ...])

Compute groupings of SlitModel files based on exposure, visit, detector, slit_id

pseudo_drizzle(xpix, ypix, data, var, wht, ...)

2D histogram analogous to drizzle.

extract_spectra([target, root, ...])

Spectral combination workflow splitting by grating and multiple observations in a particular grating

Classes

SlitGroup(files, name[, position_key, ...])

Container for a list of 2D extracted SlitModel files

msaexp.spectrum Module

Fits, etc. to extracted spectra

Functions

fit_redshift([file, z0, zstep, ...])

Fit spectrum for the redshift

fit_redshift_grid([file, zgrid, vel_width, ...])

Fit redshifts on a grid

plot_spectrum([inp, z, vel_width, ...])

Fit templates to a spectrum and make a diagnostic figure

read_spectrum(inp[, spectrum_extension, ...])

Read a spectrum and apply flux and/or uncertainty scaling

calc_uncertainty_scale([file, data, order, ...])

Compute a polynomial scaling of the spectrum uncertainties.

resample_bagpipes_model(model_galaxy[, ...])

Parameters

multiplot_spectra([file, ny, z, log_steps, ...])

Query and plot overlapping spectra

integrate_spectrum_filter(spec, filt[, z, ...])

Integrate spectrum data through a filter bandpass

do_integrate_filters(file[, z, RES, ...])

Integrate a spectrum through a list of filter bandpasses

Classes

SpectrumSampler(spec_input[, ...])

Helper functions for sampling templates onto the wavelength grid of an observed spectrum

msaexp.msa Module

Helper scripts for dealing with MSA metadata files (MSAMETFL)

Functions

regions_from_metafile(metafile, **kwargs)

Wrapper around msaexp.msa.MSAMetafile.regions_from_metafile

regions_from_fits(file, **kwargs)

Wrapper around msaexp.msa.MSAMetafile.regions_from_metafile

slit_best_source_alias(slit[, ...])

Get the "best" source id from the MSA metadata file associated with a particular slit extraction.

plot_msa_shutters(col, row, quadrant[, c, ax])

Make a plot of a list of MSA shutters

set_msa_axis_ticks([ax, which])

Draw axis ticks for a plot of the MSA shutters

read_apt_shutter_csv(file)

Read an APT MSA shutter CSV file into a table

get_shutter_wavelength_limits(col, row, quadrant)

Compute wavelength limits for specific slitlets by MSA row, col, quadrant

Classes

MSAMetafile(filename)

Helper for parsing MSAMETFL metadata files

msaexp.resample Module

Functions

resample_template(spec_wobs, spec_R_fwhm, ...)

Resample a high resolution template/model on the wavelength grid of a spectrum with (potentially) wavelength dependent dispersion

sample_gaussian_line(spec_wobs, spec_R_fwhm, ...)

Sample a Gaussian emission line on the spectrum wavelength grid accounting for pixel integration

pixel_integrated_gaussian(x, mu, sigma[, ...])

Low level function for a pixel-integrated gaussian

msaexp.resample_numba Module

Functions

simpson(y, x)

Simpson's rule integration by Mason Stoeker See: https://masonstoecker.com/2021/04/03/Simpson-and-Numba.html

trapz(y, x)

Accelerated trapezoid rule integration

trapz_dx(x)

Return trapezoid rule coefficients, useful for numerical integration using a dot product

resample_template_numba(spec_wobs, ...[, ...])

Resample a high resolution template/model on the wavelength grid of a spectrum with (potentially) wavelength dependent dispersion

sample_gaussian_line_numba(spec_wobs, ...[, ...])

Sample a Gaussian emission line on the spectrum wavelength grid accounting for pixel integration

pixel_integrated_gaussian_numba(x, mu, sigma)

Low level function for a pixel-integrated gaussian

compute_igm(z, wobs[, scale_tau])

Calculate Inoue+ (2014) IGM transmission, reworked from Inoue14

calzetti2000_alambda(wobs, z)

Calzetti (2000) attenuation law adapted from bagpipes (A.

calzetti2000_attenuation(wobs, z, Av)

Calzetti (2000) attenuation law adapted from bagpipes (A.

drude_profile(w0, center, width)

Drude profile

salim_alambda(wobs, z, delta, B)

Salim (2018) attenuation law adapted from bagpipes (A.

smc_alambda(wobs, z)

SMC extinction law from Gordon (2003) attenuation law adapted from bagpipes (A.

smc_attenuation(wobs, z, Av)

SMC extinction law from Gordon (2003) attenuation law adapted from bagpipes (A.

msaexp.cloud Package