00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00028 #ifndef absorption_h
00029 #define absorption_h
00030
00031 #include <stdexcept>
00032 #include "matpackI.h"
00033 #include "array.h"
00034 #include "mystring.h"
00035 #include "make_array.h"
00036
00039 typedef void (*lsf_type)(Vector&,
00040 Vector&,
00041 Numeric,
00042 Numeric,
00043 Numeric,
00044 VectorView,
00045 const Index);
00046
00052 class LineshapeRecord{
00053 public:
00054
00056 LineshapeRecord() : mname(),
00057 mdescription(),
00058 mfunction()
00059 { }
00060
00062 LineshapeRecord(const String& name,
00063 const String& description,
00064 lsf_type function)
00065 : mname(name),
00066 mdescription(description),
00067 mfunction(function)
00068 { }
00070 const String& Name() const { return mname; }
00072 const String& Description() const { return mdescription; }
00074 lsf_type Function() const { return mfunction; }
00075 private:
00076 String mname;
00077 String mdescription;
00078 lsf_type mfunction;
00079
00080 };
00081
00084 typedef void (*lsnf_type)(Vector&,
00085 Numeric,
00086 VectorView,
00087 const Numeric,
00088 const Index);
00089
00096 class LineshapeNormRecord{
00097 public:
00098
00100 LineshapeNormRecord() : mname(),
00101 mdescription(),
00102 mfunction()
00103 { }
00104
00106 LineshapeNormRecord(const String& name,
00107 const String& description,
00108 lsnf_type function)
00109 : mname(name),
00110 mdescription(description),
00111 mfunction(function)
00112 { }
00114 const String& Name() const { return mname; }
00116 const String& Description() const { return mdescription; }
00118 lsnf_type Function() const { return mfunction; }
00119 private:
00120 String mname;
00121 String mdescription;
00122 lsnf_type mfunction;
00123 };
00124
00130 class LineshapeSpec{
00131 public:
00132
00134 LineshapeSpec() : mind_ls(-1),
00135 mind_lsn(-1),
00136 mcutoff(0.)
00137 { }
00138
00140 LineshapeSpec(const Index& ind_ls,
00141 const Index& ind_lsn,
00142 const Numeric& cutoff)
00143 : mind_ls(ind_ls),
00144 mind_lsn(ind_lsn),
00145 mcutoff(cutoff)
00146 { }
00147
00149 const Index& Ind_ls() const { return mind_ls; }
00151 void SetInd_ls( Index ind_ls ) { mind_ls = ind_ls; }
00152
00154 const Index& Ind_lsn() const { return mind_lsn; }
00156 void SetInd_lsn( Index ind_lsn ) { mind_lsn = ind_lsn; }
00157
00161 const Numeric& Cutoff() const { return mcutoff; }
00163 void SetCutoff( Numeric cutoff ) { mcutoff = cutoff; }
00164 private:
00165 Index mind_ls;
00166 Index mind_lsn;
00167 Numeric mcutoff;
00168 };
00169
00170 ostream& operator<< (ostream& os, const LineshapeSpec& lsspec);
00171
00174 typedef Array<LineshapeSpec> ArrayOfLineshapeSpec;
00175
00176
00177
00180 class IsotopeRecord{
00181 public:
00182
00184 IsotopeRecord() : mname(),
00185 mabundance(0.),
00186 mmass(0.),
00187 mmytrantag(-1),
00188 mhitrantag(-1),
00189 mjpltags(),
00190 mqcoeff()
00191 { }
00192
00195 IsotopeRecord(const IsotopeRecord& x) :
00196 mname(x.mname),
00197 mabundance(x.mabundance),
00198 mmass(x.mmass),
00199 mmytrantag(x.mmytrantag),
00200 mhitrantag(x.mhitrantag),
00201 mjpltags(x.mjpltags),
00202 mqcoeff()
00203 { }
00204
00206 IsotopeRecord(const String& name,
00207 const Numeric& abundance,
00208 const Numeric& mass,
00209 const Index& mytrantag,
00210 const Index& hitrantag,
00211 const MakeArray<Index>& jpltags) :
00212 mname(name),
00213 mabundance(abundance),
00214 mmass(mass),
00215 mmytrantag(mytrantag),
00216 mhitrantag(hitrantag),
00217 mjpltags(jpltags),
00218 mqcoeff()
00219 {
00220
00221
00222
00223 #ifndef NDEBUG
00224 {
00225
00226 assert( (0<mmytrantag) || (-1==mmytrantag) );
00227 assert( (0<mhitrantag) || (-1==mhitrantag) );
00228 for ( Index i=0; i<mjpltags.nelem(); ++i )
00229 assert( (0<mjpltags[i]) || (-1==mjpltags[i]) );
00230 }
00231 #endif // ifndef NDEBUG
00232 }
00233
00235 const String& Name() const { return mname; }
00237 const Numeric& Abundance() const { return mabundance; }
00240 const Numeric& Mass() const { return mmass; }
00242 const Index& MytranTag() const { return mmytrantag; }
00244 const Index& HitranTag() const { return mhitrantag; }
00248 const ArrayOfIndex& JplTags() const { return mjpltags; }
00249
00250 void SetPartitionFctCoeff( const ArrayOfNumeric& qcoeff )
00251 {
00252 mqcoeff = qcoeff;
00253 }
00254
00256
00268 Numeric CalculatePartitionFctRatio( Numeric reference_temperature,
00269 Numeric actual_temperature ) const
00270 {
00271 Numeric qcoeff_at_t_ref =
00272 CalculatePartitionFctAtTemp( reference_temperature );
00273 Numeric qtemp =
00274 CalculatePartitionFctAtTemp( actual_temperature );
00275
00276 if ( qtemp < 0. )
00277 {
00278 ostringstream os;
00279 os << "Partition function of "
00280 << "Isotope = " << mname
00281 << "is unknown.";
00282 throw runtime_error(os.str());
00283 }
00284 return qcoeff_at_t_ref / qtemp;
00285 }
00286
00287 private:
00288
00289
00290
00291 Numeric CalculatePartitionFctAtTemp( Numeric temperature ) const;
00292
00293 String mname;
00294 Numeric mabundance;
00295 Numeric mmass;
00296 Index mmytrantag;
00297 Index mhitrantag;
00298 ArrayOfIndex mjpltags;
00299 ArrayOfNumeric mqcoeff;
00300 };
00301
00302
00306 class SpeciesRecord{
00307 public:
00308
00310 SpeciesRecord() : mname(),
00311 mdegfr(-1),
00312 misotope() { };
00313
00315 SpeciesRecord(const char name[],
00316 const Index degfr,
00317 const MakeArray<IsotopeRecord>& isotope)
00318 : mname(name),
00319 mdegfr(degfr),
00320 misotope(isotope)
00321 {
00322
00323
00324
00325
00326 #ifndef NDEBUG
00327 {
00328
00329 for ( Index i=0; i<misotope.nelem()-1; ++i )
00330 {
00331 assert( misotope[i].Abundance() >= misotope[i+1].Abundance() );
00332 }
00333
00334
00335 for ( Index i=0; i<misotope.nelem()-1; ++i )
00336 {
00337 if ( (0<misotope[i].MytranTag()) && (0<misotope[i+1].MytranTag()) )
00338 {
00339 assert( misotope[i].MytranTag() < misotope[i+1].MytranTag() );
00340
00341
00342 assert( misotope[i].MytranTag()/10 == misotope[i].MytranTag()/10 );
00343 }
00344 }
00345
00346
00347 for ( Index i=0; i<misotope.nelem()-1; ++i )
00348 {
00349 if ( (0<misotope[i].HitranTag()) && (0<misotope[i+1].HitranTag()) )
00350 {
00351 assert( misotope[i].HitranTag() < misotope[i+1].HitranTag() );
00352
00353
00354 assert( misotope[i].HitranTag()/10 == misotope[i+1].HitranTag()/10 );
00355 }
00356 }
00357 }
00358 #endif // #ifndef NDEBUG
00359 }
00360
00361 const String& Name() const { return mname; }
00362 Index Degfr() const { return mdegfr; }
00363 const Array<IsotopeRecord>& Isotope() const { return misotope; }
00364 Array<IsotopeRecord>& Isotope() { return misotope; }
00365
00366 private:
00368 String mname;
00370 Index mdegfr;
00372 Array<IsotopeRecord> misotope;
00373 };
00374
00462 class LineRecord {
00463 public:
00464
00468 friend void linesElowToJoule(Array<LineRecord>& abs_lines);
00469
00473 LineRecord()
00474 : mspecies (1000000),
00475 misotope (1000000),
00476 mf (0. ),
00477 mpsf (0. ),
00478 mi0 (0. ),
00479 mti0 (0. ),
00480 melow (0. ),
00481 magam (0. ),
00482 msgam (0. ),
00483 mnair (0. ),
00484 mnself (0. ),
00485 mtgam (0. ),
00486 maux ( ),
00487 mdf (-1. ),
00488 mdi0 (-1. ),
00489 mdagam (-1. ),
00490 mdsgam (-1. ),
00491 mdnair (-1. ),
00492 mdnself (-1. ),
00493 mdpsf (-1. )
00494 { }
00495
00500 LineRecord( Index species,
00501 Index isotope,
00502 Numeric f,
00503 Numeric psf,
00504 Numeric i0,
00505 Numeric ti0,
00506 Numeric elow,
00507 Numeric agam,
00508 Numeric sgam,
00509 Numeric nair,
00510 Numeric nself,
00511 Numeric tgam,
00512 const ArrayOfNumeric& aux,
00513 Numeric ,
00514 Numeric ,
00515 Numeric ,
00516 Numeric ,
00517 Numeric ,
00518 Numeric ,
00519 Numeric )
00520 : mspecies (species ),
00521 misotope (isotope ),
00522 mf (f ),
00523 mpsf (psf ),
00524 mi0 (i0 ),
00525 mti0 (ti0 ),
00526 melow (elow ),
00527 magam (agam ),
00528 msgam (sgam ),
00529 mnair (nair ),
00530 mnself (nself ),
00531 mtgam (tgam ),
00532 maux (aux ),
00533 mdf (-1. ),
00534 mdi0 (-1. ),
00535 mdagam (-1. ),
00536 mdsgam (-1. ),
00537 mdnair (-1. ),
00538 mdnself (-1. ),
00539 mdpsf (-1. )
00540 {
00541
00542
00543
00544
00545
00547
00548
00549 }
00550
00552 String Version() const
00553 {
00554 ostringstream os;
00555 os << "ARTSCAT-" << mversion;
00556 return os.str();
00557 }
00558
00561 Index Species() const { return mspecies; }
00562
00566 Index Isotope() const { return misotope; }
00567
00568 String Name() const;
00569
00570 const SpeciesRecord& SpeciesData() const;
00571
00572 const IsotopeRecord& IsotopeData() const;
00573
00575 Numeric F() const { return mf; }
00576
00578 void setF( Numeric new_mf ) { mf = new_mf; }
00579
00581 Numeric Psf() const { return mpsf; }
00582
00584 void setPsf( Numeric new_mpsf ) { mpsf = new_mpsf; }
00585
00598 Numeric I0() const { return mi0; }
00599
00601 void setI0( Numeric new_mi0 ) { mi0 = new_mi0; }
00602
00604 Numeric Ti0() const { return mti0; }
00605
00607 Numeric Elow() const { return melow; }
00608
00610 Numeric Agam() const { return magam; }
00611
00613 void setAgam( Numeric new_agam ) { magam = new_agam; }
00614
00616 Numeric Sgam() const { return msgam; }
00617
00619 void setSgam( Numeric new_sgam ) { msgam = new_sgam; }
00620
00622 Numeric Nair() const { return mnair; }
00623
00625 void setNair( Numeric new_mnair ) { mnair = new_mnair; }
00626
00628 Numeric Nself() const { return mnself; }
00629
00631 void setNself( Numeric new_mnself ) { mnself = new_mnself; }
00632
00634 Numeric Tgam() const { return mtgam; }
00635
00641 Index Naux() const { return maux.nelem(); }
00642
00644 const ArrayOfNumeric& Aux() const { return maux; }
00645
00646
00648 Numeric dF() const { return mdf; }
00649
00651 Numeric dI0() const { return mdi0; }
00652
00654 Numeric dAgam() const { return mdagam; }
00655
00657 Numeric dSgam() const { return mdsgam; }
00658
00660 Numeric dNair() const { return mdnair; }
00661
00663 Numeric dNself() const { return mdnself; }
00664
00666 Numeric dPsf() const { return mdpsf; }
00667
00668
00728 bool ReadFromHitranStream(istream& is);
00729
00730
00731
00801 bool ReadFromHitran2004Stream(istream& is);
00802
00803
00804
00805
00874 bool ReadFromMytran2Stream(istream& is);
00875
00876
00929 bool ReadFromJplStream(istream& is);
00930
00952 bool ReadFromArtsStream(istream& is);
00953
00954
00955 private:
00956
00957 static const Index mversion = 3;
00958
00959 Index mspecies;
00960
00961 Index misotope;
00962
00963 Numeric mf;
00964
00965 Numeric mpsf;
00966
00967 Numeric mi0;
00968
00969 Numeric mti0;
00970
00971 Numeric melow;
00972
00973 Numeric magam;
00974
00975 Numeric msgam;
00976
00977 Numeric mnair;
00978
00979 Numeric mnself;
00980
00981 Numeric mtgam;
00982
00983 ArrayOfNumeric maux;
00984
00985
00986
00987
00988 Numeric mdf;
00989
00990 Numeric mdi0;
00991
00992 Numeric mdagam;
00993
00994 Numeric mdsgam;
00995
00996 Numeric mdnair;
00997
00998 Numeric mdnself;
00999
01000 Numeric mdpsf;
01001 };
01002
01003
01004 class SpecIsoMap{
01005 public:
01006 SpecIsoMap():mspeciesindex(0), misotopeindex(0){}
01007 SpecIsoMap(const Index& speciesindex,
01008 const Index& isotopeindex)
01009 : mspeciesindex(speciesindex),
01010 misotopeindex(isotopeindex)
01011 {}
01012
01013
01014 const Index& Speciesindex() const { return mspeciesindex; }
01015
01016 const Index& Isotopeindex() const { return misotopeindex; }
01017
01018 private:
01019 Index mspeciesindex;
01020 Index misotopeindex;
01021 };
01022
01023
01024
01027 typedef Array<LineRecord> ArrayOfLineRecord;
01028
01032 typedef Array< Array<LineRecord> > ArrayOfArrayOfLineRecord;
01033
01034
01035
01040 ostream& operator << (ostream& os, const LineRecord& lr);
01041
01042
01043
01047 void define_species_map();
01048
01049
01050
01051 void write_lines_to_stream(ostream& os,
01052 const ArrayOfLineRecord& abs_lines);
01053
01054
01055 void xsec_species( MatrixView xsec,
01056 ConstVectorView f_mono,
01057 ConstVectorView abs_p,
01058 ConstVectorView abs_t,
01059 ConstVectorView h2o_abs,
01060 ConstVectorView vmr,
01061 const ArrayOfLineRecord& abs_lines,
01062 const Index ind_ls,
01063 const Index ind_lsn,
01064 const Numeric cutoff);
01065
01066
01067
01068 Numeric wavenumber_to_joule(Numeric e);
01069
01070
01071
01072
01073
01074
01075 void refr_index_BoudourisDryAir (
01076 Vector& refr_index,
01077 ConstVectorView abs_p,
01078 ConstVectorView abs_t );
01079
01080 void refr_index_Boudouris (
01081 Vector& refr_index,
01082 ConstVectorView abs_p,
01083 ConstVectorView abs_t,
01084 ConstVectorView h2o_abs );
01085
01086
01087
01088
01089
01090
01091
01092 void convHitranIERF(
01093 Numeric& mdf,
01094 const Index& df
01095 );
01096
01097
01098
01099 void convHitranIERSH(
01100 Numeric& mdh,
01101 const Index& dh
01102 );
01103
01104
01105
01106 void convMytranIER(
01107 Numeric& mdh,
01108 const Index & dh
01109 );
01110
01111 #endif // absorption_h