ARTS 2.5.9 (git: 825fa5f2)
hitran_species.cc
Go to the documentation of this file.
1#include "hitran_species.h"
2
3#include <map>
4
5#include "isotopologues.h"
6#include "species_tags.h"
7
8namespace Hitran {
9using HitranMap = std::map<Index, std::map<char, std::pair<Index, Numeric>>>;
10
26 {1,
27 {
28 // H2O
29 {'1', {Species::find_species_index("H2O", "161"), 9.97317E-01}},
30 {'2', {Species::find_species_index("H2O", "181"), 1.99983E-03}},
31 {'3', {Species::find_species_index("H2O", "171"), 3.71884E-04}},
32 {'4', {Species::find_species_index("H2O", "162"), 3.10693E-04}},
33 {'5', {Species::find_species_index("H2O", "182"), 6.23003E-07}},
34 {'6', {Species::find_species_index("H2O", "172"), 1.15853E-07}},
35 {'7', {Species::find_species_index("H2O", "262"), 2.41974E-08}},
36 }},
37 {2,
38 {
39 // CO2
40 {'1', {Species::find_species_index("CO2", "626"), 9.84204E-01}},
41 {'2', {Species::find_species_index("CO2", "636"), 1.10574E-02}},
42 {'3', {Species::find_species_index("CO2", "628"), 3.94707E-03}},
43 {'4', {Species::find_species_index("CO2", "627"), 7.33989E-04}},
44 {'5', {Species::find_species_index("CO2", "638"), 4.43446E-05}},
45 {'6', {Species::find_species_index("CO2", "637"), 8.24623E-06}},
46 {'7', {Species::find_species_index("CO2", "828"), 3.95734E-06}},
47 {'8', {Species::find_species_index("CO2", "827"), 1.47180E-06}},
48 {'9', {Species::find_species_index("CO2", "727"), 1.36847E-07}},
49 {'0', {Species::find_species_index("CO2", "838"), 4.44600E-08}},
50 {'A', {Species::find_species_index("CO2", "837"), 1.65354E-08}},
51 {'B', {Species::find_species_index("CO2", "737"), 1.53745E-09}},
52 }},
53 {3,
54 {
55 // O3
56 {'1', {Species::find_species_index("O3", "666"), 9.92901E-01}},
57 {'2', {Species::find_species_index("O3", "668"), 3.98194E-03}},
58 {'3', {Species::find_species_index("O3", "686"), 1.99097E-03}},
59 {'4', {Species::find_species_index("O3", "667"), 7.40475E-04}},
60 {'5', {Species::find_species_index("O3", "676"), 3.70237E-04}},
61 }},
62 {4,
63 {
64 // N2O
65 {'1', {Species::find_species_index("N2O", "446"), 9.90333E-01}},
66 {'2', {Species::find_species_index("N2O", "456"), 3.64093E-03}},
67 {'3', {Species::find_species_index("N2O", "546"), 3.64093E-03}},
68 {'4', {Species::find_species_index("N2O", "448"), 1.98582E-03}},
69 {'5', {Species::find_species_index("N2O", "447"), 3.69280E-04}},
70 }},
71 {5,
72 {
73 // CO
74 {'1', {Species::find_species_index("CO", "26"), 9.86544E-01}},
75 {'2', {Species::find_species_index("CO", "36"), 1.10836E-02}},
76 {'3', {Species::find_species_index("CO", "28"), 1.97822E-03}},
77 {'4', {Species::find_species_index("CO", "27"), 3.67867E-04}},
78 {'5', {Species::find_species_index("CO", "38"), 2.22250E-05}},
79 {'6', {Species::find_species_index("CO", "37"), 4.13292E-06}},
80 }},
81 {6,
82 {
83 // CH4
84 {'1', {Species::find_species_index("CH4", "211"), 9.88274E-01}},
85 {'2', {Species::find_species_index("CH4", "311"), 1.11031E-02}},
86 {'3', {Species::find_species_index("CH4", "212"), 6.15751E-04}},
87 {'4', {Species::find_species_index("CH4", "312"), 6.91785E-06}},
88 }},
89 {7,
90 {
91 // O2
92 {'1', {Species::find_species_index("O2", "66"), 9.95262E-01}},
93 {'2', {Species::find_species_index("O2", "68"), 3.99141E-03}},
94 {'3', {Species::find_species_index("O2", "67"), 7.42235E-04}},
95 }},
96 {8,
97 {
98 // NO
99 {'1', {Species::find_species_index("NO", "46"), 9.93974E-01}},
100 {'2', {Species::find_species_index("NO", "56"), 3.65431E-03}},
101 {'3', {Species::find_species_index("NO", "48"), 1.99312E-03}},
102 }},
103 {9,
104 {
105 // SO2
106 {'1', {Species::find_species_index("SO2", "626"), 9.45678E-01}},
107 {'2', {Species::find_species_index("SO2", "646"), 4.19503E-02}},
108 {'3', {Species::find_species_index("SO2", "636"), 7.46446E-03}},
109 {'4', {Species::find_species_index("SO2", "628"), 3.79256E-03}},
110 }},
111 {10,
112 {
113 // NO2
114 {'1', {Species::find_species_index("NO2", "646"), 9.91616E-01}},
115 {'2', {Species::find_species_index("NO2", "656"), 3.64564E-03}},
116 }},
117 {11,
118 {
119 // NH3
120 {'1', {Species::find_species_index("NH3", "4111"), 9.95872E-01}},
121 {'2', {Species::find_species_index("NH3", "5111"), 3.66129E-03}},
122 }},
123 {12,
124 {
125 // HNO3
126 {'1', {Species::find_species_index("HNO3", "146"), 9.89110E-01}},
127 {'2', {Species::find_species_index("HNO3", "156"), 3.63643E-03}},
128 }},
129 {13,
130 {
131 // OH
132 {'1', {Species::find_species_index("OH", "61"), 9.97473E-01}},
133 {'2', {Species::find_species_index("OH", "81"), 2.00014E-03}},
134 {'3', {Species::find_species_index("OH", "62"), 1.55371E-04}},
135 }},
136 {14,
137 {
138 // HF
139 {'1', {Species::find_species_index("HF", "19"), 9.99844E-01}},
140 {'2', {Species::find_species_index("HF", "29"), 1.55741E-04}},
141 }},
142 {15,
143 {
144 // HCl
145 {'1', {Species::find_species_index("HCl", "15"), 7.57587E-01}},
146 {'2', {Species::find_species_index("HCl", "17"), 2.42257E-01}},
147 {'3', {Species::find_species_index("HCl", "25"), 1.18005E-04}},
148 {'4', {Species::find_species_index("HCl", "27"), 3.77350E-05}},
149 }},
150 {16,
151 {
152 // HBr
153 {'1', {Species::find_species_index("HBr", "19"), 5.06781E-01}},
154 {'2', {Species::find_species_index("HBr", "11"), 4.93063E-01}},
155 {'3', {Species::find_species_index("HBr", "29"), 7.89384E-05}},
156 {'4', {Species::find_species_index("HBr", "21"), 7.68016E-05}},
157 }},
158 {17,
159 {
160 // HI
161 {'1', {Species::find_species_index("HI", "17"), 9.99844E-01}},
162 {'2', {Species::find_species_index("HI", "27"), 1.55741E-04}},
163 }},
164 {18,
165 {
166 // ClO
167 {'1', {Species::find_species_index("ClO", "56"), 7.55908E-01}},
168 {'2', {Species::find_species_index("ClO", "76"), 2.41720E-01}},
169 }},
170 {19,
171 {
172 // OCS
173 {'1', {Species::find_species_index("OCS", "622"), 9.37395E-01}},
174 {'2', {Species::find_species_index("OCS", "624"), 4.15828E-02}},
175 {'3', {Species::find_species_index("OCS", "632"), 1.05315E-02}},
176 {'4', {Species::find_species_index("OCS", "623"), 7.39908E-03}},
177 {'5', {Species::find_species_index("OCS", "822"), 1.87967E-03}},
178 {'6', {Species::find_species_index("OCS", "634"), 4.67176E-04}},
179 }},
180 {20,
181 {
182 // H2CO
183 {'1', {Species::find_species_index("H2CO", "126"), 9.86237E-01}},
184 {'2', {Species::find_species_index("H2CO", "136"), 1.10802E-02}},
185 {'3', {Species::find_species_index("H2CO", "128"), 1.97761E-03}},
186 }},
187 {21,
188 {
189 // HOCl
190 {'1', {Species::find_species_index("HOCl", "165"), 7.55790E-01}},
191 {'2', {Species::find_species_index("HOCl", "167"), 2.41683E-01}},
192 }},
193 {22,
194 {
195 // N2
196 {'1', {Species::find_species_index("N2", "44"), 9.92687E-01}},
197 {'2', {Species::find_species_index("N2", "45"), 7.29916E-03}},
198 }},
199 {23,
200 {
201 // HCN
202 {'1', {Species::find_species_index("HCN", "124"), 9.85114E-01}},
203 {'2', {Species::find_species_index("HCN", "134"), 1.10676E-02}},
204 {'3', {Species::find_species_index("HCN", "125"), 3.62174E-03}},
205 }},
206 {24,
207 {
208 // CH3Cl
209 {'1', {Species::find_species_index("CH3Cl", "215"), 7.48937E-01}},
210 {'2', {Species::find_species_index("CH3Cl", "217"), 2.39491E-01}},
211 }},
212 {25,
213 {
214 // H2O2
215 {'1', {Species::find_species_index("H2O2", "1661"), 9.94952E-01}},
216 }},
217 {26,
218 {
219 // C2H2
220 {'1', {Species::find_species_index("C2H2", "1221"), 9.77599E-01}},
221 {'2', {Species::find_species_index("C2H2", "1231"), 2.19663E-02}},
222 {'3', {Species::find_species_index("C2H2", "1222"), 3.04550E-04}},
223 }},
224 {27,
225 {
226 // C2H6
227 {'1', {Species::find_species_index("C2H6", "1221"), 9.76990E-01}},
228 {'2', {Species::find_species_index("C2H6", "1231"), 2.19526E-02}},
229 }},
230 {28,
231 {
232 // PH3
233 {'1', {Species::find_species_index("PH3", "1111"), 9.99533E-01}},
234 }},
235 {29,
236 {
237 // COF2
238 {'1', {Species::find_species_index("COF2", "269"), 9.86544E-01}},
239 {'2', {Species::find_species_index("COF2", "369"), 1.10837E-02}},
240 }},
241 {30,
242 {
243 // SF6
244 {'1', {Species::find_species_index("SF6", "29"), 9.50180E-01}},
245 }},
246 {31,
247 {
248 // H2S
249 {'1', {Species::find_species_index("H2S", "121"), 9.49884E-01}},
250 {'2', {Species::find_species_index("H2S", "141"), 4.21369E-02}},
251 {'3', {Species::find_species_index("H2S", "131"), 7.49766E-03}},
252 }},
253 {32,
254 {
255 // HCOOH
256 {'1', {Species::find_species_index("HCOOH", "126"), 9.83898E-01}},
257 }},
258 {33,
259 {
260 // HO2
261 {'1', {Species::find_species_index("HO2", "166"), 9.95107E-01}},
262 }},
263 {34,
264 {
265 // O
266 {'1', {Species::find_species_index("O", "6"), 9.97628E-01}},
267 }},
268 {35,
269 {
270 // ClONO2
271 {'1', {Species::find_species_index("ClONO2", "5646"), 7.49570E-01}},
272 {'2', {Species::find_species_index("ClONO2", "7646"), 2.39694E-01}},
273 }},
274 {36,
275 {
276 // NO+
277 {'1', {Species::find_species_index("NO+", "46"), 9.93974E-01}},
278 }},
279 {37,
280 {
281 // HOBr
282 {'1', {Species::find_species_index("HOBr", "169"), 5.05579E-01}},
283 {'2', {Species::find_species_index("HOBr", "161"), 4.91894E-01}},
284 }},
285 {38,
286 {
287 // C2H4
288 {'1', {Species::find_species_index("C2H4", "221"), 9.77294E-01}},
289 {'2', {Species::find_species_index("C2H4", "231"), 2.19595E-02}},
290 }},
291 {39,
292 {
293 // CH3OH
294 {'1', {Species::find_species_index("CH3OH", "2161"), 9.85930E-01}},
295 }},
296 {40,
297 {
298 // CH3Br
299 {'1', {Species::find_species_index("CH3Br", "219"), 5.00995E-01}},
300 {'2', {Species::find_species_index("CH3Br", "211"), 4.87433E-01}},
301 }},
302 {41,
303 {
304 // CH3CN
305 {'1', {Species::find_species_index("CH3CN", "2124"), 9.73866E-01}},
306 }},
307 {42,
308 {
309 // CF4
310 {'1', {Species::find_species_index("CF4", "29"), 9.88890E-01}},
311 }},
312 {43,
313 {
314 // C4H2
315 {'1', {Species::find_species_index("C4H2", "2211"), 9.55998E-01}},
316 }},
317 {44,
318 {
319 // HC3N
320 {'1', {Species::find_species_index("HC3N", "12224"), 9.63346E-01}},
321 }},
322 {45,
323 {
324 // H2
325 {'1', {Species::find_species_index("H2", "11"), 9.99688E-01}},
326 {'2', {Species::find_species_index("H2", "12"), 3.11432E-04}},
327 }},
328 {46,
329 {
330 // CS
331 {'1', {Species::find_species_index("CS", "22"), 9.39624E-01}},
332 {'2', {Species::find_species_index("CS", "24"), 4.16817E-02}},
333 {'3', {Species::find_species_index("CS", "32"), 1.05565E-02}},
334 {'4', {Species::find_species_index("CS", "23"), 7.41668E-03}},
335 }},
336 {47,
337 {
338 // SO3
339 {'1', {Species::find_species_index("SO3", "26"), 9.43434E-01}},
340 }},
341 {48,
342 {
343 // C2N2
344 {'1', {Species::find_species_index("C2N2", "4224"), 9.70752E-01}},
345 }},
346 {49,
347 {
348 // COCl2
349 {'1', {Species::find_species_index("COCl2", "2655"), 5.66392E-01}},
350 {'2', {Species::find_species_index("COCl2", "2657"), 3.62235E-01}},
351 }},
352 {50,
353 {
354 // SO
355 {'1', {Species::find_species_index("SO", "26"), 9.47926E-01}},
356 {'2', {Species::find_species_index("SO", "46"), 4.20500E-02}},
357 {'3', {Species::find_species_index("SO", "28"), 1.90079E-03}},
358 }},
359 {51,
360 {
361 // CH3F
362 {'1', {Species::find_species_index("CH3F", "219"), 9.88428E-01}},
363 }},
364 {52,
365 {
366 // GeH4
367 {'1', {Species::find_species_index("GeH4", "411"), 3.65172E-01}},
368 {'2', {Species::find_species_index("GeH4", "211"), 2.74129E-01}},
369 {'3', {Species::find_species_index("GeH4", "011"), 2.05072E-01}},
370 {'4', {Species::find_species_index("GeH4", "311"), 7.75517E-02}},
371 {'5', {Species::find_species_index("GeH4", "611"), 7.75517E-02}},
372 }},
373 {53,
374 {
375 // CS2
376 {'1', {Species::find_species_index("CS2", "222"), 8.92811E-01}},
377 {'2', {Species::find_species_index("CS2", "224"), 7.92103E-02}},
378 {'3', {Species::find_species_index("CS2", "223"), 1.40944E-02}},
379 {'4', {Species::find_species_index("CS2", "232"), 1.00306E-02}},
380 }},
381 {54,
382 {
383 // CH3I
384 {'1', {Species::find_species_index("CH3I", "217"), 9.88428E-01}},
385 }},
386 {55,
387 {
388 // NF3
389 {'1', {Species::find_species_index("NF3", "4999"), 9.96337E-01}},
390 }},
391};
392
393using OurHitranMap = std::map<Index, std::map<char, Species::IsotopeRecord>>;
394
399 OurHitranMap species_map;
400 for (auto& specs : string_map) {
401 ARTS_ASSERT(specs.second.find('1') not_eq specs.second.cend(),
402 "Must have species '1' in map")
403 for (auto& isot : specs.second) {
404 ARTS_ASSERT(isot.second.first >= 0,
405 "Undefined species in ARTS found in HITRAN data")
406 species_map[specs.first][isot.first] =
407 Species::Isotopologues[isot.second.first];
408 }
409 }
410 return species_map;
411}
412
420 // Map of all HITRAN species
421 static const OurHitranMap hitmap = to_species_map(molparam_map);
422
423 // Search the map with pointers so that we can throw manually if something is bad
424
425 if (auto species_list = hitmap.find(molnum); species_list not_eq hitmap.cend()) {
426 if (auto species_info = species_list -> second.find(isonum); species_info not_eq species_list -> second.cend()) {
427 return QuantumIdentifier{Species::find_species_index(species_info->second)};
428 }
429 }
431 "Species ",
432 molnum, ' ', isonum,
433 " does not exist in ARTS' HITRAN implementation\n"
434 "If you are using a new version of HITRAN that has added the species, please consider\n"
435 "contacting the ARTS developers so we can append the species to our list and make this work.\n");
436}
437
439 return from_mol_iso(mol, isochar);
440}
441
442Numeric ratio_from_lookup(Index mol, char isochar) {
443 return molparam_map.at(mol).at(isochar).second;
444}
445
448 for (auto& x : data) {
449 for (auto& y : x.second) {
450 out.data[y.second.first] = y.second.second;
451 }
452 }
453 return out;
454}
455
458}
459} // namespace Hitran
#define ARTS_ASSERT(condition,...)
Definition: debug.h:82
#define ARTS_USER_ERROR(...)
Definition: debug.h:150
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
std::map< Index, std::map< char, std::pair< Index, Numeric > > > HitranMap
const HitranMap molparam_map
The latest version of the HITRAN online molparam.txt file as a map.
SpeciesIsotopologueRatios isotopologue_ratios_impl(const HitranMap &data)
QuantumIdentifier from_mol_iso(Index molnum, char isonum)
Returns the species if possible or throws an error if it cannot be found.
std::map< Index, std::map< char, Species::IsotopeRecord > > OurHitranMap
SpeciesIsotopologueRatios isotopologue_ratios()
QuantumIdentifier id_from_lookup(Index mol, char isochar)
Finds the ID of the ARTS species from HITRAN.
OurHitranMap to_species_map(const HitranMap &string_map)
Turns the string-map required at compile time into a species-map to be used as a static runtime map.
Numeric ratio_from_lookup(Index mol, char isochar)
Finds the isotopologue ratio of the species from HITRAN.
constexpr std::array Isotopologues
A list of all ARTS isotopologues, note how the species enum class input HAS to be sorted.
Definition: isotopologues.h:57
constexpr Index find_species_index(const Species spec, const std::string_view isot) noexcept
A logical struct for global quantum numbers with species identifiers.
std::array< Numeric, maxsize > data