mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
mx::astro::astroSpectrum< _spectrumT, freq > Struct Template Reference

template<typename _spectrumT, bool freq = false>
struct mx::astro::astroSpectrum< _spectrumT, freq >

Class to manage an astronomical spectrum.

Details of the spectra, including units, file-location, and how they are read from disk, are specified by template parameter _spectrumT: see the available spectrum definitions. Spectra are loaded and immediately interpolated onto a wavelength grid. This is to facilitate manipulation of spectra, i.e. for multiplying by filters, etc.

Inherits functions and operators to manipulate and characterize spectra from baseSpectrum.

Template Parameters
_spectrumTis the underlying spectrum type, which provides (through static interfaces) the specifications of how to read or calculate the spectrum.
freqspecify whether this spectrum uses frequency instead of wavelength. Default is false.

Definition at line 279 of file astroSpectrum.hpp.

#include <astro/astroSpectrum.hpp>

+ Inheritance diagram for mx::astro::astroSpectrum< _spectrumT, freq >:

Public Member Functions

 astroSpectrum ()
 Default c'tor. More...
 
 astroSpectrum (const paramsT &params)
 Constructor specifying name, the enivronment will be queried for data directory. More...
 
 astroSpectrum (const paramsT &params, const std::string &dataDir)
 Constructor specifying name and data directory. More...
 
int setParameters (const paramsT &params)
 Set the parameters of the spectrum, using the underlying spectrums parameter type. More...
 
int setParameters (const paramsT &params, const std::string &dataDir)
 Set the parameters of the spectrum, using the underlying spectrum's parameter type. More...
 
template<typename gridT >
int setSpectrum (gridT &lambda)
 Load the spectrum and interpolate it onto a wavelength scale. More...
 
- Public Member Functions inherited from mx::astro::baseSpectrum< _spectrumT::units::realT >
size_t size ()
 Get the current size of the spectrum. More...
 
_spectrumT::units::realT & operator[] (size_t i)
 Access a single point in the spectrum, specified by its vector index. More...
 
const _spectrumT::units::realT operator[] (size_t i) const
 Access a single point in the spectrum, specified by its vector index. More...
 
baseSpectrum< _spectrumT::units::realT > operator* (const compSpectrumT &spec)
 Multiply two spectra together. More...
 
_spectrumT::units::realT mean ()
 Calculate the mean value of the spectrum. More...
 
_spectrumT::units::realT mean (const compSpectrumT &T)
 Calculate the mean value of the spectrum when mutiplied by another. More...
 
void charTrans (_spectrumT::units::realT &lambda0, _spectrumT::units::realT &weff, _spectrumT::units::realT &max, _spectrumT::units::realT &fwhm, std::vector< _spectrumT::units::realT > &lambda)
 Characterize the spectrum as a filter transmission curve. More...
 
void charFlux (_spectrumT::units::realT &flambda0, _spectrumT::units::realT &fnu0, _spectrumT::units::realT &fphot0, const _spectrumT::units::realT &lambda_0, const std::vector< _spectrumT::units::realT > &lambda, const filterT &trans)
 Characterize the flux densities of the spectrum w.r.t. a filter transmission curve. More...
 
void charFlux (_spectrumT::units::realT &flambda0, _spectrumT::units::realT &fnu0, _spectrumT::units::realT &fphot0, const _spectrumT::units::realT &lambda_0, const std::vector< _spectrumT::units::realT > &lambda, const std::vector< _spectrumT::units::realT > &trans)
 Characterize the flux densities of the spectrum w.r.t. a filter transmission curve. More...
 

Public Attributes

std::string _dataDir
 The directory containing the spectrum. More...
 
paramsT _params
 The parameters of the spectrum, e.g. its name or the numerical parameters needed to generate the name. More...
 
- Public Attributes inherited from mx::astro::baseSpectrum< _spectrumT::units::realT >
std::vector< _spectrumT::units::realT > _spectrum
 Contains the spectrum after it is set. More...
 

Constructor & Destructor Documentation

◆ astroSpectrum() [1/3]

