mangadap.proc.emissionlinemoments module¶
A class hierarchy that measures moments of the observed emission lines.
Revision history¶
25 Apr 2016: Implementation begun by K. Westfall (KBW)20 May 2016: (KBW) Added loggers and quiet keyword arguments toEmissionLineMoments
, removed verbose28 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 usingmangadap.proc.stellarcontinuummodel.StellarContinuumModel
on input02 Feb 2018: (KBW) Adjust for change tomangadap.proc.stellarcontinuummodel.StellarContinuumModel.fill_to_match()
.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.
Copyright © 2019, SDSS-IV/MaNGA Pipeline Group
-
class
mangadap.proc.emissionlinemoments.
EmissionLineMoments
(database_key, binned_spectra, stellar_continuum=None, emission_line_model=None, redshift=None, database_list=None, artifact_path=None, bandpass_path=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 inhdu
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
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.
- 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; seeredshift
inmangadap.proc.stellarcontinuummodel.StellarContinuumModel.matched_kinematics()
. If None (default), the median of the unmasked stellar velocities will be used.
-
_define_databases
(database_key, database_list=None, artifact_path=None, bandpass_path=None, dapsrc=None)[source]¶ Select the database of bandpass filters.
-
_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
andoutput_file
. If not provided, the defaults are set using, respectively,mangadap.config.defaults.default_dap_method_path()
andmangadap.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()
.
- directory_path (str) – The exact path to the DAP
emission-line moments file. See
-
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
-
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
- loggers (list) – (Optional) List of logging.Logger objects
to log progress; ignored if quiet=True. Logging is done
using
-
class
mangadap.proc.emissionlinemoments.
EmissionLineMomentsBitMask
[source]¶ Bases:
mangadap.util.dapbitmask.DAPBitMask
Derived class that specifies the mask bits for the emission-line moment measurements. The maskbits defined are:
Key Bit Description DIDNOTUSE 0 Pixel was ignored because it was flagged as DONOTUSE or FORESTAR by the DRP, or as LOW_SPECCOV, LOW_SNR, or NONE_IN_STACK in the binning step. FORESTAR 1 Pixel was ignored because it was flagged as FORESTAR by the DRP. LOW_SNR 2 Pixel was ignored because the S/N estimate of the spectrum was below the set threshold; see header keyword ELMMINSN. MAIN_EMPTY 5 Line moments not measured because the main passband had no observed fluxes. BLUE_EMPTY 6 Line moments not measured because the blue passband had no observed fluxes. RED_EMPTY 7 Line moments not measured because the red passband had no observed fluxes. MAIN_INCOMP 8 There were masked fluxes in the main passband. BLUE_INCOMP 9 There were masked fluxes in the blue passband. RED_INCOMP 10 There were masked fluxes in the red passband. DIVBYZERO 11 Could not compute emission-line moment or its error because of a zero devision. NO_ABSORPTION_CORRECTION 12 Moment has not been corrected for underlying absorption because no stellar-continuum model was provided or the model did not cover the necessary spectral range. MAIN_JUMP 13 Some fraction of, but less than all, the pixels in the main passband were not fit by the stellar-continuum model, meaning the bandpass integral should not be trusted. BLUE_JUMP 14 Some fraction of, but less than all, the pixels in the blue sideband were not fit by the stellar-continuum model, meaning the bandpass integral should not be trusted. RED_JUMP 15 Some fraction of, but less than all, the pixels in the red sideband were not fit by the stellar-continuum model, meaning the bandpass integral should not be trusted. JUMP_BTWN_SIDEBANDS 16 The stellar-continuum was subtracted from one sideband, but not the other, meaning that the determination of the continuum beneath the line is invalid. UNDEFINED_MOM1 17 First moment is undefined, likely because the passband was empty UNDEFINED_MOM2 18 Second moment is undefined, likely because it leads to the square-root of a negative number. UNDEFINED_BANDS 19 No moments calculated because the bandpasses were not, or improperly, defined. NON_POSITIVE_CONTINUUM 20 Equivalent width measurements were not computed because the continuum in either the blue or red sidebands was not positive. -
cfg_root
= 'emission_line_moments_bits'¶
-
-
class
mangadap.proc.emissionlinemoments.
EmissionLineMomentsDef
(key=None, minimum_snr=None, artifacts=None, passbands=None, redo_postmodeling=None, fit_vel_name=None)[source]¶ Bases:
mangadap.par.parset.KeywordParSet
A class that holds the parameters necessary to perform the emission-line moment measurements.
The defined parameters are:
Key Type Options Default Description key
str Keyword used to distinguish between different emission-line moment databases. minimum_snr
int, float 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 redo_postmodeling
bool Redo the moment measurements after the emission-line modeling has been performed fit_vel_name
str The name of the emission line used to set the redshift of each spaxel used to set the observed wavelength of the bandpasses.
-
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 byEmissionLineMomentsDef
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.