8 #ifndef mx_astro_astroSpectra_hpp
9 #define mx_astro_astroSpectra_hpp
12 #include "../ioutils/readColumns.hpp"
23 template<
typename _units>
27 typedef typename units::realT realT;
29 static const bool freq =
false;
37 static constexpr realT
fluxUnits =
static_cast<realT
>(1);
52 std::vector<realT> & rawSpectrum,
53 const std::string & path,
67 template<
typename _units,
bool _rsr=true>
71 typedef typename units::realT realT;
73 static const bool freq =
false;
82 static constexpr realT
fluxUnits =
static_cast<realT
>(1);
84 static constexpr
const char * dataDirEnvVar =
"ASTROFILT_DATADIR";
86 static std::string fileName(
const std::string & name )
92 std::vector<realT> & rawSpectrum,
93 const std::string & path,
100 for(
int i=0;i<rawLambda.size(); ++i)
103 if(rawSpectrum[i] > max) max = rawSpectrum[i];
106 for(
int i=0;i<rawLambda.size(); ++i)
108 rawSpectrum[i] /= max;
139 template<
typename _units,
bool _rsr=true>
142 typedef _units units;
143 typedef typename units::realT realT;
145 static const bool freq =
false;
159 static constexpr realT
fluxUnits =
static_cast<realT
>(1);
161 static constexpr
const char * dataDirEnvVar = 0;
163 static std::string fileName(
const paramsT & params )
169 std::vector<realT> & rawSpectrum,
170 const std::string & path,
175 rawSpectrum.resize(4);
177 rawLambda[0] = params.
lam0 - 0.5*params.
fw - 0.5*params.
dlam;
178 rawSpectrum[0] = 0.0;
180 rawLambda[1] = params.
lam0 - 0.5*params.
fw + 0.5*params.
dlam;
181 rawSpectrum[1] = 1.0;
183 rawLambda[2] = params.
lam0 + 0.5*params.
fw - 0.5*params.
dlam;
184 rawSpectrum[2] = 1.0;
186 rawLambda[3] = params.
lam0 + 0.5*params.
fw + 0.5*params.
dlam;
187 rawSpectrum[3] = 0.0;
200 template<
typename _units>
203 typedef _units units;
204 typedef typename units::realT realT;
206 static const bool freq =
false;
214 static constexpr realT
fluxUnits =
static_cast<realT
>(1e7) / (
static_cast<realT
>(1e4)*
static_cast<realT
>(1e10));
216 static constexpr
const char * dataDirEnvVar =
"CALSPEC_DATADIR";
219 static std::string
fileName(
const std::string & name )
221 if(name ==
"alpha_lyr" || name ==
"vega")
return "alpha_lyr_stis_005.asc";
222 else if(name ==
"1740346")
return "1740346_nic_002.ascii";
223 else if(name ==
"sun" || name ==
"sun_reference")
return "sun_reference_stis.002.asc";
228 std::vector<realT> & rawSpectrum,
229 const std::string & path,
242 template<
typename _units>
245 typedef _units units;
246 typedef typename units::realT realT;
248 static const bool freq =
false;
256 static constexpr realT
fluxUnits =
static_cast<realT
>(1);
262 static std::string
fileName(
const std::string & spt )
269 std::vector<realT> & rawSpectrum,
270 const std::string & path,
288 template<
typename _units>
291 typedef _units units;
292 typedef typename units::realT realT;
294 static const bool freq =
false;
302 static constexpr realT
fluxUnits =
static_cast<realT
>(1);
308 static std::string
fileName(
const std::string & name )
310 if(name ==
"EPOXI")
return "cowan_2013_EPOXI_albedo.dat";
311 if(name ==
"Earthshine")
return "earthshine_epoxi_normalized.dat";
312 if(name ==
"RawEarthshine")
return "Earthshine/F7_opt_NIR_ES_data.txt";
314 mxError(
"earthAlbeo::fileName", MXE_INVALIDARG,
"name not recognized.");
321 std::vector<realT> & rawSpectrum,
322 const std::string & path,
337 template<
typename _units>
340 typedef _units units;
341 typedef typename units::realT realT;
343 static const bool freq =
false;
351 static constexpr realT
fluxUnits =
static_cast<realT
>(1);
357 static std::string
fileName(
const std::string & name )
359 if(name ==
"Venus")
return "venus_combined_albedo.dat";
361 mxError(
"venusAlbeo::fileName", MXE_INVALIDARG,
"name not recognized.");
368 std::vector<realT> & rawSpectrum,
369 const std::string & path,
int readColumns(const std::string &fname, arrTs &... arrays)
Read in columns from a text file.
void toLower(std::string &outstr, const std::string &instr)
Convert a string to all lower case.
A spectrum from the astroFilt filter library.
static constexpr realT fluxUnits
No conversion is performed on filter transmission.
static int readSpectrum(std::vector< realT > &rawLambda, std::vector< realT > &rawSpectrum, const std::string &path, const paramsT ¶ms)
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.
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 int 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.
static constexpr const char * dataDirEnvVar
The data directory environment variable name.
A spectrum from the HST calspec library.
static int 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.
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.
std::string paramsT
The calspec Spectra are parameterized by star name.
static constexpr realT wavelengthUnits
Convert from A to SI m.
static int 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.
static constexpr const char * dataDirEnvVar
The location is specified by the EARTHSHINE_DATADIR environment variable.
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 int 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 int 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.
static int 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 "venus".
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.
Unit specifications and conversions.