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

template<typename realT>
struct mx::astro::baseSpectrum< realT >

Base spectrum class which provides manipulation and characterization functionality.

Definition at line 30 of file astroSpectrum.hpp.

#include <astro/astroSpectrum.hpp>

Public Member Functions

size_t size ()
 Get the current size of the spectrum. More...
 
realT & operator[] (size_t i)
 Access a single point in the spectrum, specified by its vector index. More...
 
const realT operator[] (size_t i) const
 Access a single point in the spectrum, specified by its vector index. More...
 
template<typename compSpectrumT >
baseSpectrum< realT > operator* (const compSpectrumT &spec)
 Multiply two spectra together. More...
 
realT mean ()
 Calculate the mean value of the spectrum. More...
 
template<typename compSpectrumT >
realT mean (const compSpectrumT &T)
 Calculate the mean value of the spectrum when mutiplied by another. More...
 
void charTrans (realT &lambda0, realT &weff, realT &max, realT &fwhm, std::vector< realT > &lambda)
 Characterize the spectrum as a filter transmission curve. More...
 
template<class filterT >
void charFlux (realT &flambda0, realT &fnu0, realT &fphot0, const realT &lambda_0, const std::vector< realT > &lambda, const filterT &trans)
 Characterize the flux densities of the spectrum w.r.t. a filter transmission curve. More...
 
void charFlux (realT &flambda0, realT &fnu0, realT &fphot0, const realT &lambda_0, const std::vector< realT > &lambda, const std::vector< realT > &trans)
 Characterize the flux densities of the spectrum w.r.t. a filter transmission curve. More...
 

Public Attributes

std::vector< realT > _spectrum
 Contains the spectrum after it is set. More...
 

Member Function Documentation

◆ charFlux() [1/2]

template<typename realT >
template<class filterT >
void mx::astro::baseSpectrum< realT >::charFlux ( realT &  flambda0,
realT &  fnu0,
realT &  fphot0,
const realT &  lambda_0,
const std::vector< realT > &  lambda,
const filterT &  trans 
)
inline

Characterize the flux densities of the spectrum w.r.t. a filter transmission curve.

To obtain the flux (e.g. W/m^2) multiply these quantities by the effective width calculated using charTrans.

This implements Equations A11, A12, and A13 of Bessel 2012.

Warning
this only produces correct fphot0 for a spectrum in W/m^3. DO NOT USE FOR ANYTHING ELSE.
Todo:

use unit conversions to make it work for everything.

check on integration method, should it be trap?

Parameters
[out]flambda0the flux of the star at \( \lambda_0 \) in W/m^3
[out]fnu0the flux of the star at \( \lambda_0 \) in W/m^2/Hz
[out]fphot0the flux of the star at \( \lambda_0 \) in photons/sec/m^3
[in]lambda_0the mean photon wavelength lambda_0 (from charTrans).
[in]lambdathe wavelength scale of this spectrum.
[in]transthe filter transmission curve over which to characterize, on the same wavelength grid.

Definition at line 197 of file astroSpectrum.hpp.

◆ charFlux() [2/2]

template<typename realT >
void mx::astro::baseSpectrum< realT >::charFlux ( realT &  flambda0,
realT &  fnu0,
realT &  fphot0,
const realT &  lambda_0,
const std::vector< realT > &  lambda,
const std::vector< realT > &  trans 
)
inline

Characterize the flux densities of the spectrum w.r.t. a filter transmission curve.

To obtain the flux (e.g. W/m^2) multiply these quantities by the effective width calculated using charTrans.

This implements Equations A11, A12, and A13 of Bessel 2012.

Warning
this only produces correct fphot0 for a spectrum in W/m^3. DO NOT USE FOR ANYTHING ELSE.
Todo:

use unit conversions to make it work for everything.

check on integration method, should it be trap?

Parameters
[out]flambda0the flux of the star at \( \lambda_0 \) in W/m^3
[out]fnu0the flux of the star at \( \lambda_0 \) in W/m^2/Hz
[out]fphot0the flux of the star at \( \lambda_0 \) in photons/sec/m^3
[in]lambda_0the mean photon wavelength lambda_0 (from charTrans).
[in]lambdathe wavelength scale of this spectrum.
[in]transthe filter transmission curve over which to characterize, on the same wavelength grid.

