mangadap.proc.emissionlinemoments module

A class hierarchy that measures moments of the observed emission lines.

License:
Copyright (c) 2015, SDSS-IV/MaNGA Pipeline Group
Licensed under BSD 3-clause license - see LICENSE.rst
Class usage examples:
Add examples!
Revision history:
25 Apr 2016: Implementation begun by K. Westfall (KBW)
20 May 2016: (KBW) Added loggers and quiet keyword arguments to EmissionLineMoments, removed verbose
28 Jul 2016: (KBW) Fixed error in initialization of guess redshift when stellar continuum is provided.
09 Jan 2017: (KBW) Generalized so that it no longer reads in StellarContinuumModel object.
23 Feb 2017: (KBW) Use DAPFitsUtil read and write functions.
27 Feb 2017: (KBW) Use DefaultConfig for ini files.
31 May 2017: (KBW) Revert to using mangadap.proc.stellarcontinuummodel.StellarContinuumModel on input
15 Feb 2018: (KBW) Add parameter that will set whether or not the moments should be remeasured after the emission-line modeling. Allow to pass an emission-line model for setting up the continuum and the velocities to measure.
class mangadap.proc.emissionlinemoments.EmissionLineMoments(database_key, binned_spectra, stellar_continuum=None, emission_line_model=None, redshift=None, database_list=None, artifact_list=None, bandpass_list=None, dapsrc=None, dapver=None, analysis_path=None, directory_path=None, output_file=None, hardcopy=True, clobber=False, checksum=False, loggers=None, quiet=False)[source]

Bases: object

Class that holds the emission-line moment measurements.

Parameters:
  • loggers (list) – (Optional) List of logging.Logger objects to log progress; ignored if quiet=True. Logging is done using mangadap.util.log.log_output(). Default is no logging.
  • quiet (bool) – (Optional) Suppress all terminal and logging output. Default is False.
loggers

List of logging.Logger objects to log progress; ignored if quiet=True. Logging is done using mangadap.util.log.log_output().

Type:list
quiet

Suppress all terminal and logging output.

Type:bool
_assign_image_arrays()[source]

Set image_arrays, which contains the list of extensions in hdu that are on-sky image data.

_assign_redshifts(redshift, measure_on_unbinned_spaxels, good_snr, default_redshift=None)[source]

Set the redshift to use for each spectrum for the emission-line moments.

In terms of precedence, directly provided redshifts override those in any available EmissionLineModel.

If self.emission_line_model and redshift are None, the default redshift is used (or 0.0 if this is also None).

To get the emission_line stellar kinematics, the function calls mangadap.proc.emissionlinemodel.EmissionLineModel.matched_kinematics(). The method must have a fit_vel_name define for this use!

In this function, the provided redshift must be a single value or None; therefore, the means of any vectors should be provided instead of the full vector.

Parameters:
  • redshift (float, numpy.ndarray) – Redshifts (\(z\)) to use for each spectrum. If None, the default
  • measure_on_unbinned_spaxels (bool) – Flag that method expects to measure moments on unbinned spaxels.
  • good_snr (numpy.ndarray) – Boolean array setting which spectra have sufficient S/N for the measurements.
  • default_redshift (float) – (Optional) Only used if there are stellar kinematics available. Provides the default redshift to use for spectra without stellar measurements; see :arg:`redshift` in mangadap.proc.stellarcontinuummodel.StellarContinuumModel.matched_kinematics(). If None (default), the median of the unmasked stellar velocities will be used.
_compile_database()[source]

Compile the database with the specifications of each index.

_define_databases(database_key, database_list=None, artifact_list=None, bandpass_list=None, dapsrc=None)[source]

Select the database of bandpass filters.

_flag_good_spectra(measure_on_unbinned_spaxels)[source]
_get_missing_bins(unique_bins=None)[source]
_initialize_primary_header(hdr=None, measurements_binid=None)[source]

