ARTS 2.5.9 (git: 825fa5f2)
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 "gridded_fields.h"
36#include "matpackI.h"
37#include "messages.h"
38#include "mystring.h"
39#include "species.h"
40
41// Declare existance of some classes:
42class bifstream;
43class CIARecord;
44
46
47/* Header with implementation. */
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
57 const Species::Species sp1,
58 const Species::Species sp2);
59
68class CIARecord {
69 public:
78 [[nodiscard]] String MoleculeName(const Index i) const;
79
90 void SetMoleculeName(const Index i, const String& name);
91
97 [[nodiscard]] Species::Species Species(const Index i) const {
98 // Assert that i is 0 or 1:
99 ARTS_ASSERT(i >= 0);
100 ARTS_ASSERT(i <= 1);
101
102 return mspecies[i];
103 }
104
107 [[nodiscard]] Index DatasetCount() const { return mdata.nelem(); }
108
111 [[nodiscard]] ConstVectorView FrequencyGrid(Index dataset) const {
112 ARTS_ASSERT(dataset >= 0);
113 ARTS_ASSERT(dataset < mdata.nelem());
114
115 return mdata[dataset].get_numeric_grid(0);
116 }
117
120 [[nodiscard]] ConstVectorView TemperatureGrid(Index dataset) const {
121 ARTS_ASSERT(dataset >= 0);
122 ARTS_ASSERT(dataset < mdata.nelem());
123
124 return mdata[dataset].get_numeric_grid(1);
125 }
126
129 [[nodiscard]] const GriddedField2& Dataset(Index dataset) const {
130 ARTS_ASSERT(dataset >= 0);
131 ARTS_ASSERT(dataset < mdata.nelem());
132
133 return mdata[dataset];
134 }
135
138 [[nodiscard]] const ArrayOfGriddedField2& Data() const { return mdata; }
139
143
148 void SetSpecies(const Species::Species first, const Species::Species second) {
149 mspecies[0] = first;
150 mspecies[1] = second;
151 }
152
165 void Extract(VectorView result,
166 ConstVectorView f_grid,
167 const Numeric& temperature,
168 const Index& dataset,
169 const Numeric& T_extrapolfac,
170 const Index& robust,
171 const Verbosity& verbosity) const;
172
185 [[nodiscard]] Numeric Extract(const Numeric& frequency,
186 const Numeric& temperature,
187 const Index& dataset,
188 const Numeric& T_extrapolfac,
189 const Index& robust,
190 const Verbosity& verbosity) const {
191 Vector result(1);
192 const Vector freqvec(1, frequency);
193
194 Extract(result,
195 freqvec,
196 temperature,
197 dataset,
198 T_extrapolfac,
199 robust,
200 verbosity);
201
202 return result[0];
203 }
204
206 void ReadFromCIA(const String& filename, const Verbosity& verbosity);
207
208 friend void xml_read_from_stream(istream& is_xml,
209 CIARecord& cr,
210 bifstream* pbifs,
211 const Verbosity& verbosity);
212
214 void AppendDataset(const CIARecord& c2);
215
216 [[nodiscard]] std::array<Species::Species, 2> TwoSpecies() const {
217 return mspecies;
218 }
219 std::array<Species::Species, 2>& TwoSpecies() { return mspecies; }
220
221 CIARecord() = default;
222
224 Species::Species spec1,
225 Species::Species spec2)
226 : mdata(std::move(data)), mspecies({spec1, spec2}) {}
227
228 friend ostream& operator<<(ostream& os, const CIARecord& cr);
229
230 private:
232 void AppendDataset(const Vector& freq,
233 const ArrayOfNumeric& temp,
234 const ArrayOfVector& cia);
235
248
257 std::array<Species::Species, 2> mspecies;
258};
259
260#endif // cia_h
The global header file for ARTS.
Index cia_get_index(const ArrayOfCIARecord &cia_data, const Species::Species sp1, const Species::Species sp2)
Get the index in cia_data for the two given species.
Definition: cia.cc:227
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:55
This can be used to make arrays out of anything.
Definition: array.h:48
Index nelem() const ARTS_NOEXCEPT
Definition: array.h:92
CIA data for a single pair of molecules.
Definition: cia.h:68
friend void xml_read_from_stream(istream &is_xml, CIARecord &cr, bifstream *pbifs, const Verbosity &verbosity)
Reads CIARecord from XML input stream.
std::array< Species::Species, 2 > mspecies
The pair of molecules associated with these CIA data.
Definition: cia.h:257
void SetSpecies(const Species::Species first, const Species::Species second)
Set CIA species.
Definition: cia.h:148
ArrayOfGriddedField2 mdata
The data itself, directly from the HITRAN file.
Definition: cia.h:247
CIARecord(ArrayOfGriddedField2 data, Species::Species spec1, Species::Species spec2)
Definition: cia.h:223
void AppendDataset(const CIARecord &c2)
Append other CIARecord to this.
Definition: cia.cc:484
const ArrayOfGriddedField2 & Data() const
Return CIA data.
Definition: cia.h:138
ArrayOfGriddedField2 & Data()
Return CIA data.
Definition: cia.h:142
std::array< Species::Species, 2 > TwoSpecies() const
Definition: cia.h:216
Species::Species Species(const Index i) const
Return CIA species index.
Definition: cia.h:97
void ReadFromCIA(const String &filename, const Verbosity &verbosity)
Read CIA catalog file.
Definition: cia.cc:303
void SetMoleculeName(const Index i, const String &name)
Set each molecule name (from a string) that is associated with this CIARecord.
Definition: cia.cc:278
CIARecord()=default
Index DatasetCount() const
Return number of datasets in this record.
Definition: cia.h:107
std::array< Species::Species, 2 > & TwoSpecies()
Definition: cia.h:219
ConstVectorView FrequencyGrid(Index dataset) const
Return frequency grid for given dataset.
Definition: cia.h:111
friend ostream & operator<<(ostream &os, const CIARecord &cr)
Output operator for CIARecord.
Definition: cia.cc:498
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:239
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:185
String MoleculeName(const Index i) const
Return each molecule name (as a string) that is associated with this CIARecord.
Definition: cia.cc:267
ConstVectorView TemperatureGrid(Index dataset) const
Return temperatur grid for given dataset.
Definition: cia.h:120
const GriddedField2 & Dataset(Index dataset) const
Return CIA dataset.
Definition: cia.h:129
A constant view of a Vector.
Definition: matpackI.h:521
The VectorView class.
Definition: matpackI.h:674
The Vector class.
Definition: matpackI.h:910
Binary output file stream class.
Definition: bifstream.h:43
#define ARTS_ASSERT(condition,...)
Definition: debug.h:82
Implementation of gridded fields.
Implementation of Matrix, Vector, and such stuff.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Declarations having to do with the four output streams.
This file contains the definition of String, the ARTS string class.