8 #include "../math/gslInterpolator.hpp"
12 #ifndef mx_astro_stars_hpp
13 #define mx_astro_stars_hpp
15 #include "../ioutils/stringUtils.hpp"
16 #include "../ioutils/readColumns.hpp"
32 template<
typename realT=
float>
79 if(spType.size() < 2)
return -1000;
80 if(!isdigit(spType[1]))
return -1000;
83 while( i < spType.size() && ( isdigit(spType[i]) || spType[i] ==
'.')) ++i;
85 std::string subType = spType.substr(1, i-1);
87 num += ioutils::convertFromString<realT>(subType);
89 if(spType.size() == i)
return num;
90 if(spType[i] ==
'V')
return num;
105 template<
typename realT>
165 void findMinMax( std::vector<double> & seq,
168 std::vector<double> & ref
171 if(seq.size()!=ref.size())
173 std::cerr <<
"size mismatch\n";
180 for(n=0; n < seq.size();++n)
182 if(seq[n] != -99)
break;
185 if(n >= seq.size()-1)
195 for(;n<seq.size()-1;++n)
197 if(seq[n+1] == -99)
break;
202 for(;n<seq.size();++n)
211 #include "mamajek.inc"
250 if( numType < m_minT || numType >
m_maxT)
263 realT
Teff(
const std::string & spType )
275 if( numType < m_minRad || numType >
m_maxRad)
288 realT
radius(
const std::string & spType )
300 if( numType < m_minL || numType >
m_maxL)
313 realT
logL(
const std::string & spType )
323 realT
Mv( realT numType )
325 if( numType < m_minMv || numType >
m_maxMv)
338 realT
Mv(
const std::string & spType )
350 if( numType < m_minVRc || numType >
m_maxVRc)
363 realT
V_Rc(
const std::string & spType )
375 if( numType < m_minVIc || numType >
m_maxVIc)
388 realT
V_Ic(
const std::string & spType )
400 if( numType < m_minVKs || numType >
m_maxVKs)
413 realT
V_Ks(
const std::string & spType )
423 realT
J_H( realT numType )
425 if( numType < m_minJH || numType >
m_maxJH)
438 realT
J_H(
const std::string & spType )
450 if( numType < m_minHKs || numType >
m_maxHKs)
463 realT
H_Ks(
const std::string & spType )
472 realT spTFromTeff( realT
Teff )
485 namespace maintenance
495 std::vector<std::string> SpT;
496 std::vector<double> Teff;
497 std::vector<double> logT;
498 std::vector<double> logL;
499 std::vector<double> Mbol;
500 std::vector<double> BCv;
501 std::vector<double> Mv;
502 std::vector<double> B__V;
503 std::vector<double> Bt__Vt;
504 std::vector<double> G__V;
505 std::vector<double> Bp__Rp;
506 std::vector<double> G__Rp;
507 std::vector<double> M_G;
508 std::vector<double> b__y;
509 std::vector<double> U__B;
510 std::vector<double> V__Rc;
511 std::vector<double> V__Ic;
512 std::vector<double> V__Ks;
513 std::vector<double> J__H;
514 std::vector<double> H__Ks;
515 std::vector<double> Ks__W1;
516 std::vector<double> W1__W2;
517 std::vector<double> W1__W3;
518 std::vector<double> W1__W4;
519 std::vector<double> M_J;
520 std::vector<double> M_Ks;
521 std::vector<double> i__z;
522 std::vector<double> z__Y;
523 std::vector<double> R_Rsun;
524 std::vector<double> Msun;
526 ioutils::readColumns(fn,SpT,Teff,logT,logL,Mbol,BCv,Mv,B__V,Bt__Vt,G__V,Bp__Rp,G__Rp,M_G,b__y,U__B,V__Rc,V__Ic,V__Ks,J__H,H__Ks,Ks__W1,W1__W2,W1__W3,
527 W1__W4,M_J,M_Ks,i__z,z__Y,R_Rsun, Msun);
529 std::cout <<
"//" << fn <<
"\n";
530 std::cout <<
" m_numTypes = {" <<
numSpType(SpT[0]);
531 for(
int n=1;n<SpT.size();++n) std::cout <<
',' <<
numSpType(SpT[n]);
534 std::cout <<
" m_Teffs = {" << Teff[0];
535 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << Teff[n];
538 std::cout <<
" m_logLs = {" << logL[0];
539 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << logL[n];
542 std::cout <<
" m_rads = {" << R_Rsun[0];
543 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << R_Rsun[n];
546 std::cout <<
" m_masses = {" << Msun[0];
547 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << Msun[n];
550 std::cout <<
" m_Mvs = {" << Mv[0];
551 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << Mv[n];
554 std::cout <<
" m_V_Rcs = {" << V__Rc[0];
555 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << V__Rc[n];
558 std::cout <<
" m_V_Ics = {" << V__Ic[0];
559 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << V__Ic[n];
562 std::cout <<
" m_V_Kss = {" << V__Ks[0];
563 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << V__Ks[n];
566 std::cout <<
" m_J_Hs = {" << J__H[0];
567 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << J__H[n];
570 std::cout <<
" m_H_Kss = {" << H__Ks[0];
571 for(
int n=1;n<SpT.size();++n) std::cout <<
',' << H__Ks[n];
Class to manage interpolation using the GSL interpolation library.
int readColumns(const std::string &fname, arrTs &... arrays)
Read in columns from a text file.
realT numSpType(std::string spType)
Parse a main sequence spectral type string into a numeric code.
void toUpper(std::string &outstr, const std::string &instr)
Convert a string to all upper case.
void removeWhiteSpace(std::string &outstr, const std::string &instr)
Remove all white space from a string.
void makeMSTable(const std::string &fn)
Read in the main sequence table of Mamajek, and construct the vectors for input into the mainSequence...
Provide various characteristics of main sequence stars according to their spectral type.
math::gslInterpolator< math::gsl_interp_linear< double > > interpVKs
The interpolator for V-Ks color.
std::vector< double > m_TeffsR
The effective temperatures from the sequence, reveresed order.
realT V_Ic(realT numType)
Get the interpolated absolute V-Ic color.
realT radius(const std::string &spType)
Get the interpolated radius.
double m_minSpTfmT
The minimum numeric spectral type for effective Temperature.
realT V_Rc(realT numType)
Get the interpolated absolute V-Rc color.
realT H_Ks(const std::string &spType)
Get the interpolated absolute H-Ks color.
double m_maxT
The maximum numeric spectral type for effective Temperature.
double m_minRad
The minimum numeric spectral type for effective Temperature.
double m_maxMv
The maximum numeric spectral type for absolute V magnitude.
realT J_H(const std::string &spType)
Get the interpolated absolute J-H color.
std::vector< double > m_V_Ics
The V-Ic colors from the sequence.
realT logL(realT numType)
Get the interpolated log of luminosity.
math::gslInterpolator< math::gsl_interp_linear< double > > interpVIc
The interpolator for V-Ic color.
double m_maxL
The maximum numeric spectral type for log luminosity.
double m_minL
The minimum numeric spectral type for log luminosity.
std::vector< double > m_J_Hs
The J-H colors from the sequence.
double m_minVKs
The minimum numeric spectral type for V-Ks color.
realT Teff(const std::string &spType)
Get the interpolated effective temperature.
std::vector< double > m_numTypes
The numeric spectral type codes from the sequence.
realT radius(realT numType)
Get the interpolated radius.
std::vector< double > m_numTypesR
The numeric spectral type codes from the sequence, in reversed order.
realT V_Ic(const std::string &spType)
Get the interpolated absolute V-Ic color.
double m_maxVIc
The maximum numeric spectral type for V-Ic color.
double m_minJH
The minimum numeric spectral type for J-H color.
realT V_Ks(const std::string &spType)
Get the interpolated absolute V-Ks color.
math::gslInterpolator< math::gsl_interp_linear< double > > interpSpTfmT
The interpolator for effective Temperature.
std::vector< double > m_Teffs
The effective temperatures from the sequence.
double m_maxJH
The maximum numeric spectral type for J-H color.
double m_minMv
The minimum numeric spectral type for absolute V magnitude.
std::vector< double > m_Mvs
The absolute V magnitudes from the sequence.
std::vector< double > m_V_Kss
The V-Ks colors from the sequence.
realT J_H(realT numType)
Get the interpolated absolute J-H color.
math::gslInterpolator< math::gsl_interp_linear< double > > interpRad
The interpolator for effective Temperature.
realT V_Rc(const std::string &spType)
Get the interpolated absolute V-Rc color.
double m_minHKs
The minimum numeric spectral type for H-Ks color.
std::vector< double > m_logLs
The log10 luminosities from the sequence.
math::gslInterpolator< math::gsl_interp_linear< double > > interpVRc
The interpolator for V-Rc color.
std::vector< double > m_V_Rcs
The V-Rc colors from the sequence.
realT Mv(realT numType)
Get the interpolated absolute V magnitude.
math::gslInterpolator< math::gsl_interp_linear< double > > interpHKs
The interpolator for H-Ks color.
math::gslInterpolator< math::gsl_interp_linear< double > > interpMv
The interpolator for absolute V magnitude.
realT logL(const std::string &spType)
Get the interpolated log of luminosity.
realT H_Ks(realT numType)
Get the interpolated absolute H-Ks color.
double m_maxRad
The maximum numeric spectral type for effective Temperature.
math::gslInterpolator< math::gsl_interp_linear< double > > interpL
The interpolator for log luminosity.
realT Mv(const std::string &spType)
Get the interpolated absolute V magnitude.
double m_maxVKs
The maximum numeric spectral type for V-Ks color.
math::gslInterpolator< math::gsl_interp_linear< double > > interpJH
The interpolator for J-H color.
double m_maxHKs
The maximum numeric spectral type for H-Ks color.
double m_minVRc
The minimum numeric spectral type for V-Rc color.
std::vector< double > m_H_Kss
The H-Ks colors from the sequence.
double m_maxSpTfmT
The maximum numeric spectral type for effective Temperature.
double m_minT
The minimum numeric spectral type for effective Temperature.
math::gslInterpolator< math::gsl_interp_linear< double > > interpT
The interpolator for effective Temperature.
realT V_Ks(realT numType)
Get the interpolated absolute V-Ks color.
double m_maxVRc
The maximum numeric spectral type for V-Rc color.
realT Teff(realT numType)
Get the interpolated effective temperature.
std::vector< double > m_rads
The radii from the sequence.
std::vector< double > m_masses
The masses from the sequence.
double m_minVIc
The minimum numeric spectral type for V-Ic color.
Unit specifications and conversions.