Initialize the header of hdu.

Returns:Edited header object.
Return type:astropy.io.fits.Header
_moments_database_dtype(name_len)[source]

Construct the record array data type for the output fits extension.

_set_paths(directory_path, dapver, analysis_path, output_file)[source]

Set the directory_path and output_file. If not provided, the defaults are set using, respectively, mangadap.config.defaults.default_dap_method_path() and mangadap.config.defaults.default_dap_file_name().

..warning:

File name is different if an emission-line model is
provided!
Parameters:
  • directory_path (str) – The exact path to the DAP emission-line moments file. See directory_path.
  • dapver (str) – DAP version.
  • analysis_path (str) – The path to the top-level directory containing the DAP output files for a given DRP and DAP version.
  • output_file (str) – The name of the file with emission-line moment measurements. See measure().
channel_names()[source]
static continuum_subtracted_moments(wave, spec, mainbands, restwave, bcen, bcont, rcen, rcont, spec_n=None, err=None, sres=None)[source]

Calculate the continuum-subtracted moments

err and sres are single vectors that are the same for all spec!

Returns:cntm cntb flux fluxerr mom1 mom1err mom2 mom2err sinst incomplete empty divbyzero undefined_mom2
file_name()[source]

Return the name of the output file.

file_path()[source]

Return the full path to the output file.

measure(binned_spectra, stellar_continuum=None, emission_line_model=None, redshift=None, dapsrc=None, dapver=None, analysis_path=None, directory_path=None, output_file=None, hardcopy=True, clobber=False, loggers=None, quiet=False)[source]

Measure the emission-line moments using the binned spectra.

If neither stellar-continuum nor emission-line models are provided:
  • Moments are measure on the binned spectra
  • No continuum subtraction is performed

If a stellar-continuum model is provided without an emission-line model:

  • Moments are measured on the binned spectra
  • The best-fitting stellar continuum is subtracted

If an emission-line model is provided without a stellar-continuum model:

  • Moments are measured on the relevant (binned or unbinned) spectra
  • If the emission-line model includes data regarding the stellar-continuum fit (template spectra and template weights), the continuum is subtracted before the measurements are made; otherwise, no continuum is subtracted

If both stellar-continuum and emission-line models are provided, and if the stellar-continuum and emission-line fits are performed on the same spectra:

  • Moments are measured on the relevant (binned or unbinned) spectra
  • If the emission-line model includes data regarding the stellar-continuum fit (template spectra and template weights), the continuum is subtracted before the measurements are made; otherwise, the stellar continuum is used.

If both stellar-continuum and emission-line models are provided, and if the stellar-continuum and emission-line fits are performed on different spectra:

  • The behavior is exactly as if the stellar-continuum model was not provided.
static measure_moments(momdb, wave, flux, ivar=None, mask=None, sres=None, continuum=None, redshift=None, bitmask=None)[source]

Measure the emission-line moments.

If not input as masked arrays, flux is converted to one.

static output_dtype(nmom, bitmask=None)[source]

Construct the record array data type for the output fits extension.

Returned columns are:

Column Description
BINID Bin ID of the fitted spectrum
BINID_INDEX Index of the bin ID of the fitted spectrum
REDSHIFT Redshift used for setting the passbands
MASK Bit mask value for the measurements
BCEN Blueband center for moments
BCONT Blueband pseudocontinuum for moments
BCONTERR Error in the above
RCEN Redband center for moments
RCONT Redband pseudocontinuum for moments
RCONTERR Error in the above
CNTSLOPE Continuum slope used for the moments
FLUX Zeroth moment
FLUXERR Zeroth moment error
MOM1 First velocity moment
MOM1ERR First velocity moment error
MOM2 Second velocity moment
MOM2ERR Second velocity moment error
SINST Instrumental dispersion at mom1
BMED Median flux in the blue band used for EW
RMED Median flux in the red band used for EW
EWCONT Continuum value used for EW
EW Equivalenth width (FLUX/pseudo continuum)
EWERR Error in the above
read(ifile=None, strict=True, checksum=False)[source]

