ARTS  2.3.1285(git:92a29ea9-dirty)
absorption.h
Go to the documentation of this file.
1 /* Copyright (C) 2000-2012
2  Stefan Buehler <sbuehler@ltu.se>
3  Axel von Engeln <engeln@uni-bremen.de>
4 
5  This program is free software; you can redistribute it and/or modify it
6  under the terms of the GNU General Public License as published by the
7  Free Software Foundation; either version 2, or (at your option) any
8  later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18  USA. */
19 
28 #ifndef absorption_h
29 #define absorption_h
30 
31 #include <cmath>
32 #include <stdexcept>
33 #include "abs_species_tags.h"
34 #include "array.h"
35 #include "energylevelmap.h"
36 #include "gridded_fields.h"
37 #include "jacobian.h"
38 #include "matpackI.h"
39 #include "messages.h"
40 #include "mystring.h"
41 #include "absorptionlines.h"
42 
46  public:
48  IsotopologueRecord() = default;
49  IsotopologueRecord(const IsotopologueRecord&) = default;
53 
56  const Numeric& abundance,
57  const Numeric& mass,
58  const Index& mytrantag,
59  const Index& hitrantag,
60  const ArrayOfIndex& jpltags)
61  : mname(name),
62  mabundance(abundance),
63  mmass(mass),
64  mmytrantag(mytrantag),
65  mhitrantag(hitrantag),
66  mjpltags(jpltags),
67  mqcoeff(),
69  mqcoeffgrid() {
70  // With Matpack, initialization of mjpltags from jpltags should now work correctly.
71 
72  // Some consistency checks whether the given data makes sense.
73 #ifndef NDEBUG
74  {
75  /* 1. All the tags must be positive or -1 */
76  assert((0 < mmytrantag) || (-1 == mmytrantag));
77  assert((0 < mhitrantag) || (-1 == mhitrantag));
78  for (Index i = 0; i < mjpltags.nelem(); ++i)
79  assert((0 < mjpltags[i]) || (-1 == mjpltags[i]));
80  }
81 #endif // ifndef NDEBUG
82  }
83 
85  const String& Name() const { return mname; }
87  const Numeric& Abundance() const { return mabundance; }
90  const Numeric& Mass() const { return mmass; }
92  const Index& MytranTag() const { return mmytrantag; }
94  const Index& HitranTag() const { return mhitrantag; }
98  const ArrayOfIndex& JplTags() const { return mjpltags; }
99 
101 
104  bool isContinuum() const { return mname.length() && !isdigit(mname[0]); }
105 
107  const Vector& GetCoeff() const { return mqcoeff; }
108 
110  const Vector& GetCoeffGrid() const { return mqcoeffgrid; }
111 
113  Index GetCoeffType() const { return mqcoefftype; }
114 
116  const ArrayOfNumeric& temp_range,
117  const Index& qcoefftype) {
118  mqcoeff = qcoeff;
119  mqcoeffgrid = temp_range;
120  mqcoefftype = qcoefftype;
121  }
122 
123  enum {
124  PF_FROMCOEFF, // Partition function will be from coefficients
125  PF_FROMTEMP, // Partition function will be from temperature field
126  PF_NOTHING // This will be the designated starter value
127  };
128 
129  private:
139 };
140 
145  public:
148  : mname(), mdegfr(-1), misotopologue() { /* Nothing to do here */
149  }
150 
152  SpeciesRecord(const char name[],
153  const Index degfr,
154  const Array<IsotopologueRecord>& isotopologue)
155  : mname(name), mdegfr(degfr), misotopologue(isotopologue) {
156  // Thanks to Matpack, initialization of misotopologue with isotopologue
157  // should now work correctly.
158 
159 #ifndef NDEBUG
160  {
161  /* Check that the isotopologues are correctly sorted. */
162  for (Index i = 0; i < misotopologue.nelem() - 1; ++i) {
163  assert(std::isnan(misotopologue[i].Abundance()) ||
164  std::isnan(misotopologue[i + 1].Abundance()) ||
165  misotopologue[i].Abundance() >=
166  misotopologue[i + 1].Abundance());
167  }
168 
169  /* Check that the Mytran tags are correctly sorted. */
170  for (Index i = 0; i < misotopologue.nelem() - 1; ++i) {
171  if ((0 < misotopologue[i].MytranTag()) &&
172  (0 < misotopologue[i + 1].MytranTag())) {
173  assert(misotopologue[i].MytranTag() <
174  misotopologue[i + 1].MytranTag());
175 
176  // Also check that the tags have the same base number:
177  assert(misotopologue[i].MytranTag() / 10 ==
178  misotopologue[i].MytranTag() / 10);
179  }
180  }
181 
182  /* Check that the Hitran tags are correctly sorted. */
183  for (Index i = 0; i < misotopologue.nelem() - 1; ++i) {
184  if ((0 < misotopologue[i].HitranTag()) &&
185  (0 < misotopologue[i + 1].HitranTag())) {
186  // assert( misotopologue[i].HitranTag() < misotopologue[i+1].HitranTag() );
187 
188  // Also check that the tags have the same base number:
189  assert(misotopologue[i].HitranTag() / 10 ==
190  misotopologue[i + 1].HitranTag() / 10);
191  }
192  }
193  }
194 #endif // #ifndef NDEBUG
195  }
196 
197  const String& Name() const { return mname; }
198  Index Degfr() const { return mdegfr; }
200  return misotopologue;
201  }
202  Array<IsotopologueRecord>& Isotopologue() { return misotopologue; }
203 
205  String FullName(Index k) const {return mname + '-' + misotopologue[k].Name();}
206 
207  private:
214 };
215 
218  public:
219  typedef enum {
226  AT_FINAL_ENTRY
227  } AuxType;
228 
232 
235 
236  void InitFromSpeciesData();
237 
239  Index nspecies() const { return mparams.nelem(); };
240 
242  Index nisotopologues(const Index species) const {
243  return mparams[species].nelem();
244  };
245 
247  const ArrayOfGriddedField1& getParam(const Index species,
248  const Index isotopologue) const;
249 
251  Numeric getIsotopologueRatio(const SpeciesTag& st) const;
252 
254  Numeric getIsotopologueRatio(const QuantumIdentifier& qid) const;
255 
258  return getParam(qid.Species(), qid.Isotopologue());
259  }
260 
262  String getTypeString(const Index species, const Index isotopologue) const;
263 
265  void setParam(const Index species,
266  const Index isotopologue,
267  const AuxType auxtype,
268  const ArrayOfGriddedField1& auxdata);
269 
271  void setParam(const String& artstag,
272  const String& auxtype,
273  const ArrayOfGriddedField1& auxdata);
274 
276  const AuxType& getParamType(const Index species,
277  const Index isotopologue) const {
278  return mparam_type[species][isotopologue];
279  }
280 
282  const AuxType& getParamType(const QuantumIdentifier& qid) const {
283  return getParamType(qid.Species(), qid.Isotopologue());
284  }
285 
287  bool ReadFromStream(String& artsid,
288  istream& is,
289  Index nparams,
290  const Verbosity& verbosity);
291 
293  ArrayOfGriddedField1& Data(const Index species, const Index isotopologue) {return mparams[species][isotopologue];}
294 
296  Index setParamType(const Index species, const Index isotopologue, Index type) {
297  for (auto y: {AT_NONE, AT_ISOTOPOLOGUE_RATIO, AT_ISOTOPOLOGUE_QUANTUM, AT_PARTITIONFUNCTION_TFIELD, AT_PARTITIONFUNCTION_COEFF, AT_PARTITIONFUNCTION_COEFF_VIBROT, AT_FINAL_ENTRY }) {
298  if (Index(y) == type) {
299  mparam_type[species][isotopologue] = y;
300  return 0;
301  }
302  }
303  return 1;
304  }
305 
307  bool validIndex(Index species, Index isotopologue) const {
308  if(species >= 0 and isotopologue >= 0 and
309  mparams.nelem() > species and mparams[species].nelem() > isotopologue and
310  mparam_type.nelem() > species and mparam_type[species].nelem() > isotopologue)
311  return true;
312  else
313  return false;
314  }
315 
316  private:
317  ArrayOfArrayOfAuxData mparams;
318  ArrayOfArrayOfAuxType mparam_type;
319 };
320 
322 void checkIsotopologueRatios(const ArrayOfArrayOfSpeciesTag& abs_species,
323  const SpeciesAuxData& isoratios);
324 
326 void checkPartitionFunctions(const ArrayOfArrayOfSpeciesTag& abs_species,
327  const SpeciesAuxData& partfun);
328 
331  SpeciesAuxData& sad);
332 
335  SpeciesAuxData& sad);
336 
337 // is needed to map jpl tags/arts identifier to the species/isotopologue data within arts
338 class SpecIsoMap {
339  public:
340  SpecIsoMap() : mspeciesindex(0), misotopologueindex(0) {}
341  SpecIsoMap(const Index& speciesindex, const Index& isotopologueindex)
342  : mspeciesindex(speciesindex), misotopologueindex(isotopologueindex) {}
343 
344  // Return the index to the species
345  const Index& Speciesindex() const { return mspeciesindex; }
346  // Return the index to the isotopologue
347  const Index& Isotopologueindex() const { return misotopologueindex; }
348 
349  private:
352 };
353 
358 ostream& operator<<(ostream& os, const SpeciesRecord& sr);
359 
362 ostream& operator<<(ostream& os, const SpeciesAuxData& sad);
363 
364 // A helper function for energy conversion:
366 
367 //======================================================================
368 // Functions related to species
369 //======================================================================
370 
372 
374 
376  const String& species_name,
377  const ArrayOfArrayOfSpeciesTag& abs_species,
378  const Matrix& abs_vmrs);
379 
404 void xsec_species(Matrix& xsec,
405  Matrix& source,
406  Matrix& phase,
407  ArrayOfMatrix& dxsec_dx,
408  ArrayOfMatrix& dsource_dx,
409  ArrayOfMatrix& dphase_dx,
410  const ArrayOfRetrievalQuantity& jacobian_quantities,
411  const ArrayOfIndex& jacobian_propmat_positions,
412  const Vector& f_grid,
413  const Vector& abs_p,
414  const Vector& abs_t,
415  const EnergyLevelMap& abs_nlte,
416  const Matrix& abs_vmrs,
417  const ArrayOfArrayOfSpeciesTag& abs_species,
418  const AbsorptionLines& band,
419  const Numeric& isot_ratio,
420  const SpeciesAuxData::AuxType& partfun_type,
421  const ArrayOfGriddedField1& partfun_data);
422 
429 
430 #endif // absorption_h
Index GetCoeffType() const
Return the partition function coefficient types.
Definition: absorption.h:113
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
const Index & MytranTag() const
MYTRAN2 tag numbers for all isotopologues.
Definition: absorption.h:92
void checkIsotopologueRatios(const ArrayOfArrayOfSpeciesTag &abs_species, const SpeciesAuxData &isoratios)
Check that isotopologue ratios for the given species are correctly defined.
Definition: absorption.cc:301
ostream & operator<<(ostream &os, const SpeciesRecord &sr)
Output operator for SpeciesRecord.
Definition: absorption.cc:467
bool isContinuum() const
Check if isotopologue is actually a continuum.
Definition: absorption.h:104
ArrayOfArrayOfAuxData mparams
Definition: absorption.h:317
Index nelem() const
Number of elements.
Definition: array.h:195
void Isotopologue(Index iso)
Set the Isotopologue.
Definition: quantum.h:487
const Numeric & Mass() const
Mass of the isotopologue.
Definition: absorption.h:90
String species_name_from_species_index(const Index spec_ind)
Return species name for given species index.
Definition: absorption.cc:569
Declarations having to do with the four output streams.
Index misotopologueindex
Definition: absorption.h:351
Routines for setting up the jacobian.
The Vector class.
Definition: matpackI.h:860
void set_vmr_from_first_species(Vector &vmr, const String &species_name, const ArrayOfArrayOfSpeciesTag &abs_species, const Matrix &abs_vmrs)
set_abs_from_first_species.
Definition: absorption.cc:597
Index mdegfr
Degrees of freedom.
Definition: absorption.h:211
Array< IsotopologueRecord > & Isotopologue()
Definition: absorption.h:202
const Vector & GetCoeffGrid() const
Return the partition function coefficients.
Definition: absorption.h:110
Array< GriddedField1 > AuxData
Definition: absorption.h:230
const Index & Isotopologueindex() const
Definition: absorption.h:347
Array< Array< AuxType > > ArrayOfArrayOfAuxType
Definition: absorption.h:229
IsotopologueRecord & operator=(const IsotopologueRecord &)=default
const AuxType & getParamType(const QuantumIdentifier &qid) const
Return a constant reference to the parameter types.
Definition: absorption.h:282
Contains the absorption namespace.
ArrayOfArrayOfAuxType mparam_type
Definition: absorption.h:318
const Index & HitranTag() const
HITRAN-96 tag numbers for all isotopologues.
Definition: absorption.h:94
Index Degfr() const
Definition: absorption.h:198
This file contains the definition of Array.
String mname
Species name.
Definition: absorption.h:209
const Array< IsotopologueRecord > & Isotopologue() const
Definition: absorption.h:199
ArrayOfGriddedField1 & Data(const Index species, const Index isotopologue)
Returns value for one isotopologue.
Definition: absorption.h:293
void fillSpeciesAuxDataWithPartitionFunctionsFromSpeciesData(SpeciesAuxData &sad)
Fill SpeciesAuxData with default partition functions from species data.
Definition: absorption.cc:417
const AuxType & getParamType(const Index species, const Index isotopologue) const
Return a constant reference to the parameter types.
Definition: absorption.h:276
const ArrayOfIndex & JplTags() const
JPL tag numbers for all isotopologues.
Definition: absorption.h:98
SpeciesAuxData()
Default constructor.
Definition: absorption.h:234
String FullName(Index k) const
Return a copy of the full name of the k:th isotopologue.
Definition: absorption.h:205
void Species(Index sp)
Set the Species.
Definition: quantum.h:481
Contains the lookup data for one species.
Definition: absorption.h:144
SpeciesRecord(const char name[], const Index degfr, const Array< IsotopologueRecord > &isotopologue)
The constructor used in define_species_data.
Definition: absorption.h:152
A tag group can consist of the sum of several of these.
const SpeciesRecord & SpeciesDataOfBand(const AbsorptionLines &band)
Returns the species data.
Definition: absorption.cc:611
Class to identify and match lines by their quantum numbers.
Definition: quantum.h:390
SpecIsoMap(const Index &speciesindex, const Index &isotopologueindex)
Definition: absorption.h:341
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
ArrayOfIndex mjpltags
Definition: absorption.h:135
The Matrix class.
Definition: matpackI.h:1193
IsotopologueRecord()=default
Default constructor.
const String & Name() const
Definition: absorption.h:197
Index mspeciesindex
Definition: absorption.h:350
Index nspecies() const
Returns number of species.
Definition: absorption.h:239
Index species_index_from_species_name(String name)
Return species index for given species name.
Definition: absorption.cc:531
Implementation of Matrix, Vector, and such stuff.
Class to map energy levels.
Index nisotopologues(const Index species) const
Returns number of isotopologues for a certain species.
Definition: absorption.h:242
const ArrayOfGriddedField1 & getParam(const QuantumIdentifier &qid) const
Return a constant reference to the parameters.
Definition: absorption.h:257
Contains the lookup data for one isotopologue.
Definition: absorption.h:45
void SetPartitionFctCoeff(const ArrayOfNumeric &qcoeff, const ArrayOfNumeric &temp_range, const Index &qcoefftype)
Definition: absorption.h:115
void checkPartitionFunctions(const ArrayOfArrayOfSpeciesTag &abs_species, const SpeciesAuxData &partfun)
Check that partition functions for the given species are correctly defined.
Definition: absorption.cc:356
IsotopologueRecord(const String &name, const Numeric &abundance, const Numeric &mass, const Index &mytrantag, const Index &hitrantag, const ArrayOfIndex &jpltags)
Constructor that sets the values.
Definition: absorption.h:55
Numeric wavenumber_to_joule(Numeric e)
A little helper function to convert energy from units of wavenumber (cm^-1) to Joule (J)...
Definition: absorption.cc:500
Index setParamType(const Index species, const Index isotopologue, Index type)
Sets type for one isotopologue if type is valid (returns 0 if valid)
Definition: absorption.h:296
SpeciesRecord()
Default constructor.
Definition: absorption.h:147
Header file for stuff related to absorption species tags.
void xsec_species(Matrix &xsec, Matrix &source, Matrix &phase, ArrayOfMatrix &dxsec_dx, ArrayOfMatrix &dsource_dx, ArrayOfMatrix &dphase_dx, const ArrayOfRetrievalQuantity &jacobian_quantities, const ArrayOfIndex &jacobian_propmat_positions, const Vector &f_grid, const Vector &abs_p, const Vector &abs_t, const EnergyLevelMap &abs_nlte, const Matrix &abs_vmrs, const ArrayOfArrayOfSpeciesTag &abs_species, const AbsorptionLines &band, const Numeric &isot_ratio, const SpeciesAuxData::AuxType &partfun_type, const ArrayOfGriddedField1 &partfun_data)
Cross-section algorithm.
Definition: absorption.cc:616
Array< IsotopologueRecord > misotopologue
Isotopologue data.
Definition: absorption.h:213
const Vector & GetCoeff() const
Return the partition function coefficients.
Definition: absorption.h:107
const Index & Speciesindex() const
Definition: absorption.h:345
Implementation of gridded fields.
void fillSpeciesAuxDataWithIsotopologueRatiosFromSpeciesData(SpeciesAuxData &sad)
Fill SpeciesAuxData with default isotopologue ratios from species data.
Definition: absorption.cc:394
bool validIndex(Index species, Index isotopologue) const
Returns true if species and isotopologue are valid.
Definition: absorption.h:307
const Numeric & Abundance() const
Normal abundance ( = isotopologue ratio).
Definition: absorption.h:87
Auxiliary data for isotopologues.
Definition: absorption.h:217
Array< Array< AuxData > > ArrayOfArrayOfAuxData
Definition: absorption.h:231
const String & Name() const
Isotopologue name.
Definition: absorption.h:85
This file contains the definition of String, the ARTS string class.