hispecdrp.primitives.coadd.coadd_spectra_primitive

Functions

_coadd_spectra(input_frames[, ...])

Coadd a (n_frames, n_pix) stack of 1D spectra using a specified method.

_coadd_spectra_numba(spec_2d, spec_out, dq_2d)

_get_spec_data_attrs(input_model, fiber)

_make_spec_batch(input_models, attrs, order)

Build (n_frames, n_pix) arrays for one order from a list of spectral models.

coadd_spectra(input, do_fibers, do_orders[, ...])

sigma_clip_spectra(data_2d, mask_2d[, ...])

Classes

CoaddSpectraPrimitive([dataset, config, ...])

Coadd multiple spectral-like models (e.g. Level 2 spectra) of the same kind to increase signal-to-noise.

class CoaddSpectraPrimitive(dataset=None, config=None, context=None, log_config=None, parent=None, **kwargs)[source]

Bases: BasePrimitive

Coadd multiple spectral-like models (e.g. Level 2 spectra) of the same kind to increase signal-to-noise.

An ancestor FITS extension is created to include the list of filenames that were combined.

This primitive combines input data products using a weighted average (if mean_calc = ‘wmean’), where the weights are given by the inverse variances (1 / model.err^2). The output error and variance arrays are computed using the corresponding weighted standard error. Data quality (DQ) flags from all inputs are propagated to the output using a bitwise OR.

Parameters:
  • input (list[str or DataModel]) – Input files or data models to coadd. All inputs are combined into a single output model (each fiber/order trace is coadded independently).

  • suffix (str or None, optional) – Suffix to append to the output filename. Default is 'coadded'.

  • mean_calc (str, optional) – Method for calculating the output data values. Currently, only 'wmean' (weighted mean) is implemented.

  • err_calc (str, optional) – Method for calculating the output error and variance. Currently, only 'wse' (weighted standard error) is implemented.

  • do_fibers (list of int, optional) – Fibers to coadd. If None, all fibers on the input model are used.

  • do_orders (list of int, optional) – Orders to coadd. If None, all orders on the input model are used.

Returns:

output (DataModel) – Coadded data model with propagated errors and data quality flags.

coadd_spectra(input, do_fibers, do_orders, do_sigma_clip=False, sigma_thresh_low=None, sigma_thresh_high=None, min_keep=3, mean_calc='wmean', err_calc='wse', primitive=None)[source]