Read an existing file with a previously binned set of spectra.

static sideband_pseudocontinua(wave, spec, sidebands, spec_n=None, err=None, log=True, weighted_center=True)[source]

Get the side-band integrals.

err is a single vector that is the same for all spec!

Returns:Return five arrays or floats: (1) The center of each passband, (2) the mean continuum level, (3) the propagated error in the continuum level (will be None if no errors are provided), (4) flag that part of the passband was masked, (5) flag that the passband was fully masked or empty.
Return type:float, numpy.ndarray
static single_band_moments(wave, spec, passband, restwave, err=None)[source]

Measure the moments for a single band.

If spectrum errors are not provided, moment errors are returned as 0.0.

Parameters:
  • wave (numpy.ndarray) – Wavelengths in angstroms
  • spec (numpy.ndarray) – Flux in flux density (per angstrom)
  • restwave (float) – The rest wavelength of the line.
  • err (numpy.ndarray) – The 1-sigma errors in the flux density.
Returns:

flux fluxerr mom1 mom1err mom2 mom2err incomplete band empty band division by zero undefined 1st moment undefined 2nd moment

write(clobber=False)[source]

Write the hdu object to the file.

class mangadap.proc.emissionlinemoments.EmissionLineMomentsBitMask(dapsrc=None)[source]

Bases: mangadap.util.bitmask.BitMask

Derived class that specifies the mask bits for the emission-line moment measurements. See mangadap.util.bitmask.BitMask for attributes.

A list of the bits and meanings are provided by the base class function mangadap.util.bitmask.BitMask.info(); i.e.,:

from mangadap.proc.emissionlinemoments import EmissionLineMomentsBitMask
bm = EmissionLineMomentsBitMask()
bm.info()
class mangadap.proc.emissionlinemoments.EmissionLineMomentsDef(key, minimum_snr, artifacts, passbands, redo_postmodeling, fit_vel_name)[source]

Bases: mangadap.par.parset.ParSet

A class that holds the parameters necessary to perform the emission-line moment measurements.

Parameters:
  • key (str) – Keyword used to distinguish between different emission-line moment databases.
  • minimum_snr (bool) – Minimum S/N of spectrum to fit
  • artifacts (str) – String identifying the artifact database to use
  • passbands (str) – String identifying the emission-line bandpass filter database to use
mangadap.proc.emissionlinemoments.available_emission_line_moment_databases(dapsrc=None)[source]

Return the list of available emission-line moment databases.

Available database combinations:

Todo

Fill in

Parameters:

dapsrc (str) – (Optional) Root path to the DAP source directory. If not provided, the default is defined by mangadap.config.defaults.dap_source_dir().

Returns:

A list of EmissionLineMomentsDef() objects, each defining an emission-line moment database to measure.

Return type:

list

Raises:
  • NotADirectoryError – Raised if the provided or default dapsrc is not a directory.
  • OSError/IOError – Raised if no emission-line moment configuration files could be found.
  • KeyError – Raised if the emission-line moment database keywords are not all unique.

Todo

  • Somehow add a python call that reads the databases and constructs the table for presentation in sphinx so that the text above doesn’t have to be edited with changes in the available databases.
mangadap.proc.emissionlinemoments.validate_emission_line_moments_config(cnfg)[source]

Validate the mangadap.util.parser.DefaultConfig with the emission-line moment measurement parameters.

Parameters:

cnfg (mangadap.util.parser.DefaultConfig) – Object meant to contain defining parameters of the emission-line moments as needed by EmissionLineMomentsDef

Raises:
  • KeyError – Raised if any required keywords do not exist.
  • ValueError – Raised if keys have unacceptable values.
  • FileNotFoundError – Raised if a file is specified but could not be found.