26 static const int NISM = 23;
35 static const double tnuHM96[
NHM96]={-8,-1.722735683,-0.351545683,-0.222905683,-0.133385683,
37 -0.127655683,-0.004575683,0.297544317,0.476753,0.476756,0.588704317,
38 0.661374317,1.500814317,2.245164317};
41 static const double fnuHM96[
NHM96]={-32.53342863,-19.9789,-20.4204,-20.4443,-20.5756,-20.7546,
42 -21.2796,-21.6256,-21.8404,-21.4823,-22.2102,-22.9263,-23.32,-24.2865};
65 const double RESETFACTOR = 0.98;
74 power = (fluxlog[1] - fluxlog[0] ) / log10( tnu[1].Ryd()/tnu[0].
Ryd() );
77 fluxlog[0] = fluxlog[1] + power * log10( tnu[0].Ryd()/tnu[1].Ryd() );
83 power = log10( fluxlog[1]/fluxlog[0]) / log10( tnu[1].Ryd()/tnu[0].Ryd() );
86 fluxlog[0] = log10(fluxlog[1]) + power * log10( tnu[0].Ryd()/tnu[1].Ryd() );
88 fluxlog[0] =
exp10(fluxlog[0]);
116 bool lgNoContinuum =
false,
130 fprintf(
ioQQQ,
" %ld is too many spectra entered. Increase LIMSPC\n Sorry.\n",
140 lgQuoteFound =
false;
144 bool lgKeyword =
false;
149 chFile =
"akn120.sed";
157 chFile =
"CrabDavidson.sed";
161 chFile =
"CrabHester.sed";
174 chFile =
"Rubin.sed";
180 chFile =
"Trapezium.sed";
203 bool lgHM05 =
false, lgHM12 =
false;
209 for( i=0; i <
NAGN; i++ )
230 fprintf(
ioQQQ,
" There must be a number for the break.\n Sorry.\n" );
237 fprintf(
ioQQQ,
" The break must be greater than 0.2 Ryd.\n Sorry.\n" );
244 ConBreak = 0.0912/ConBreak;
250 ConBreak =
exp10(ConBreak);
253 else if( ConBreak == 0. )
255 fprintf(
ioQQQ,
" An energy of 0 is not allowed.\n Sorry.\n" );
261 fprintf(
ioQQQ,
" The energy of the break cannot be greater than%10.2e Ryd.\n Sorry.\n",
268 fprintf(
ioQQQ,
" The energy of the break cannot be less than%10.2e Ryd.\n Sorry.\n",
295 for( j=0; j <
NHM96; j++ )
307 scale = log10(scale);
312 fprintf(
ioQQQ,
" %ld is too many continua entered. Increase LIMSPC\n Sorry.\n",
322 fprintf(
ioQQQ,
" This command has come between a previous ordered pair of continuum shape and luminosity commands.\n Reorder the commands to complete each continuum specification before starting another.\n" );
347 bool lgQuasar = p.
nMatch(
"QUAS");
348 if( lgHM12 && lgQuasar )
350 fprintf(
ioQQQ,
" The QUASAR option is not supported on the TABLE HM12 command.\n" );
362 scale = log10(scale);
364 UNUSED double zlow, zhigh;
365 int version = lgHM05 ? 2005 : 2012;
379 fprintf(
ioQQQ,
" %ld is too many continua entered. Increase LIMSPC\n Sorry.\n", p.
m_nqh );
388 fprintf(
ioQQQ,
" This command has come between a previous ordered pair of"
389 " continuum shape and luminosity commands.\n Reorder the commands"
390 " to complete each continuum specification before starting another.\n" );
415 scale = log10(scale);
420 if( Q < 14 || Q > 20 )
422 fprintf(
ioQQQ,
" Invalid value Q=%d, should be 14 <= Q <= 20.\n", Q );
426 UNUSED double zlow, zhigh;
440 fprintf(
ioQQQ,
" %ld is too many continua entered. Increase LIMSPC\n Sorry.\n", p.
m_nqh );
449 fprintf(
ioQQQ,
" This command has come between a previous ordered pair of"
450 " continuum shape and luminosity commands.\n Reorder the commands"
451 " to complete each continuum specification before starting another.\n" );
465 else if( p.
nMatch(
" ISM") )
472 for( i=6; i <
NISM; i++ )
486 if( scale > 0. && !p.
nMatch(
" LOG"))
487 scale = log10(scale);
492 fprintf(
ioQQQ,
" %4ld is too many continua entered. Increase LIMSPC\n Sorry.\n",
502 fprintf(
ioQQQ,
" This command has come between a previous ordered pair of continuum shape and luminosity commands.\n Reorder the commands to complete each continuum specification before starting another.\n" );
536 else if( p.
nMatch(
"DRAI") )
552 if( scale > 0. && !p.
nMatch(
" LOG") )
553 scale = log10(scale);
558 fprintf(
ioQQQ,
" %4ld is too many continua entered. Increase LIMSPC\n Sorry.\n",
568 fprintf(
ioQQQ,
" This command has come between a previous ordered pair of continuum shape and luminosity commands.\n Reorder the commands to complete each continuum specification before starting another.\n" );
604 else if( p.
nMatch(
"LINES") )
611 lgNoContinuum =
true;
615 fprintf(
ioQQQ,
" sorry, only one table line per input stream\n");
621 if( lgQuoteFound && chFile.length() > 0 )
631 fprintf(
ioQQQ,
"\n DISASTER PROBLEM ParseTable could not find "
633 fprintf(
ioQQQ,
" Please check the spelling of the file name and that it "
634 "is in either the local or data directory.\n\n");
644 else if( p.
nMatch(
"POWE") )
671 else if( brakmm == 0. )
680 else if( brakmm < 0. )
684 brakmm =
exp10(brakmm);
689 brakmm = RYDLAM / (1e4*brakmm);
696 " Check the order of parameters on this table power law command - the low-energy break of %f Ryd seems high to me.\n",
722 else if( brakxr == 0. )
730 brakxr =
exp10(brakxr);
741 if( brakmm >= brakxr )
743 fprintf(
ioQQQ,
" HELP!! The lower energy for the power law, %f, is greater than the upper energy, %f. This is not possible.\n Sorry.\n",
766 else if( p.
nMatch(
"READ") )
773 fprintf(
ioQQQ,
" Name of file must appear on TABLE READ.\n");
788 if( scale > 0. && !p.
nMatch(
" LOG"))
789 scale = log10(scale);
793 fprintf(
ioQQQ,
" %ld is too many continua entered. Increase LIMSPC\n Sorry.\n",
802 fprintf(
ioQQQ,
" This command has come between a previous ordered pair of continuum shape and luminosity commands.\n Reorder the commands to complete each continuum specification before starting another.\n" );
839 fprintf(
ioQQQ,
" The TABLE TLUSTY command is no longer supported.\n" );
840 fprintf(
ioQQQ,
" Please use TABLE STAR TLUSTY instead. See Hazy for details.\n" );
844 else if( p.
nMatch(
"SED") || lgKeyword )
851 fprintf(
ioQQQ,
"PROBLEM in TABLE SED: No quotes were found.\n The SED table file must be designated in quotes.\n" );
860 strcpy( chPath,
"SED" );
862 strcat( chPath, chFile.c_str() );
868 long int fileLength = 0;
869 const char *chEnergyUnits=NULL;
870 bool lgUnitsSet =
false, lgNuFnu =
false, lgExtrapolate =
false;
872 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioDATA ) != NULL )
882 if( chLine[0]==
'\n' || chLine[0]==
'\0' )
884 fprintf(
ioQQQ,
"PROBLEM in TABLE SED: Encountered unexpected empty line.\n");
890 strcpy( chLineCAPS , chLine );
894 if(
nMatch(
"UNIT", chLineCAPS ) != 0)
901 if(
nMatch(
"NUFN" , chLineCAPS ) != 0)
906 if(
nMatch(
"EXTRAP" , chLineCAPS ) != 0)
907 lgExtrapolate =
true;
914 fprintf(
ioQQQ,
"PROBLEM in TABLE SED: less than two data pairs found.\n");
918 vector<double> tnuInput(fileLength);
919 vector<double> tslopInput(fileLength);
923 long int entryNum = 0;
925 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioDATA ) != NULL )
934 tnuInput[entryNum] =
FFmtRead(chLine,&i,
sizeof(chLine),&lgEOL);
937 fprintf(
ioQQQ,
"PROBLEM in TABLE SED: freq/wavl and flux pairs must be entered."
938 " The first number was not found on this line:\n%s\n", chLine);
941 tslopInput[entryNum] =
FFmtRead(chLine,&i,
sizeof(chLine),&lgEOL);
947 fprintf(
ioQQQ,
"PROBLEM in TABLE SED: freq/wavl and flux pairs must be entered."
948 " The second number was not found on this line:\n%s\n", chLine);
952 if( tslopInput[entryNum] <= 0. )
954 fprintf(
ioQQQ,
"PROBLEM flux in TABLE SED file entry %li is not positive\nphoton energy %e where the value is %e.\n",
955 entryNum , tnuInput[entryNum] , tslopInput[entryNum] );
960 if( tnuInput[entryNum] <= 0. )
962 fprintf(
ioQQQ,
"PROBLEM freq/wavl in TABLE SED file entry %li is not positive\n"
963 "freq/wavl is %e.\n",
964 entryNum , tnuInput[entryNum] );
969 if( entryNum > 1 && (tnuInput[entryNum-2]-tnuInput[entryNum-1])*
970 (tnuInput[entryNum-1]-tnuInput[entryNum]) <= 0. )
972 fprintf(
ioQQQ,
"PROBLEM freq/wavl values in TABLE SED file must be in increasing or decreasing order\n");
973 fprintf(
ioQQQ,
"The following freq/wavl sequence is not monotonically changing:\n");
974 for(
long ij=entryNum-2; ij<=entryNum; ++ij )
979 tslopInput[entryNum] = log10(tslopInput[entryNum]);
983 ASSERT( entryNum == fileLength );
988 for(
long i=0; i < entryNum; i++ )
990 unitChange.
set(tnuInput[i], chEnergyUnits);
991 tnuInput[i] = unitChange.
Ryd();
998 for(
long i=0; i < entryNum; i++ )
999 tslopInput[i] -= log10(tnuInput[i]);
1002 if( tnuInput[0] < tnuInput[1] )
1004 for(
long i=0; i < entryNum; i++ )
1012 for(
long i=0; i < entryNum; i++ )
1029 else if( p.
nMatch(
"STAR") )
1031 char chMetalicity[5] = {
'\0'}, chODFNew[8], chVaryFlag[7] = {
'\0'};
1032 bool lgHCa =
false, lgHNi =
false;
1034 double Tlow = -1., Thigh = -1.;
1050 sprintf(chVaryFlag,
"%1ld-DIM",ndim);
1056 static const char table[][2][10] = {
1088 strncpy( chMetalicity,
"p00",
sizeof(chMetalicity) );
1089 for (i=0; i < (long)(
sizeof(table)/
sizeof(*table)); ++i)
1093 strncpy( chVaryFlag, table[i][0],
sizeof(chVaryFlag)-1 );
1094 strncpy( chMetalicity, table[i][1],
sizeof(chMetalicity)-1 );
1102 bool lgHalo = p.
nMatch(
"HALO");
1103 bool lgSolar = ( !lgHalo && strcmp( chMetalicity,
"p00" ) == 0 );
1108 bool lgList = p.
nMatch(
"LIST");
1117 for( nval=0; nval <
MDIM; nval++ )
1124 if( nval == 0 && !lgList )
1126 fprintf(
ioQQQ,
" The stellar temperature MUST be entered.\n" );
1134 val[0] =
exp10(val[0]);
1137 fprintf(
ioQQQ,
" DISASTER the log of the parameter was specified, "
1138 "but the numerical value is too large.\n Sorry.\n\n");
1145 nstar =
GridInterpolate(val,&nval,&ndim,chFile.c_str(),lgList,&Tlow,&Thigh);
1148 else if( p.
nMatch(
"ATLA") )
1155 strncpy( chODFNew,
"_odfnew",
sizeof(chODFNew) );
1157 strncpy( chODFNew,
"",
sizeof(chODFNew) );
1160 nstar =
AtlasInterpolate(val,&nval,&ndim,chMetalicity,chODFNew,lgList,&Tlow,&Thigh);
1163 else if( p.
nMatch(
"COST") )
1180 if( val[1] < 1. || val[1] > 7. )
1182 fprintf(
ioQQQ,
" The second number must be the id sequence number, 1 to 7.\n" );
1187 else if( p.
nMatch(
"ZAMS") )
1192 fprintf(
ioQQQ,
" A second number, the age of the star, must be present.\n" );
1196 else if( p.
nMatch(
" AGE") )
1201 fprintf(
ioQQQ,
" A second number, the ZAMS mass of the star, must be present.\n" );
1223 if( ! ( lgSolar || lgHalo ) )
1225 fprintf(
ioQQQ,
" Please choose SOLAR or HALO abundances.\n" );
1232 else if( p.
nMatch(
"KURU") )
1237 else if( p.
nMatch(
"MIHA") )
1242 else if( p.
nMatch(
"RAUC") )
1244 if( ! ( lgSolar || lgHalo ) )
1246 fprintf(
ioQQQ,
" Please choose SOLAR or HALO abundances.\n" );
1258 else if( p.
nMatch(
"HYDR") )
1262 else if( p.
nMatch(
"HELI") )
1266 else if( p.
nMatch(
"H+HE") )
1274 else if( p.
nMatch(
"CO W") )
1285 else if( p.
nMatch(
"TLUS") )
1293 else if( p.
nMatch(
"BSTA") )
1299 else if( p.
nMatch(
"OSTA") )
1307 fprintf(
ioQQQ,
" There must be a third key on TABLE STAR TLUSTY;" );
1308 fprintf(
ioQQQ,
" the options are OBSTAR, BSTAR, OSTAR.\n" );
1313 else if( p.
nMatch(
"WERN") )
1320 else if( p.
nMatch(
"WMBA") )
1329 fprintf(
ioQQQ,
" There must be a second key on TABLE STAR;" );
1330 fprintf(
ioQQQ,
" the options are ATLAS, KURUCZ, MIHALAS, RAUCH, WERNER, and WMBASIC.\n" );
1350 for( i=1; i < nval; i++ )
1370 else if( p.
nMatch(
"COST") )
1398 else if( p.
nMatch(
"KURU") )
1403 "TABLE STAR KURUCZ %f LOG" );
1406 else if( p.
nMatch(
"MIHA") )
1411 "TABLE STAR MIHALAS %f LOG" );
1414 else if( p.
nMatch(
"RAUC") )
1423 else if( p.
nMatch(
"HELI") )
1425 else if( p.
nMatch(
"H+HE") )
1429 else if( p.
nMatch(
"CO W") )
1434 if( ( lgHCa || lgHNi ) && ndim == 2 )
1460 else if( p.
nMatch(
"BSTA") )
1462 else if( p.
nMatch(
"OSTA") )
1473 else if( p.
nMatch(
"WERN") )
1478 "TABLE STAR WERNER %f LOG %f" );
1481 else if( p.
nMatch(
"WMBA") )
1486 "TABLE STAR WMBASIC %f LOG %f %f" );
1499 for( i=1; i < nval; i++ )
1513 fprintf(
ioQQQ,
" There MUST be a keyword on this line. The keys are:"
1514 "AGN, DRAINE, HM96, HM05, HM12, _ISM, LINES, POWERlaw, "
1515 "READ, SED, and STAR.\n Sorry.\n" );
1563 fprintf(
ioQQQ,
" Table for this continuum; TNU, TFAC, TSLOP\n" );
1651 tnuagn[0] =
Energy(1e-5);
1652 tnuagn[1] =
Energy(9.12e-3);
1653 tnuagn[2] =
Energy(.206);
1654 tnuagn[3] =
Energy(1.743);
1655 tnuagn[4] =
Energy(4.13);
1656 tnuagn[5] =
Energy(26.84);
1657 tnuagn[6] =
Energy(7353.);
1658 tnuagn[7] =
Energy(7.4e6);
1740 if( nLINE_TABLE == 0 )
1747 for(
long n=0; n < nLINE_TABLE; ++n )
1752 fprintf(
ioQQQ,
"lines_table in parse_table.cpp did not find line %s ",chLabel[n].c_str());
1760 fprintf(
ioQQQ ,
" BOTCHED MONITORS!!! Botched Monitors!!! lines_table could not find a total of %li lines\n\n", miss );
1789 fprintf(
ioQQQ,
" the input continuum file has been truncated.\n" );
1793 while( chLine[0] ==
'#' );
1797 sscanf( chLine,
"%ld", &version );
1801 " the input continuum file has the wrong version number, I expected %li and found %li.\n",
1808 double mesh_lo, mesh_hi;
1817 for(
unsigned int i=0; i <
NMD5; ++i )
1818 md5sum[i] = chLine[i];
1822 fprintf(
ioQQQ,
" the input continuum file has been truncated.\n" );
1830 sscanf( chLine,
"%x %x", &u.i[0], &u.i[1] );
1832 sscanf( chLine,
"%x %x", &u.i[1], &u.i[0] );
1837 fprintf(
ioQQQ,
" the input continuum file has been truncated.\n" );
1845 sscanf( chLine,
"%x %x", &u.i[0], &u.i[1] );
1847 sscanf( chLine,
"%x %x", &u.i[1], &u.i[0] );
1852 fprintf(
ioQQQ,
" the input continuum file has been truncated.\n" );
1860 fprintf(
ioQQQ,
" the input continuum file has an incompatible energy grid.\n" );
1868 sscanf( chLine,
"%x %x", &u.i[0], &u.i[1] );
1870 sscanf( chLine,
"%x %x", &u.i[1], &u.i[0] );
1875 fprintf(
ioQQQ,
" the input continuum file has been truncated.\n" );
1886 fprintf(
ioQQQ,
" the input continuum file has been truncated.\n" );
1893 sscanf( chLine,
"%ld", &nflux );
1897 fprintf(
ioQQQ,
" the input continuum file has been truncated.\n" );
1904 fprintf(
ioQQQ,
" the input continuum file has been truncated.\n" );
1914 sscanf( chLine,
"%lf%lf ", &help[0], &help[1] );
1918 fprintf(
ioQQQ,
"\n\nPROBLEM in TABLE READ continuum frequencies: point %li should "
1919 "have %e and has %e\n", (
unsigned long)i,
rfield.
anu(i), help[0] );
1944 fprintf(
ioQQQ,
" the input continuum file has the wrong number of points: %ld\n",
1953 fprintf(
ioQQQ,
" please recreate this file using the SAVE TRANSMITTED CONTINUUM command.\n" );
bool nMatch(const char *chKey) const
void prt_wl(FILE *ioOUT, realnum wl)
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
long RauchInterpolateHydr(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
static double tsldrn[NDRAINE]
const int FILENAME_PATH_LENGTH_2
NORETURN void TotalInsanity(void)
bool lgSphericalDilution[LIMSPC]
STATIC void ReadTable(const char *fnam)
long findline(const char *chLabel, realnum wavelength)
string mesh_md5sum() const
long CoStarInterpolate(double val[], long *nval, long *ndim, IntMode imode, bool lgHalo, bool lgList, double *val0_lo, double *val0_hi)
static const long VERSION_TRNCON
long TlustyInterpolate(double val[], long *nval, long *ndim, tl_grid tlg, const char *chMetalicity, bool lgList, double *Tlow, double *Thigh)
void ParseTable(Parser &p)
long nMatch(const char *chKey, const char *chCard)
long HaardtMadauInterpolate(double val, int version, bool lgQuasar, double *zlow, double *zhigh)
static const double tnuHM96[NHM96]
int GetQuote(string &chLabel)
realnum varang[LIMPAR][2]
static double tnuism[NISM]
bool fp_equal_tol(sys_float x, sys_float y, sys_float tol)
double TableRadius[LIMSPC]
long RauchInterpolateHCa(double val[], long *nval, long *ndim, bool lgHalo, bool lgList, double *Tlow, double *Thigh)
bool nMatchErase(const char *chKey)
vector< Energy > tNu[LIMSPC]
vector< realnum > tFluxLog[LIMSPC]
static double tnudrn[NDRAINE]
long int cdGetLineList(const char chFile[], vector< string > &chLabels, vector< realnum > &wl)
char chVarFmt[LIMPAR][FILENAME_PATH_LENGTH_2]
long WMBASICInterpolate(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
realnum vparm[LIMEXT][LIMPAR]
vector< realnum > tslop[LIMSPC]
static realnum tslagn[NAGN]
double anu(size_t i) const
static string chLINE_LIST
long KhaireSrianandInterpolate(double val, int Q, double *zlow, double *zhigh)
size_t ipointC(double anu) const
long RauchInterpolateHpHe(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
long MihalasInterpolate(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
static Energy tnuagn[NAGN]
Illuminate::IlluminationType Illumination[LIMSPC]
const int INPUT_LINE_LENGTH
NORETURN void NoNumb(const char *chDesc) const
static const double fnuHM96[NHM96]
STATIC void ZeroContin(void)
long RauchInterpolateCOWD(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
const char * StandardEnergyUnit(const char *chCard)
long WernerInterpolate(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
#define DEBUG_ENTRY(funcname)
static const unsigned int NMD5
long RauchInterpolateHelium(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
long GridInterpolate(double val[], long *nval, long *ndim, const char *FileName, bool lgList, double *Tlow, double *Thigh)
int fprintf(const Output &stream, const char *format,...)
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
STATIC void resetBltin(Energy *tnu, realnum *fluxlog, bool lgLog)
long Kurucz79Interpolate(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
long RauchInterpolatePG1159(double val[], long *nval, long *ndim, bool lgList, double *Tlow, double *Thigh)
long RauchInterpolateHNi(double val[], long *nval, long *ndim, bool lgHalo, bool lgList, double *Tlow, double *Thigh)
long AtlasInterpolate(double val[], long *nval, long *ndim, const char *chMetalicity, const char *chODFNew, bool lgList, double *Tlow, double *Thigh)
static double fnuism[NISM]
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)