8#ifndef mx_astro_astroSpectra_hpp
9#define mx_astro_astroSpectra_hpp
12#include "../ioutils/readColumns.hpp"
23template <
typename _units>
27 typedef typename units::realT realT;
29 static const bool freq =
false;
37 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
53 std::vector<realT> &rawLambda,
54 std::vector<realT> &rawSpectrum,
55 const std::string &path,
67template <
typename _units,
bool _rsr = true>
71 typedef typename units::realT realT;
73 static const bool freq =
false;
81 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
83 static constexpr const char *dataDirEnvVar =
"ASTROFILT_DATADIR";
85 static std::string fileName(
const std::string &name )
91 std::vector<realT> &rawLambda,
92 std::vector<realT> &rawSpectrum,
93 const std::string &path,
105 for(
int i = 0; i < rawLambda.size(); ++i )
108 if( rawSpectrum[i] > max )
109 max = rawSpectrum[i];
112 for(
int i = 0; i < rawLambda.size(); ++i )
114 rawSpectrum[i] /= max;
143template <
typename _units,
bool _rsr = true>
146 typedef _units units;
147 typedef typename units::realT realT;
149 static const bool freq =
false;
163 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
165 static constexpr const char *dataDirEnvVar = 0;
167 static std::string fileName(
const paramsT ¶ms )
173 std::vector<realT> &rawLambda,
174 std::vector<realT> &rawSpectrum,
175 const std::string &path,
179 rawLambda.resize( 4 );
180 rawSpectrum.resize( 4 );
182 rawLambda[0] = params.
lam0 - 0.5 * params.
fw - 0.5 * params.
dlam;
183 rawSpectrum[0] = 0.0;
185 rawLambda[1] = params.
lam0 - 0.5 * params.
fw + 0.5 * params.
dlam;
186 rawSpectrum[1] = 1.0;
188 rawLambda[2] = params.
lam0 + 0.5 * params.
fw - 0.5 * params.
dlam;
189 rawSpectrum[2] = 1.0;
191 rawLambda[3] = params.
lam0 + 0.5 * params.
fw + 0.5 * params.
dlam;
192 rawSpectrum[3] = 0.0;
203template <
typename _units>
206 typedef _units units;
207 typedef typename units::realT realT;
209 static const bool freq =
false;
218 static_cast<realT
>( 1e7 ) / (
static_cast<realT
>( 1e4 ) *
static_cast<realT
>( 1e10 ) );
220 static constexpr const char *dataDirEnvVar =
"CALSPEC_DATADIR";
223 static std::string
fileName(
const std::string &name )
225 if( name ==
"alpha_lyr" || name ==
"vega" )
226 return "alpha_lyr_stis_005.asc";
227 else if( name ==
"1740346" )
228 return "1740346_nic_002.ascii";
229 else if( name ==
"sun" || name ==
"sun_reference" )
230 return "sun_reference_stis.002.asc";
235 std::vector<realT> &rawLambda,
236 std::vector<realT> &rawSpectrum,
237 const std::string &path,
249template <
typename _units>
252 typedef _units units;
253 typedef typename units::realT realT;
255 static const bool freq =
false;
263 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
269 static std::string
fileName(
const std::string &spt )
276 std::vector<realT> &rawLambda,
277 std::vector<realT> &rawSpectrum,
278 const std::string &path,
295template <
typename _units>
298 typedef _units units;
299 typedef typename units::realT realT;
301 static const bool freq =
false;
309 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
315 static std::string
fileName(
const std::string &name )
317 if( name ==
"EPOXI" )
318 return "cowan_2013_EPOXI_albedo.dat";
319 if( name ==
"Earthshine" )
320 return "earthshine_epoxi_normalized.dat";
321 if( name ==
"RawEarthshine" )
322 return "Earthshine/F7_opt_NIR_ES_data.txt";
331 std::vector<realT> &rawLambda,
332 std::vector<realT> &rawSpectrum,
333 const std::string &path,
346template <
typename _units>
349 typedef _units units;
350 typedef typename units::realT realT;
352 static const bool freq =
false;
360 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
366 static std::string
fileName(
const std::string &name )
368 if( name ==
"Venus" )
369 return "venus_combined_albedo.dat";
378 std::vector<realT> &rawLambda,
379 std::vector<realT> &rawSpectrum,
380 const std::string &path,
error_t readColumns(const std::string &fname, arrTs &...arrays)
Read in columns from a text file.
error_t
The mxlib error codes.
@ noerror
No error has occurred.
#define mxError(esrc, ecode, expl)
This reports an mxlib specific error.
#define MXE_INVALIDARG
An argument was invalid.
mx::error_t toLower(std::string &outstr, const std::string &instr)
Convert a string to all lower case.
A spectrum from the astroFilt filter library.
static error_t readSpectrum(std::vector< realT > &rawLambda, std::vector< realT > &rawSpectrum, const std::string &path, const paramsT ¶ms)
static constexpr realT fluxUnits
No conversion is performed on filter transmission.
static constexpr realT wavelengthUnits
Convert from um to SI m.
std::string paramsT
The astroFilters are parameterized by name.
static constexpr realT fluxUnits
Specify how to convert to SI flux units. No conversions are performed in the basic spectrum.
static error_t readSpectrum(std::vector< realT > &rawLambda, std::vector< realT > &rawSpectrum, const std::string &path, const paramsT ¶ms)
This function reads the spectrum, returning its raw wavelength and spectrum points.
std::string paramsT
The parameter is a string name.
static constexpr realT wavelengthUnits
Specify how to convert to SI wavelength units. No conversions are performed in the basic spectrum.
static std::string fileName(const paramsT &name)
This function should calculate the file name (without the path) for the spectrum parameters.
static constexpr const char * dataDirEnvVar
The data directory environment variable name.
A spectrum from the HST calspec library.
static constexpr realT fluxUnits
Convert from erg s-1 cm-2 A-1 to SI W m-3.
static std::string fileName(const std::string &name)
The file name is found from the star's name.
static error_t readSpectrum(std::vector< realT > &rawLambda, std::vector< realT > &rawSpectrum, const std::string &path, const paramsT ¶ms)
Read a CALSPEC spectrum, which is a simple two column ASCII format.
std::string paramsT
The calspec Spectra are parameterized by star name.
static constexpr realT wavelengthUnits
Convert from A to SI m.
static constexpr realT wavelengthUnits
Convert from A to SI m.
static constexpr const char * dataDirEnvVar
The location is specified by the EARTHSHINE_DATADIR environment variable.
static error_t readSpectrum(std::vector< realT > &rawLambda, std::vector< realT > &rawSpectrum, const std::string &path, const paramsT ¶ms)
Read the Earthshine albedo spectrum, which is a simple two column ASCII format.
std::string paramsT
The name of the spectrum can be "EPOXI", "Earthshine", or "RawEarthshine".
static constexpr realT fluxUnits
The Earthshine is a dimensionless albedo.
static std::string fileName(const std::string &name)
The name of the datafile is a constant.
A spectrum from the Pickles library.
static constexpr const char * dataDirEnvVar
The Pickles spectra location is specified by the PICKLES_DATADIR environment variable.
static constexpr realT fluxUnits
The Pickles spectra are dimensionless.
static constexpr realT wavelengthUnits
Convert from A to SI m.
std::string paramsT
The Pickles spectra are parameterized by a spectral type string.
static std::string fileName(const std::string &spt)
The name of the datafile is constructed from its spectral type string.
static error_t readSpectrum(std::vector< realT > &rawLambda, std::vector< realT > &rawSpectrum, const std::string &path, const paramsT ¶ms)
Read a Pickles spectrum, which for these purposes is a simple two column ASCII format.
The square wave is parameterized by the central wavelength, width, and sampling (all in microns).
realT dlam
The wavelength sampling to use in microns.
realT lam0
The central Wavelength in microns.
realT fw
The full width of the filter in microns.
A square-wave filter spectrum.
static constexpr realT fluxUnits
No conversion is performed on filter transmission.
static constexpr realT wavelengthUnits
Convert from um to SI m.
static error_t readSpectrum(std::vector< realT > &rawLambda, std::vector< realT > &rawSpectrum, const std::string &path, const paramsT ¶ms)
static std::string fileName(const std::string &name)
The name of the datafile is a constant.
static constexpr realT fluxUnits
The Earthshine is a dimensionless albedo.
std::string paramsT
The name of the spectrum can be "venus".
static constexpr const char * dataDirEnvVar
The location is specified by the EARTHSHINE_DATADIR environment variable.
static error_t readSpectrum(std::vector< realT > &rawLambda, std::vector< realT > &rawSpectrum, const std::string &path, const paramsT ¶ms)
Read the Earthshine albedo spectrum, which is a simple two column ASCII format.
static constexpr realT wavelengthUnits
Convert from A to SI m.
Unit specifications and conversions.