extract1d

jwst.extract_1d.extract1d.extract1d(image, profiles_2d, variance_rn, variance_phnoise, variance_flat, weights=None, profile_bg=None, extraction_type='box', bg_smooth_length=0, fit_bkg=False, bkg_fit_type='poly', bkg_order=0)[source]

Extract the spectrum, optionally subtracting background.

Parameters:
imagendarray

2D array, transposed if necessary so that the dispersion direction is the second index.

profiles_2dlist of ndarray

These 2D arrays contain the weights for the extraction. A box extraction will add up the flux multiplied by these weights; an optimal extraction will fit an amplitude to the weight map at each column in the dispersion direction. These arrays should be the same shape as image, with one array for each object to extract. Box extraction only works if exactly one profile is supplied (i.e. this is a one-element list).

variance_rnndarray

2D read noise component of the variance.

variance_phnoisendarray

2D photon noise component of the variance.

variance_flatndarray

2D flat component of the variance.

weightsndarray or None, optional

2D weights for the individual pixels in fitting a profile. If None (default), use uniform weights (ones for all valid pixels).

profile_bgndarray or None, optional

2D array of the same shape as image, with nonzero elements where the background is to be estimated.

extraction_type{“box”, “optimal”}, optional

Type of spectral extraction.

bg_smooth_lengthint, optional

Smoothing length for box smoothing of the background along the dispersion direction. Should be odd, >=1.

fit_bkgbool, optional

Fit a background? Default False

bkg_fit_typestr, optional

Type of fitting to apply to background values in each column (or row, if the dispersion is vertical).

bkg_orderint, optional

Polynomial order for fitting to each column of background. A value of 0 means that a simple average of the background regions, column by column, will be used. This argument must be positive or zero, and it is only used if background regions have been specified and if bkg_fit is poly.

Returns:
fluxesndarray of float64

The extracted spectrum/spectra. Units are currently arbitrary. The first dimension is the same as the length of profiles_2d.

var_rnndarray of float64

The variances of the extracted spectrum/spectra due to read noise. Units are the same as flux^2, shape is the same as flux.

var_phnoisendarray of float64

The variances of the extracted spectrum/spectra due to photon noise. Units are the same as flux^2, shape is the same as flux.

var_flatndarray of float64

The variances of the extracted spectrum/spectra due to flatfield uncertainty. Units are the same as flux^2, shape is the same as flux.

bkgndarray of float64

Background level that would be obtained for each source if performing a 1-D extraction on the 2D background.

var_bkg_rnndarray of float64

As above, for read noise. Nonzero because read noise adds an error term to the derived background level.

var_bkg_phnoisendarray of float64

The variances of the extracted spectrum/spectra due to background photon noise. Units are the same as flux^2, shape is the same as flux. This background contribution is already included in var_phnoise.

var_bkg_flatndarray of float64

As above, for the flatfield.

npixelsndarray of int64

Number of pixels that contribute to the flux measurement for each source

modelndarray of float64

The model of the scene, the same shape as the input image (and hopefully also similar in value).