Definition at line 220 of file astroSpectrum.hpp.

References mx::astro::baseSpectrum< realT >::_spectrum, mx::astro::constants::c(), and mx::astro::constants::h().

◆ charTrans()

template<typename realT >
void mx::astro::baseSpectrum< realT >::charTrans ( realT &  lambda0,
realT &  weff,
realT &  max,
realT &  fwhm,
std::vector< realT > &  lambda 
)
inline

Characterize the spectrum as a filter transmission curve.

For a photonic transmission curve given by \( S(\lambda ) \) The mean photon wavelength is defined as

\[ \lambda_0 = \frac{1}{\Delta\lambda_{0}}\int \frac{S(\lambda )}{S_{max}} \lambda d\lambda \]

which Equation A14 of Bessel 2012.

where the effective width is defined by

\[ \Delta\lambda_{o} = \int \frac{S(\lambda )} { S_{max}} d\lambda \]

The full-width at half-maximum, FWHM, is the distance between the points at 50% of maximum \( S(\lambda) \).

Parameters
[out]lambda0the central wavelength of the filter
[out]weffthe effective width of the filter
[out]maxthe maximum value of the transmission curve
[out]fwhmthe full-width at half-maximum of the filter profile
[in]lambdathe wavelength scale, should correspond to the spectrum.

Definition at line 133 of file astroSpectrum.hpp.

References mx::astro::baseSpectrum< realT >::_spectrum.

◆ mean() [1/2]

template<typename realT >
realT mx::astro::baseSpectrum< realT >::mean ( )
inline

Calculate the mean value of the spectrum.

Returns
the mean value of the spectrum

Definition at line 83 of file astroSpectrum.hpp.

References mx::astro::baseSpectrum< realT >::_spectrum.

◆ mean() [2/2]

template<typename realT >
template<typename compSpectrumT >
realT mx::astro::baseSpectrum< realT >::mean ( const compSpectrumT &  T)
inline

Calculate the mean value of the spectrum when mutiplied by another.

The result is normalized by the mean value of the input spectrum, equivalent to:

\[ \mu = \frac{\int T(\lambda)S(\lambda) d\lambda}{\int T(\lambda) d\lambda} \]

For instance, use this to get the mean value of a spectrum in a filter.

Returns
the mean value of the multiplied spectrum.
Template Parameters
compSpectrumTthe vector-like type of the comparison spectrum.
Parameters
[in]Tthe spectrum to multiply by

Definition at line 104 of file astroSpectrum.hpp.

References mx::astro::baseSpectrum< realT >::_spectrum.

◆ operator*()

template<typename realT >
template<typename compSpectrumT >
baseSpectrum<realT> mx::astro::baseSpectrum< realT >::operator* ( const compSpectrumT &  spec)
inline

Multiply two spectra together.

Returns
a new baseSpectrum
Parameters
[in]specthe spectrum to multiply by

Definition at line 66 of file astroSpectrum.hpp.

References mx::astro::baseSpectrum< realT >::_spectrum.

◆ operator[]() [1/2]

template<typename realT >
realT& mx::astro::baseSpectrum< realT >::operator[] ( size_t  i)
inline

Access a single point in the spectrum, specified by its vector index.

Returns
a reference to the value at i.
Parameters
[in]ithe index of the spectral point

Definition at line 47 of file astroSpectrum.hpp.

References mx::astro::baseSpectrum< realT >::_spectrum.

◆ operator[]() [2/2]

template<typename realT >
const realT mx::astro::baseSpectrum< realT >::operator[] ( size_t  i) const
inline

Access a single point in the spectrum, specified by its vector index.

Returns
the value of point i.
Parameters
[in]ithe index of the spectral point

Definition at line 56 of file astroSpectrum.hpp.

References mx::astro::baseSpectrum< realT >::_spectrum.

◆ size()

template<typename realT >
size_t mx::astro::baseSpectrum< realT >::size ( )
inline

Get the current size of the spectrum.

Returns
the number of points in the spectrum

Definition at line 38 of file astroSpectrum.hpp.

References mx::astro::baseSpectrum< realT >::_spectrum.

Member Data Documentation

◆ _spectrum


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