template<typename _spectrumT , bool freq = false>
mx::astro::astroSpectrum< _spectrumT, freq >::astroSpectrum ( )
inline

Default c'tor.

Definition at line 291 of file astroSpectrum.hpp.

◆ astroSpectrum() [2/3]

template<typename _spectrumT , bool freq = false>
mx::astro::astroSpectrum< _spectrumT, freq >::astroSpectrum ( const paramsT &  params)
inlineexplicit

Constructor specifying name, the enivronment will be queried for data directory.

Parameters
[in]paramsThe name of the spectrum

Definition at line 294 of file astroSpectrum.hpp.

References mx::astro::astroSpectrum< _spectrumT, freq >::setParameters().

◆ astroSpectrum() [3/3]

template<typename _spectrumT , bool freq = false>
mx::astro::astroSpectrum< _spectrumT, freq >::astroSpectrum ( const paramsT &  params,
const std::string &  dataDir 
)
inline

Constructor specifying name and data directory.

Parameters
[in]paramsThe name of the spectrum
[in]dataDirThe directory containing the spectrum

Definition at line 300 of file astroSpectrum.hpp.

References mx::astro::astroSpectrum< _spectrumT, freq >::setParameters().

Member Function Documentation

◆ setParameters() [1/2]

template<typename _spectrumT , bool freq = false>
int mx::astro::astroSpectrum< _spectrumT, freq >::setParameters ( const paramsT &  params)
inline

Set the parameters of the spectrum, using the underlying spectrums parameter type.

Parameters
[in]paramsThe name of the spectrum

Definition at line 308 of file astroSpectrum.hpp.

References mx::astro::astroSpectrum< _spectrumT, freq >::_dataDir, mx::astro::astroSpectrum< _spectrumT, freq >::_params, and mx::sys::getEnv().

Referenced by mx::astro::astroSpectrum< _spectrumT, freq >::astroSpectrum(), and mx::astro::cahoyGrid< _units >::loadGrid().

◆ setParameters() [2/2]

template<typename _spectrumT , bool freq = false>
int mx::astro::astroSpectrum< _spectrumT, freq >::setParameters ( const paramsT &  params,
const std::string &  dataDir 
)
inline

Set the parameters of the spectrum, using the underlying spectrum's parameter type.

This version also sets the data directory, instead of using the enivronment variable.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
[in]paramsThe name of the spectrum
[in]dataDirThe directory containing the spectrum

Definition at line 325 of file astroSpectrum.hpp.

References mx::astro::astroSpectrum< _spectrumT, freq >::_dataDir, and mx::astro::astroSpectrum< _spectrumT, freq >::_params.

◆ setSpectrum()

template<typename _spectrumT , bool freq = false>
template<typename gridT >
int mx::astro::astroSpectrum< _spectrumT, freq >::setSpectrum ( gridT &  lambda)
inline

Load the spectrum and interpolate it onto a wavelength scale.

Returns
-1 on an error reading the spectrum.
0 on success.

Definition at line 337 of file astroSpectrum.hpp.

References mx::astro::astroSpectrum< _spectrumT, freq >::_dataDir, mx::astro::astroSpectrum< _spectrumT, freq >::_params, mx::astro::baseSpectrum< _spectrumT::units::realT >::_spectrum, and mx::math::gsl_interpolate().

Referenced by mx::astro::cahoyGrid< _units >::loadGrid().

Member Data Documentation

◆ _dataDir

template<typename _spectrumT , bool freq = false>
std::string mx::astro::astroSpectrum< _spectrumT, freq >::_dataDir

◆ _params

template<typename _spectrumT , bool freq = false>
paramsT mx::astro::astroSpectrum< _spectrumT, freq >::_params

The parameters of the spectrum, e.g. its name or the numerical parameters needed to generate the name.

Definition at line 288 of file astroSpectrum.hpp.

Referenced by mx::astro::astroSpectrum< _spectrumT, freq >::setParameters(), and mx::astro::astroSpectrum< _spectrumT, freq >::setSpectrum().


The documentation for this struct was generated from the following file: