ARTS  2.3.1285(git:92a29ea9-dirty)
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 "check_input.h"
36 #include "gridded_fields.h"
37 #include "matpackI.h"
38 #include "mystring.h"
39 
40 // Declare existance of some classes:
41 class bifstream;
42 class CIARecord;
43 
45 
46 /* Header with implementation. */
47 void cia_interpolation(VectorView result,
48  ConstVectorView frequency,
49  const Numeric& temperature,
50  const GriddedField2& cia_data,
51  const Numeric& T_extrapolfac,
52  const Index& robust,
53  const Verbosity& verbosity);
54 
55 Index cia_get_index(const ArrayOfCIARecord& cia_data,
56  const Index sp1,
57  const Index sp2);
58 
67 class CIARecord {
68  public:
77  String MoleculeName(const Index i) const;
78 
89  void SetMoleculeName(const Index i, const String& name);
90 
96  Index Species(const Index i) const {
97  // Assert that i is 0 or 1:
98  assert(i >= 0);
99  assert(i <= 1);
100 
101  return mspecies[i];
102  }
103 
106  Index DatasetCount() const { return mdata.nelem(); }
107 
111  assert(dataset >= 0);
112  assert(dataset < mdata.nelem());
113 
114  return mdata[dataset].get_numeric_grid(0);
115  }
116 
120  assert(dataset >= 0);
121  assert(dataset < mdata.nelem());
122 
123  return mdata[dataset].get_numeric_grid(1);
124  }
125 
128  const GriddedField2& Dataset(Index dataset) const {
129  assert(dataset >= 0);
130  assert(dataset < mdata.nelem());
131 
132  return mdata[dataset];
133  }
134 
137  const ArrayOfGriddedField2& Data() const { return mdata; }
138 
142 
147  void SetSpecies(const Index first, const Index second) {
148  mspecies[0] = first;
149  mspecies[1] = second;
150  }
151 
164  void Extract(VectorView result,
165  ConstVectorView f_grid,
166  const Numeric& temperature,
167  const Index& dataset,
168  const Numeric& T_extrapolfac,
169  const Index& robust,
170  const Verbosity& verbosity) const;
171 
184  Numeric Extract(const Numeric& frequency,
185  const Numeric& temperature,
186  const Index& dataset,
187  const Numeric& T_extrapolfac,
188  const Index& robust,
189  const Verbosity& verbosity) const {
190  Vector result(1);
191  const Vector freqvec(1, frequency);
192 
193  Extract(result,
194  freqvec,
195  temperature,
196  dataset,
197  T_extrapolfac,
198  robust,
199  verbosity);
200 
201  return result[0];
202  }
203 
205  void ReadFromCIA(const String& filename, const Verbosity& verbosity);
206 
207  friend void xml_read_from_stream(istream& is_xml,
208  CIARecord& cr,
209  bifstream* pbifs,
210  const Verbosity& verbosity);
211 
213  void AppendDataset(const CIARecord& c2);
214 
215  private:
217  void AppendDataset(const Vector& freq,
218  const ArrayOfNumeric& temp,
219  const ArrayOfVector& cia);
220 
233 
243 };
244 
245 ostream& operator<<(ostream& os, const CIARecord& cr);
246 
247 #endif // cia_h
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
The VectorView class.
Definition: matpackI.h:610
ostream & operator<<(ostream &os, const CIARecord &cr)
Output operator for CIARecord.
Definition: cia.cc:509
const ArrayOfGriddedField2 & Data() const
Return CIA data.
Definition: cia.h:137
Index nelem() const
Number of elements.
Definition: array.h:195
The Vector class.
Definition: matpackI.h:860
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:316
ArrayOfGriddedField2 mdata
The data itself, directly from the HITRAN file.
Definition: cia.h:232
Index DatasetCount() const
Return number of datasets in this record.
Definition: cia.h:106
const GriddedField2 & Dataset(Index dataset) const
Return CIA dataset.
Definition: cia.h:128
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:249
ConstVectorView FrequencyGrid(Index dataset) const
Return frequency grid for given dataset.
Definition: cia.h:110
The global header file for ARTS.
Index mspecies[2]
The pair of molecules associated with these CIA data.
Definition: cia.h:242
void AppendDataset(const CIARecord &c2)
Append other CIARecord to this.
Definition: cia.cc:495
Binary output file stream class.
Definition: bifstream.h:42
ConstVectorView TemperatureGrid(Index dataset) const
Return temperatur grid for given dataset.
Definition: cia.h:119
#define temp
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Array< CIARecord > ArrayOfCIARecord
Definition: cia.h:42
Implementation of Matrix, Vector, and such stuff.
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:184
void SetMoleculeName(const Index i, const String &name)
Set each molecule name (from a string) that is associated with this CIARecord.
Definition: cia.cc:288
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:147
A constant view of a Vector.
Definition: matpackI.h:476
String MoleculeName(const Index i) const
Return each molecule name (as a string) that is associated with this CIARecord.
Definition: cia.cc:277
CIA data for a single pair of molecules.
Definition: cia.h:67
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:237
Index Species(const Index i) const
Return CIA species index.
Definition: cia.h:96
This file contains the definition of String, the ARTS string class.
ArrayOfGriddedField2 & Data()
Return CIA data.
Definition: cia.h:141