8#ifndef mx_astro_astroSpectra_hpp
9#define mx_astro_astroSpectra_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 );
54 std::vector<realT> &rawSpectrum,
56 const std::string &path,
69template <
typename _units,
bool _rsr = true>
73 typedef typename units::realT realT;
75 static const bool freq =
false;
83 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
85 static constexpr const char *dataDirEnvVar =
"ASTROFILT_DATADIR";
87 static std::string fileName(
const std::string &name )
94 std::vector<realT> &rawSpectrum,
96 const std::string &path,
109 for(
int i = 0; i < rawLambda.size(); ++i )
112 if( rawSpectrum[i] > max )
113 max = rawSpectrum[i];
116 for(
int i = 0; i < rawLambda.size(); ++i )
118 rawSpectrum[i] /= max;
147template <
typename _units,
bool _rsr = true>
150 typedef _units units;
151 typedef typename units::realT realT;
153 static const bool freq =
false;
167 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
169 static constexpr const char *dataDirEnvVar = 0;
171 static std::string fileName(
const paramsT ¶ms )
178 std::vector<realT> &rawSpectrum,
180 const std::string &path,
185 rawLambda.resize( 4 );
186 rawSpectrum.resize( 4 );
188 rawLambda[0] = params.
lam0 - 0.5 * params.
fw - 0.5 * params.
dlam;
189 rawSpectrum[0] = 0.0;
191 rawLambda[1] = params.
lam0 - 0.5 * params.
fw + 0.5 * params.
dlam;
192 rawSpectrum[1] = 1.0;
194 rawLambda[2] = params.
lam0 + 0.5 * params.
fw - 0.5 * params.
dlam;
195 rawSpectrum[2] = 1.0;
197 rawLambda[3] = params.
lam0 + 0.5 * params.
fw + 0.5 * params.
dlam;
198 rawSpectrum[3] = 0.0;
209template <
typename _units>
212 typedef _units units;
213 typedef typename units::realT realT;
215 static const bool freq =
false;
224 static_cast<realT
>( 1e7 ) / (
static_cast<realT
>( 1e4 ) *
static_cast<realT
>( 1e10 ) );
226 static constexpr const char *dataDirEnvVar =
"CALSPEC_DATADIR";
229 static std::string
fileName(
const std::string &name )
231 if( name ==
"alpha_lyr" || name ==
"vega" )
232 return "alpha_lyr_stis_005.asc";
233 else if( name ==
"1740346" )
234 return "1740346_nic_002.ascii";
235 else if( name ==
"sun" || name ==
"sun_reference" )
236 return "sun_reference_stis.002.asc";
244 std::vector<realT> &rawSpectrum,
246 const std::string &path,
259template <
typename _units>
262 typedef _units units;
263 typedef typename units::realT realT;
265 static const bool freq =
false;
273 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
279 static std::string
fileName(
const std::string &spt )
287 std::vector<realT> &rawSpectrum,
289 const std::string &path,
307template <
typename _units,
typename verboseT = verbose::d>
310 typedef _units units;
311 typedef typename units::realT realT;
313 static const bool freq =
false;
321 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
327 static std::string
fileName(
const std::string &name )
329 if( name ==
"EPOXI" )
330 return "cowan_2013_EPOXI_albedo.dat";
331 if( name ==
"Earthshine" )
332 return "earthshine_epoxi_normalized.dat";
333 if( name ==
"RawEarthshine" )
334 return "Earthshine/F7_opt_NIR_ES_data.txt";
344 std::vector<realT> &rawSpectrum,
346 const std::string &path,
360template <
typename _units,
typename verboseT = verbose::d>
363 typedef _units units;
364 typedef typename units::realT realT;
366 static const bool freq =
false;
374 static constexpr realT
fluxUnits =
static_cast<realT
>( 1 );
380 static std::string
fileName(
const std::string &name )
382 if( name ==
"Venus" )
383 return "venus_combined_albedo.dat";
393 std::vector<realT> &rawSpectrum,
395 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.
@ invalidarg
An argument was invalid.
error_t mxlib_error_report(const error_t &code, const std::string &expl, const std::source_location &loc=std::source_location::current())
Print a report to stderr given an mxlib error_t code and explanation and return the code.
mx::error_t toLower(std::string &outstr, const std::string &instr)
Convert a string to all lower case.
A utility to read in columns from a text file.
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.
std::string paramsT
The name of the spectrum can be "EPOXI", "Earthshine", or "RawEarthshine".
static std::string fileName(const std::string &name)
The name of the datafile is a constant.
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 const char * dataDirEnvVar
The location is specified by the EARTHSHINE_DATADIR environment variable.
static constexpr realT wavelengthUnits
Convert from A to SI m.
static constexpr realT fluxUnits
The Earthshine is a dimensionless albedo.
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 constexpr realT wavelengthUnits
Convert from A to SI m.
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 const char * dataDirEnvVar
The location is specified by the EARTHSHINE_DATADIR environment variable.
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.
std::string paramsT
The name of the spectrum can be "venus".
Unit specifications and conversions.