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:
  • image (ndarray) – 2D array, transposed if necessary so that the dispersion direction is the second index.

  • profiles_2d (list 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_rn (ndarray) – 2D read noise component of the variance.

  • variance_phnoise (ndarray) – 2D photon noise component of the variance.

  • variance_flat (ndarray) – 2D flat component of the variance.

  • weights (ndarray 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_bg (ndarray 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_length (int, optional) – Smoothing length for box smoothing of the background along the dispersion direction. Should be odd, >=1.

  • fit_bkg (bool, optional) – Fit a background? Default False

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

  • bkg_order (int, 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:

  • fluxes (ndarray of float64) – The extracted spectrum/spectra. Units are currently arbitrary. The first dimension is the same as the length of profiles_2d.

  • var_rn (ndarray 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_phnoise (ndarray 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_flat (ndarray 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.

  • bkg (ndarray of float64) – Background level that would be obtained for each source if performing a 1-D extraction on the 2D background.

  • var_bkg_rn (ndarray of float64) – As above, for read noise. Nonzero because read noise adds an error term to the derived background level.

  • var_bkg_phnoise (ndarray 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_flat (ndarray of float64) – As above, for the flatfield.

  • npixels (ndarray of int64) – Number of pixels that contribute to the flux measurement for each source

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