51 vector<genericState> v =
matchGeneric( speciesLabel.c_str(), false );
54 fprintf(
ioQQQ,
"Error: Incorrect number of matches (%d) for species '%s'\n",
55 int(v.size()), speciesLabel.c_str() );
82 return (ibin < 0 || ibin >=
nBins) ?
false :
true;
85 virtual void sumBand(
double *sumOutward,
double *sumInward )
const = 0;
87 void accumulate(
bool lgReset,
double dVeffAper );
89 double getInten(
const long ibin,
const int ipContType )
const;
101 for(
long ibin = 0; ibin <
nBins; ibin++ )
109 vector<double> sumOutward(
nBins ), sumInward(
nBins );
113 for(
long ibin = 0; ibin <
nBins; ibin++ )
161 void setup(
string &
label,
double wlo,
double whi,
long nb );
163 void sumBand(
double *sumOutward,
double *sumInward )
const;
170 "out of range (0, %ld)\n",
182 double mid_wl = 0.5 * (
wl[ ibin ] +
wl[ ibin+1 ] );
201 for(
long ibin = 0; ibin <
nBins+1; ++ibin )
217 for(
long i=0; i<
nBins; ++i )
226 if(
species.sp->lines == NULL )
229 "WARNING: Species '%s' does not have any data for 'save species continuum'.\n",
234 double log_step_inv = 1. /
log_step;
237 tr !=
species.sp->lines->end(); ++tr )
239 if( (*tr).WLAng() <
wlLo || (*tr).WLAng() >
wlHi )
242 double bin = (log10( (*tr).WLAng() ) -
log_wlLo) * log_step_inv;
243 long ibin = long( bin );
248 enum { DEBUG_BAND =
false };
249 if( DEBUG_BAND && (*tr).Emis().xIntensity() > 0. )
252 "WLAng= %g\t wl(i)= %g\t wl(i+1)= %g\t "
253 "bin= %g\t ibin= %ld\t inten= %g\t "
256 wl[ibin],
wl[ibin+1],
258 (*tr).Emis().xIntensity(),
259 (*tr).Emis().FracInwd() );
263 sumOutward[ ibin ] += (*tr).Emis().xIntensity() *
264 MAX2( 0., 1-(*tr).Emis().FracInwd() );
265 sumInward[ ibin ] += (*tr).Emis().xIntensity() *
266 (*tr).Emis().FracInwd();
274 vector<pseudo_cont>::iterator &this_it )
280 for( vector<pseudo_cont>::iterator it =
PseudoCont.begin();
286 if( speciesLabel == (*it).label() )
315 double &wlLo,
double &wlHi,
long &nBins )
319 wlLo = pseudoContDef.
wlLo;
320 wlHi = pseudoContDef.
wlHi;
321 nBins = pseudoContDef.
nBins;
377 for( vector<pseudo_cont>::iterator it =
PseudoCont.begin();
390 long ipContType =
UNSET;
391 if( strcmp( saveSpec,
"CONi" ) == 0 )
395 else if( strcmp( saveSpec,
"CONo" ) == 0 )
399 else if( strcmp( saveSpec,
"CONt" ) == 0 )
410 vector<pseudo_cont>::iterator it;
415 "Error: Species continuum data unmatched for species '%s'\n",
416 speciesLabel.c_str() );
429 "#%s ", speciesLabel.c_str() );
445 ": Energy\t%s Int[erg cm-2 s-1]\n",
448 for(
long ibin = 0; ibin < (*it).bins(); ibin++ )
454 (*it).getWl( ibin ) );
463 for(
long ibin = 0; ibin < (*it).bins(); ibin++ )
466 (*it).getInten( ibin, ipContType ));
467 if( ibin < (*it).bins()-1 )
481 "#%s ", speciesLabel.c_str() );
483 "wl\ttotal\tinward\toutward\n" );
487 for(
long ibin = 0; ibin < (*it).bins(); ibin++ )
490 (*it).getWl( ibin ) );
492 (*it).getInten( ibin,
TOTAL ) );
494 (*it).getInten( ibin,
INWARD ) );
496 (*it).getInten( ibin,
OUTWARD ) );
531 return double(
prt_wl[ iband ] );
535 return wlLo[ iband ];
539 return wlHi[ iband ];
566 fprintf(
ioQQQ,
" BandsCreate could not read first line of %s.\n",
572 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioDATA ) != NULL )
576 if( chLine[0] !=
'#')
581 if( fseek( ioDATA , 0 , SEEK_SET ) != 0 )
589 wlLo.resize( nBands );
590 wlHi.resize( nBands );
597 fprintf(
ioQQQ,
" BandsCreate could not read first line of %s.\n",
603 const long int iyr = 9, imo=6 , idy = 11;
604 long iyrread, imoread , idyread;
606 iyrread = (long)
FFmtRead(chLine,&i,
sizeof(chLine),&lgEOL);
607 imoread = (long)
FFmtRead(chLine,&i,
sizeof(chLine),&lgEOL);
608 idyread = (long)
FFmtRead(chLine,&i,
sizeof(chLine),&lgEOL);
610 if(( iyrread != iyr ) ||
611 ( imoread != imo ) ||
615 " PROBLEM BandsCreate: the version of %s is not the "
616 "current version.\n",
619 " BandsCreate: I expected the magic numbers %li %li %li "
620 "but found %li %li %li.\n",
621 iyr, imo , idy ,iyrread, imoread , idyread );
629 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioDATA ) != NULL )
635 if( chLine[0] !=
'#')
641 fprintf(
ioQQQ,
" There should have been a number on this band column 1. Sorry.\n" );
648 fprintf(
ioQQQ,
" There should have been a number on this band column 2. Sorry.\n" );
655 fprintf(
ioQQQ,
" There should have been a number on this band column 3. Sorry.\n" );
666 for(
long i=0; i <
nBands; ++i )
671 fprintf(
ioQQQ,
" band %li has none positive entry.\n",i );
677 fprintf(
ioQQQ,
" band %li has improper bounds.\n" ,i );
692 vector<bands_file>::iterator &this_it )
696 this_it =
Bands.end();
697 for( vector<bands_file>::iterator it =
Bands.begin();
698 it !=
Bands.end(); ++it )
700 if( (*it).bandFilename() == filename )
712 vector<bands_file>::iterator it;
715 if( it ==
Bands.end() )
718 b_tmp.
setup( filename );
720 Bands.push_back( b_tmp );
738 void setup(
const string &splab, vector<bands_file>::iterator it )
745 nBins = (*bands_it).get_nBands();
749 for(
long iband = 0; iband <
nBins; ++iband )
757 string spectralLabel;
761 comment = spectralLabel +
" emission in bands defined in " +
762 (*bands_it).bandFilename();
772 "out of range (0, %ld)\n",
775 (*bands_it).bandFilename().c_str(),
781 void sumBand(
double *sumOutward,
double *sumInward )
const;
790 return (*bands_it).getWl( iband );
795 return (*bands_it).getWlLo( iband );
800 return (*bands_it).getWlHi( iband );
808 for(
long i=0; i<
nBins; ++i )
817 if(
species.sp->lines == NULL )
820 "WARNING: Species '%s' does not have any data for 'save species bands'.\n",
826 tr !=
species.sp->lines->end(); ++tr )
828 for(
long iband = 0; iband <
nBins; ++iband )
830 if( (*tr).WLAng() >=
getWlLo( iband ) &&
831 (*tr).WLAng() <
getWlHi( iband ) )
833 sumOutward[ iband ] += (*tr).Emis().xIntensity() *
834 MAX2( 0., 1-(*tr).Emis().FracInwd() );
835 sumInward[ iband ] += (*tr).Emis().xIntensity() *
836 (*tr).Emis().FracInwd();
846 for(
long iband = 0; iband <
nBins; iband++ )
854 (
" total " +
comment ).c_str() );
859 (
" inward " +
comment ).c_str() );
867 vector<species_bands>::iterator &this_it )
873 for( vector<species_bands>::iterator it =
SpecBands.begin();
876 if( speciesLabel == (*it).label() &&
877 fileBands == (*it).bandFilename() )
895 for( vector<save_species_bands>::iterator it =
save.
specBands.begin();
901 for( vector<save_species_bands>::iterator it =
save.
specBands.begin();
904 vector<bands_file>::iterator b_it;
908 sb_tmp.
setup( (*it).speciesLabel, b_it );
919 for( vector<species_bands>::iterator it =
SpecBands.begin();
931 const string &fileBands )
935 vector<species_bands>::iterator it;
940 "Error: Species band data unmatched for species "
941 "'%s' and bands from file '%s'\n",
942 speciesLabel.c_str(), fileBands.c_str() );
953 const int ipEmType = 0;
955 double tot_emiss, inwd_emiss;
957 for(
long iband = 0; iband < (*it).bins(); iband++ )
965 ASSERT( tot_emiss >= 0. && inwd_emiss >= 0. &&
966 tot_emiss - inwd_emiss >= 0. );
972 tot_emiss - inwd_emiss );
realnum punarg[LIMPUN][3]
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
realnum getWlLo(const long iband) const
static vector< pseudo_cont > PseudoCont
const int FILENAME_PATH_LENGTH_2
NORETURN void TotalInsanity(void)
static vector< bands_file > Bands
long findline(const char *chLabel, realnum wavelength)
vector< save_species_bands > specBands
double getInten(const long ibin, const int ipContType) const
void lindst(double xEmiss, realnum wavelength, const char *chLab, long int ipnt, char chInfo, bool lgOutToo, const char *chComment)
string bandFilename() const
STATIC void getPseudoWlRange(const string &speciesLabel, double &wlLo, double &wlHi, long &nBins)
realnum getWlLo(const long iband) const
void setup(const string &fname)
void SaveSpeciesBands(const long ipPun, const string &speciesLabel, const string &fileBands)
void SpeciesPseudoContCreate()
vector< genericState > matchGeneric(const char *chLabel, bool lgValidate)
void getSpecies(const string &speciesLabel, genericState &species)
t_pseudo_cont pseudoContDef
string bandFilename() const
realnum getWl(const long ibin) const
void PntForLine(double wavelength, const char *chLabel, long int *ipnt)
STATIC void PseudoContCreate(long ips)
bool check_index(const long ibin) const
void check_index_fatal(const long iband) const
STATIC string getIntenTypeStr(const int ipContType)
void setup(const string &splab, vector< bands_file >::iterator it)
void sumBand(double *sumOutward, double *sumInward) const
char chSaveArgs[LIMPUN][5]
realnum getWlHi(const long iband) const
STATIC long resolveSpecType(const char *saveSpec)
void chemical_to_spectral(const string chLabelChem, string &chLabelSpec)
STATIC void addBandsFile(const string &filename)
virtual void sumBand(double *sumOutward, double *sumInward) const =0
virtual realnum getWl(const long ibin) const =0
double AnuUnit(realnum energy)
SaveParams params[LIMPUN]
realnum getWl(const long iband) const
vector< realnum > inten_inward
void SpeciesBandsCreate()
vector< string > contSaveSpeciesLabel
void SaveHeaderDone(int ipPun)
double density(const genericState &gs)
STATIC void getPseudoIndex(const string &speciesLabel, vector< pseudo_cont >::iterator &this_it)
STATIC void findBandsFile(const string &filename, vector< bands_file >::iterator &this_it)
#define DEBUG_ENTRY(funcname)
void accumulate(bool lgReset, double dVeffAper)
vector< bands_file >::iterator bands_it
int fprintf(const Output &stream, const char *format,...)
STATIC void getSpecBandsIndex(const string &speciesLabel, const string &fileBands, vector< species_bands >::iterator &this_it)
static vector< species_bands > SpecBands
void check_index_fatal(const long ibin) const
STATIC long getAdjPseudoIndex(const string &speciesLabel)
void SaveSpeciesPseudoCont(const long ipPun, const string &speciesLabel)
realnum getWlHi(const long iband) const
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
void SpeciesPseudoContAccum()
void setup(string &label, double wlo, double whi, long nb)
void sumBand(double *sumOutward, double *sumInward) const
realnum getWl(const long iband) const
bool lgSaveHeader(int ipPun) const
vector< realnum > inten_outward
vector< adjPseudoCont > setPseudoCont
virtual void check_index_fatal(const long ibin) const =0
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)