ARTS  2.4.0(git:4fb77825)
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,
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
GriddedField2
Definition: gridded_fields.h:237
gridded_fields.h
Implementation of gridded fields.
cia_interpolation
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
CIARecord::Species
Index Species(const Index i) const
Return CIA species index.
Definition: cia.h:96
temp
#define temp
Definition: legacy_continua.cc:20951
ARTS::Var::verbosity
Verbosity verbosity(Workspace &ws) noexcept
Definition: autoarts.h:7112
CIARecord::ReadFromCIA
void ReadFromCIA(const String &filename, const Verbosity &verbosity)
Read CIA catalog file.
Definition: cia.cc:316
ArrayOfCIARecord
Array< CIARecord > ArrayOfCIARecord
Definition: cia.h:42
matpackI.h
Implementation of Matrix, Vector, and such stuff.
Array
This can be used to make arrays out of anything.
Definition: array.h:108
CIARecord::SetMoleculeName
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
my_basic_string< char >
VectorView
The VectorView class.
Definition: matpackI.h:610
CIARecord::Data
ArrayOfGriddedField2 & Data()
Return CIA data.
Definition: cia.h:141
CIARecord::DatasetCount
Index DatasetCount() const
Return number of datasets in this record.
Definition: cia.h:106
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:49
bifstream
Binary output file stream class.
Definition: bifstream.h:42
ARTS::Var::f_grid
Vector f_grid(Workspace &ws) noexcept
Definition: autoarts.h:3449
CIARecord::xml_read_from_stream
friend void xml_read_from_stream(istream &is_xml, CIARecord &cr, bifstream *pbifs, const Verbosity &verbosity)
Reads CIARecord from XML input stream.
Definition: xml_io_compound_types.cc:56
CIARecord::mdata
ArrayOfGriddedField2 mdata
The data itself, directly from the HITRAN file.
Definition: cia.h:232
CIARecord::FrequencyGrid
ConstVectorView FrequencyGrid(Index dataset) const
Return frequency grid for given dataset.
Definition: cia.h:110
CIARecord::TemperatureGrid
ConstVectorView TemperatureGrid(Index dataset) const
Return temperatur grid for given dataset.
Definition: cia.h:119
CIARecord::Dataset
const GriddedField2 & Dataset(Index dataset) const
Return CIA dataset.
Definition: cia.h:128
CIARecord::Data
const ArrayOfGriddedField2 & Data() const
Return CIA data.
Definition: cia.h:137
operator<<
ostream & operator<<(ostream &os, const CIARecord &cr)
Output operator for CIARecord.
Definition: cia.cc:509
CIARecord::Extract
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
CIARecord
CIA data for a single pair of molecules.
Definition: cia.h:67
CIARecord::SetSpecies
void SetSpecies(const Index first, const Index second)
Set CIA species.
Definition: cia.h:147
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
check_input.h
CIARecord::MoleculeName
String MoleculeName(const Index i) const
Return each molecule name (as a string) that is associated with this CIARecord.
Definition: cia.cc:277
cia_get_index
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
Vector
The Vector class.
Definition: matpackI.h:860
CIARecord::Extract
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
A constant view of a Vector.
Definition: matpackI.h:476
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:195
mystring.h
This file contains the definition of String, the ARTS string class.
arts.h
The global header file for ARTS.
CIARecord::mspecies
Index mspecies[2]
The pair of molecules associated with these CIA data.
Definition: cia.h:242
CIARecord::AppendDataset
void AppendDataset(const CIARecord &c2)
Append other CIARecord to this.
Definition: cia.cc:495