ARTS  2.2.66
cia.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Stefan Buehler <sbuehler@ltu.se>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
31 #ifndef cia_h
32 #define cia_h
33 
34 #include "arts.h"
35 #include "matpackI.h"
36 #include "mystring.h"
37 #include "gridded_fields.h"
38 #include "check_input.h"
39 
40 // Declare existance of some classes:
41 class bifstream;
42 class CIARecord;
43 
45 
46 
47 /* Header with implementation. */
48 void cia_interpolation(VectorView result,
49  ConstVectorView frequency,
50  const Numeric& temperature,
51  const GriddedField2& cia_data,
52  const Numeric& T_extrapolfac,
53  const Index& robust,
54  const Verbosity& verbosity);
55 
56 Index cia_get_index(const ArrayOfCIARecord& cia_data,
57  const Index sp1, const Index sp2);
58 
59 
68 class CIARecord {
69 
70 public:
79  String MoleculeName(const Index i) const;
80 
81 
92  void SetMoleculeName(const Index i,
93  const String& name);
94 
95 
101  Index Species(const Index i) const
102  {
103  // Assert that i is 0 or 1:
104  assert(i>=0);
105  assert(i<=1);
106 
107  return mspecies[i];
108  }
109 
110 
113  Index DatasetCount() const { return mdata.nelem(); }
114 
115 
119  {
120  assert(dataset >= 0);
121  assert(dataset < mdata.nelem());
122 
123  return mdata[dataset].get_numeric_grid(0);
124  }
125 
126 
130  {
131  assert(dataset >= 0);
132  assert(dataset < mdata.nelem());
133 
134  return mdata[dataset].get_numeric_grid(1);
135  }
136 
137 
140  const GriddedField2& Dataset(Index dataset) const
141  {
142  assert(dataset >= 0);
143  assert(dataset < mdata.nelem());
144 
145  return mdata[dataset];
146  }
147 
148 
151  const ArrayOfGriddedField2& Data() const
152  {
153  return mdata;
154  }
155 
156 
161  void SetSpecies(const Index first, const Index second)
162  {
163  mspecies[0] = first;
164  mspecies[1] = second;
165  }
166 
167 
180  void Extract(VectorView result,
181  ConstVectorView f_grid,
182  const Numeric& temperature,
183  const Index& dataset,
184  const Numeric& T_extrapolfac,
185  const Index& robust,
186  const Verbosity& verbosity) const;
187 
188 
201  Numeric Extract(const Numeric& frequency,
202  const Numeric& temperature,
203  const Index& dataset,
204  const Numeric& T_extrapolfac,
205  const Index& robust,
206  const Verbosity& verbosity) const
207  {
208  Vector result(1);
209  const Vector freqvec(1, frequency);
210 
211  Extract(result, freqvec, temperature, dataset, T_extrapolfac, robust,
212  verbosity);
213 
214  return result[0];
215  }
216 
217 
219  void ReadFromCIA(const String& filename,
220  const Verbosity& verbosity);
221 
222  friend void xml_read_from_stream( istream& is_xml,
223  CIARecord& cr,
224  bifstream *pbifs,
225  const Verbosity& verbosity);
226 
227 private:
228 
230  void AppendDataset(const Vector& freq,
231  const ArrayOfNumeric& temp,
232  const ArrayOfVector& cia);
233 
234 
247 
257 };
258 
259 
260 ostream& operator<<(ostream& os, const CIARecord& cr);
261 
262 #endif // cia_h
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
The VectorView class.
Definition: matpackI.h:372
ostream & operator<<(ostream &os, const CIARecord &cr)
Output operator for CIARecord.
Definition: cia.cc:543
const ArrayOfGriddedField2 & Data() const
Return CIA data.
Definition: cia.h:151
Index nelem() const
Number of elements.
Definition: array.h:176
The Vector class.
Definition: matpackI.h:556
friend void xml_read_from_stream(istream &is_xml, CIARecord &cr, bifstream *pbifs, const Verbosity &verbosity)
Reads CIARecord from XML input stream.
void ReadFromCIA(const String &filename, const Verbosity &verbosity)
Read CIA catalog file.
Definition: cia.cc:345
ArrayOfGriddedField2 mdata
The data itself, directly from the HITRAN file.
Definition: cia.h:246
Index DatasetCount() const
Return number of datasets in this record.
Definition: cia.h:113
const GriddedField2 & Dataset(Index dataset) const
Return CIA dataset.
Definition: cia.h:140
void cia_interpolation(VectorView result, ConstVectorView frequency, const Numeric &temperature, const GriddedField2 &cia_data, const Numeric &T_extrapolfac, const Index &robust, const Verbosity &verbosity)
Interpolate CIA data.
Definition: cia.cc:53
void Extract(VectorView result, ConstVectorView f_grid, const Numeric &temperature, const Index &dataset, const Numeric &T_extrapolfac, const Index &robust, const Verbosity &verbosity) const
Vector version of extract.
Definition: cia.cc:265
void AppendDataset(const Vector &freq, const ArrayOfNumeric &temp, const ArrayOfVector &cia)
Append dataset to mdata.
Definition: cia.cc:515
ConstVectorView FrequencyGrid(Index dataset) const
Return frequency grid for given dataset.
Definition: cia.h:118
The global header file for ARTS.
Index mspecies[2]
The pair of molecules associated with these CIA data.
Definition: cia.h:256
Binary output file stream class.
Definition: bifstream.h:44
ConstVectorView TemperatureGrid(Index dataset) const
Return temperatur grid for given dataset.
Definition: cia.h:129
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
Array< CIARecord > ArrayOfCIARecord
Definition: cia.h:42
Numeric Extract(const Numeric &frequency, const Numeric &temperature, const Index &dataset, const Numeric &T_extrapolfac, const Index &robust, const Verbosity &verbosity) const
Scalar version of extract.
Definition: cia.h:201
void SetMoleculeName(const Index i, const String &name)
Set each molecule name (from a string) that is associated with this CIARecord.
Definition: cia.cc:313
This can be used to make arrays out of anything.
Definition: array.h:40
void SetSpecies(const Index first, const Index second)
Set CIA species.
Definition: cia.h:161
A constant view of a Vector.
Definition: matpackI.h:292
String MoleculeName(const Index i) const
Return each molecule name (as a string) that is associated with this CIARecord.
Definition: cia.cc:301
#define temp
Definition: continua.cc:20773
CIA data for a single pair of molecules.
Definition: cia.h:68
Implementation of gridded fields.
Index cia_get_index(const ArrayOfCIARecord &cia_data, const Index sp1, const Index sp2)
Get the index in cia_data for the two given species.
Definition: cia.cc:252
Index Species(const Index i) const
Return CIA species index.
Definition: cia.h:101
This file contains the definition of String, the ARTS string class.