pypeit.coadd1d module

Coadding module.

class pypeit.coadd1d.CoAdd1D(spec1dfiles, objids, spectrograph=None, par=None, sensfuncfile=None, setup_id=None, debug=False, show=False, chk_version=True)[source]

Bases: object

coadd()[source]

Dummy method overloaded by sub-classes

classmethod get_instance(spec1dfiles, objids, spectrograph=None, par=None, sensfuncfile=None, setup_id=None, debug=False, show=False, chk_version=True)[source]

Superclass factory method which generates the subclass instance. See CoAdd1D instantiation for argument descriptions.

load()[source]

Load the arrays we need for performing coadds. Dummy method overloaded by children.

run()[source]

Runs the coadding

save(coaddfile, telluric=None, obj_model=None, overwrite=True)[source]

Generate a OneSpec object and write it to disk.

Parameters:
  • coaddfile (str) – File to output coadded spectrum to.

  • telluric (numpy.ndarray, optional) – Telluric model.

  • obj_model (str, optional) – Name of the object model

  • overwrite (bool, optional) – Overwrite existing file?

class pypeit.coadd1d.EchelleCoAdd1D(spec1dfiles, objids, spectrograph=None, par=None, sensfuncfile=None, setup_id=None, debug=False, show=False, chk_version=True)[source]

Bases: CoAdd1D

Child of CoAdd1d for Echelle reductions.

coadd()[source]

Perform coadd for echelle data using ech_combspec

Returns:

  • wave_grid_mid (numpy.ndarray) – Wavelength grid (in Angstrom) evaluated at the bin centers, uniformly-spaced either in lambda or log10-lambda/velocity. See core.wavecal.wvutils.py for more. shape=(ngrid,)

  • wave_coadd (numpy.ndarray) – Wavelength grid for stacked spectrum. As discussed above, this is the weighted average of the wavelengths of each spectrum that contriuted to a bin in the input wave_grid wavelength grid. It thus has ngrid elements, whereas wave_grid has ngrid+1 elements to specify the ngrid total number of bins. Note that wave_giant_stack is NOT simply the wave_grid bin centers, since it computes the weighted average;

  • flux_coadd (numpy.ndarray) – Final stacked spectrum on wave_stack wavelength grid. shape=(ngrid,)

  • ivar_coadd (numpy.ndarray) – Inverse variance spectrum on wave_stack wavelength grid. Erors are propagated according to weighting and masking. shape=(ngrid,)

  • gpm_coadd (numpy.ndarray) – Mask for stacked spectrum on wave_stack wavelength grid. True=Good. shape=(ngrid,)

  • order_stacks_output (numpy.ndarray, None) – Stacked orders. None if not echelle data. shape=(norders, ngrid)

load()[source]

Load the arrays we need for performing echelle coadds.

Returns:

  • waves (list) – List of arrays with the wavelength arrays for each setup. The length of the list equals the number of unique setups and each arrays in the list has shape = (nspec, norders, nexp)

  • fluxes (list) – List of arrays with the flux arrays for each setup. The length of the list equals the number of unique setups and each arrays in the list has shape = (nspec, norders, nexp)

  • ivars (list) – List of arrays with the ivar arrays for each setup. The length of the list equals the number of unique setups and each arrays in the list has shape = (nspec, norders, nexp)

  • gpms (list) – List of arrays with the gpm arrays for each setup. The length of the list equals the number of unique setups and each arrays in the list has shape = (nspec, norders, nexp)

  • weights_sens (list) – List of arrays with the sensfunc weights for each setup. The length of the list equals the number of unique setups and each arrays in the list has shape = (nspec, norders, nexp)

  • headers (list) – List of headers for each setup. The length of the list is the number of unique setups.

load_ech_arrays(spec1dfiles, objids, sensfuncfiles)[source]

Load the arrays we need for performing coadds for a single setup.

Parameters:
  • spec1dfiles (list) – List of spec1d files for this setup.

  • objids (list) – List of objids. This is aligned with spec1dfiles

  • sensfuncfile (list) – List of sensfuncfiles. This is aligned with spec1dfiles and objids

Returns:

waves, fluxes, ivars, gpms, header. Each array has shape = (nspec, norders, nexp)

Return type:

tuple

class pypeit.coadd1d.MultiSlitCoAdd1D(spec1dfiles, objids, spectrograph=None, par=None, sensfuncfile=None, setup_id=None, debug=False, show=False, chk_version=False)[source]

Bases: CoAdd1D

Child of CoAdd1d for Multislit and Longslit reductions.

check_exposures()[source]

Check if there are bad exposures. Exposures with flux masked everywhere are always removed. Exposures that are considered bad based on their S/N compared to the average S/N among all the exposures, are removed only if self.par[‘sigrej_exp’] is set. The attributes self.waves, self.fluxes, self.ivars, self.gpms need to be defined.

Returns:

  • gpm_exp (list of bool) – List of boolean that indicates which exposures have been coadded. The length of the list is nexp.

  • _waves (list of float numpy.ndarray) – Updated list of wavelength arrays.

  • _fluxes (list of float numpy.ndarray) – Updated list of flux arrays.

  • _ivars (list of float numpy.ndarray) – Updated list of inverse variance arrays.

  • _gpms (list of bool numpy.ndarray) – Updated list of good pixel mask variance arrays.

coadd()[source]

Perform coadd for for Multi/Longslit data using multi_combspec

Returns:

see objects returned by multi_combspec().

Return type:

tuple

load()[source]

Load the arrays we need for performing coadds.

Returns:

  • waves (list of float numpy.ndarray) – List of wavelength arrays. The length of the list is nexp. The arrays can have different shapes.

  • fluxes (list of float numpy.ndarray) – List of flux arrays. The arrays can have different shapes, but all are aligned with what is in waves.

  • ivars (list of float numpy.ndarray) – List of inverse variance arrays. The arrays can have different shapes, but all are aligned with what is in waves.

  • gpms (list of bool numpy.ndarray) – List of good pixel mask variance arrays. The arrays can have different shapes, but all are aligned with what is in waves.

  • headers (list of header objects) – List of headers of length nexp

class pypeit.coadd1d.SlicerIFUCoAdd1D(spec1dfiles, objids, spectrograph=None, par=None, sensfuncfile=None, setup_id=None, debug=False, show=False, chk_version=False)[source]

Bases: MultiSlitCoAdd1D

Child of MultiSlitCoAdd1d for SlicerIFU reductions.