12#ifndef mx_astro_stars_hpp
13#define mx_astro_stars_hpp
34template <
typename realT =
float>
80 if( spType.size() < 2 )
82 if( !isdigit( spType[1] ) )
86 while( i < spType.size() && ( isdigit( spType[i] ) || spType[i] ==
'.' ) )
89 std::string subType = spType.substr( 1, i - 1 );
93 if( spType.size() == i )
95 if( spType[i] ==
'V' )
111template <
typename realT>
170 void findMinMax( std::vector<double> &seq,
double &min,
double &max, std::vector<double> &ref )
172 if( seq.size() != ref.size() )
174 std::cerr <<
"size mismatch\n";
181 for( n = 0; n < seq.size(); ++n )
187 if( n >= seq.size() - 1 )
196 for( ; n < seq.size() - 1; ++n )
198 if( seq[n + 1] == -99 )
204 for( ; n < seq.size(); ++n )
212#include "mamajek.inc"
251 if( numType < m_minT || numType >
m_maxT )
264 realT
Teff(
const std::string &spType )
276 if( numType < m_minRad || numType >
m_maxRad )
289 realT
radius(
const std::string &spType )
301 if( numType < m_minL || numType >
m_maxL )
314 realT
logL(
const std::string &spType )
324 realT
Mv( realT numType )
326 if( numType < m_minMv || numType >
m_maxMv )
339 realT
Mv(
const std::string &spType )
351 if( numType < m_minVRc || numType >
m_maxVRc )
364 realT
V_Rc(
const std::string &spType )
376 if( numType < m_minVIc || numType >
m_maxVIc )
389 realT
V_Ic(
const std::string &spType )
401 if( numType < m_minVKs || numType >
m_maxVKs )
414 realT
V_Ks(
const std::string &spType )
424 realT
J_H( realT numType )
426 if( numType < m_minJH || numType >
m_maxJH )
439 realT
J_H(
const std::string &spType )
451 if( numType < m_minHKs || numType >
m_maxHKs )
464 realT
H_Ks(
const std::string &spType )
473 realT spTFromTeff( realT
Teff )
493 std::vector<std::string> SpT;
494 std::vector<double> Teff;
495 std::vector<double> logT;
496 std::vector<double> logL;
497 std::vector<double> Mbol;
498 std::vector<double> BCv;
499 std::vector<double> Mv;
500 std::vector<double> B__V;
501 std::vector<double> Bt__Vt;
502 std::vector<double> G__V;
503 std::vector<double> Bp__Rp;
504 std::vector<double> G__Rp;
505 std::vector<double> M_G;
506 std::vector<double> b__y;
507 std::vector<double> U__B;
508 std::vector<double> V__Rc;
509 std::vector<double> V__Ic;
510 std::vector<double> V__Ks;
511 std::vector<double> J__H;
512 std::vector<double> H__Ks;
513 std::vector<double> Ks__W1;
514 std::vector<double> W1__W2;
515 std::vector<double> W1__W3;
516 std::vector<double> W1__W4;
517 std::vector<double> M_J;
518 std::vector<double> M_Ks;
519 std::vector<double> i__z;
520 std::vector<double> z__Y;
521 std::vector<double> R_Rsun;
522 std::vector<double> Msun;
556 std::cout <<
"//" << fn <<
"\n";
557 std::cout <<
" m_numTypes = {" <<
numSpType( SpT[0] );
558 for(
int n = 1; n < SpT.size(); ++n )
562 std::cout <<
" m_Teffs = {" << Teff[0];
563 for(
int n = 1; n < SpT.size(); ++n )
564 std::cout <<
',' << Teff[n];
567 std::cout <<
" m_logLs = {" << logL[0];
568 for(
int n = 1; n < SpT.size(); ++n )
569 std::cout <<
',' << logL[n];
572 std::cout <<
" m_rads = {" << R_Rsun[0];
573 for(
int n = 1; n < SpT.size(); ++n )
574 std::cout <<
',' << R_Rsun[n];
577 std::cout <<
" m_masses = {" << Msun[0];
578 for(
int n = 1; n < SpT.size(); ++n )
579 std::cout <<
',' << Msun[n];
582 std::cout <<
" m_Mvs = {" << Mv[0];
583 for(
int n = 1; n < SpT.size(); ++n )
584 std::cout <<
',' << Mv[n];
587 std::cout <<
" m_V_Rcs = {" << V__Rc[0];
588 for(
int n = 1; n < SpT.size(); ++n )
589 std::cout <<
',' << V__Rc[n];
592 std::cout <<
" m_V_Ics = {" << V__Ic[0];
593 for(
int n = 1; n < SpT.size(); ++n )
594 std::cout <<
',' << V__Ic[n];
597 std::cout <<
" m_V_Kss = {" << V__Ks[0];
598 for(
int n = 1; n < SpT.size(); ++n )
599 std::cout <<
',' << V__Ks[n];
602 std::cout <<
" m_J_Hs = {" << J__H[0];
603 for(
int n = 1; n < SpT.size(); ++n )
604 std::cout <<
',' << J__H[n];
607 std::cout <<
" m_H_Kss = {" << H__Ks[0];
608 for(
int n = 1; n < SpT.size(); ++n )
609 std::cout <<
',' << H__Ks[n];
Class to manage interpolation using the GSL interpolation library.
error_t 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.
mx::error_t 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.
typeT convertFromString(const std::string &str, error_t *errc=nullptr)
Convert a string to a numerical value.
Class for managing 1-D interpolation using the GNU Scientific Library.
A utility to read in columns from a text file.
void makeMSTable(const std::string &fn)
Read in the main sequence table of Mamajek, and construct the vectors for input into the mainSequence...
Utilities for working with strings.
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.