ARTS 2.5.9 (git: 825fa5f2)
groups.cc
Go to the documentation of this file.
1/* Copyright (C) 2000-2012
2 Stefan Buehler <sbuehler@ltu.se>
3 Patrick Eriksson <patrick.eriksson@chalmers.se>
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 USA. */
19
31#include "groups.h"
32
33#include <map>
34
35#include "array.h"
36#include "arts.h"
37#include "mystring.h"
38
41namespace global_data {
43map<String, Index> WsvGroupMap;
44} // namespace global_data
45
49 for (Index i = 0; i < wsv_groups.nelem(); ++i) {
50 WsvGroupMap[wsv_groups[i]] = i;
51 }
52}
53
55
68
69 //--------------------< Build the group names array >--------------------
70 // Initialize to empty, just in case.
71 wsv_groups.resize(0);
72
73 wsv_groups.emplace_back(
74 "AbsorptionLines",
75 "Contains line-by-line absorption information for a number of related absorption lines");
76
77 wsv_groups.emplace_back(
78 "Agenda", "Describes a set of function calls and variable definitions");
79
80 wsv_groups.emplace_back(
81 "Any",
82 "Meta type for when methods can take any argument (avoid manual use)");
83
84 wsv_groups.emplace_back("ArrayOfAbsorptionLines",
85 "A list of *AbsorptionLines*");
86
87 wsv_groups.emplace_back("ArrayOfArrayOfAbsorptionLines",
88 "A list of *ArrayOfAbsorptionLines*");
89
90 wsv_groups.emplace_back("ArrayOfAgenda", "A list of *Agenda*");
91
92 wsv_groups.emplace_back("ArrayOfArrayOfGriddedField1",
93 "A list of *ArrayOfGriddedField1*");
94
95 wsv_groups.emplace_back("ArrayOfArrayOfGriddedField2",
96 "A list of *ArrayOfGriddedField2*");
97
98 wsv_groups.emplace_back("ArrayOfArrayOfGriddedField3",
99 "A list of *ArrayOfGriddedField3*");
100
101 wsv_groups.emplace_back("ArrayOfArrayOfIndex", "A list of *ArrayOfIndex*");
102
103 wsv_groups.emplace_back("ArrayOfArrayOfMatrix", "A list of *ArrayOfMatrix*");
104
105 wsv_groups.emplace_back("ArrayOfPpath", "A list of *Ppath*");
106
107 wsv_groups.emplace_back("ArrayOfArrayOfPropagationMatrix",
108 "A list of *ArrayOfPropagationMatrix*");
109
110 wsv_groups.emplace_back("ArrayOfArrayOfRadiationVector",
111 "A list of *ArrayOfRadiationVector*");
112
113 wsv_groups.emplace_back("ArrayOfArrayOfScatteringMetaData",
114 "A list of *ArrayOfScatteringMetaData*");
115
116 wsv_groups.emplace_back("ArrayOfArrayOfSingleScatteringData",
117 "A list of *ArrayOfSingleScatteringData*");
118
119 wsv_groups.emplace_back("ArrayOfArrayOfSpeciesTag",
120 "A list of *ArrayOfSpeciesTag*");
121
122 wsv_groups.emplace_back("ArrayOfArrayOfStokesVector",
123 "A list of *ArrayOfStokesVector*");
124
125 wsv_groups.emplace_back("ArrayOfArrayOfString", "A list of *ArrayOfString*");
126
127 wsv_groups.emplace_back("ArrayOfArrayOfTensor3",
128 "A list of *ArrayOfTensor3*");
129
130 wsv_groups.emplace_back("ArrayOfArrayOfTensor6",
131 "A list of *ArrayOfTensor6*");
132
133 wsv_groups.emplace_back("ArrayOfArrayOfTime", "A list of *ArrayOfTime*");
134
135 wsv_groups.emplace_back("ArrayOfArrayOfTransmissionMatrix",
136 "A list of *ArrayOfTransmissionMatrix*");
137
138 wsv_groups.emplace_back("ArrayOfArrayOfVector", "A list of *ArrayOfVector*");
139
140 wsv_groups.emplace_back("ArrayOfCIARecord", "A list of *CIARecord*");
141
142 wsv_groups.emplace_back("ArrayOfGriddedField1", "A list of *GriddedField1*");
143
144 wsv_groups.emplace_back("ArrayOfGriddedField2", "A list of *GriddedField2*");
145
146 wsv_groups.emplace_back("ArrayOfGriddedField3", "A list of *GriddedField3*");
147
148 wsv_groups.emplace_back("ArrayOfGriddedField4", "A list of *GriddedField4*");
149
150 wsv_groups.emplace_back("ArrayOfIndex", "A list of *Index*");
151
152 wsv_groups.emplace_back("ArrayOfJacobianTarget",
153 "A list of *JacobianTarget*");
154
155 wsv_groups.emplace_back("ArrayOfMatrix", "A list of *Matrix*");
156
157 wsv_groups.emplace_back("ArrayOfPropagationMatrix",
158 "A list of *PropagationMatrix*");
159
160 wsv_groups.emplace_back("ArrayOfQuantumIdentifier",
161 "A list of *QuantumIdentifier*");
162
163 wsv_groups.emplace_back("ArrayOfRadiationVector",
164 "A list of *RadiationVector*");
165
166 wsv_groups.emplace_back("ArrayOfRetrievalQuantity",
167 "A list of retrieval quantitities");
168
169 wsv_groups.emplace_back("ArrayOfScatteringMetaData",
170 "A list of *ScatteringMetaData*");
171
172 wsv_groups.emplace_back("ArrayOfSingleScatteringData",
173 "A list of *SingleScatteringData*");
174
175 wsv_groups.emplace_back("ArrayOfSpeciesTag", R"--(A list of species tags
176
177These tags include the species and a lot of optional information
178about the isotopologue, the absorption scheme, and the frequency limits)--");
179
180 wsv_groups.emplace_back("ArrayOfSparse", "A list of *Sparse*");
181
182 wsv_groups.emplace_back("ArrayOfStar", "A list of star");
183
184 wsv_groups.emplace_back("ArrayOfStokesVector", "A list of *StokesVector*");
185
186 wsv_groups.emplace_back("ArrayOfString", "A list of *String*");
187
188 wsv_groups.emplace_back("ArrayOfTelsemAtlas", "A list of *TelsemAtlas*");
189
190 wsv_groups.emplace_back("ArrayOfTensor3", "A list of *Tensor3*");
191
192 wsv_groups.emplace_back("ArrayOfTensor4", "A list of *Tensor4*");
193
194 wsv_groups.emplace_back("ArrayOfTensor5", "A list of *Tensor5*");
195
196 wsv_groups.emplace_back("ArrayOfTensor6", "A list of *Tensor6*");
197
198 wsv_groups.emplace_back("ArrayOfTensor7", "A list of *Tensor7*");
199
200 wsv_groups.emplace_back("ArrayOfTime", "A list of *Time*");
201
202 wsv_groups.emplace_back("ArrayOfTransmissionMatrix",
203 "A list of *TransmissionMatrix*");
204
205 wsv_groups.emplace_back("ArrayOfVector", "A list of *Vector*");
206
207 wsv_groups.emplace_back("ArrayOfXsecRecord",
208 R"--(A list of cross-section records
209
210These cross-section records contains information about the valid temperature and
211pressure ranges as well as well as the fitting coefficients used to compute
212and interpolate the cross-section to other temperatures and pressures)--");
213
214 wsv_groups.emplace_back(
215 "CIARecord",
216 R"--(Contains information to compute collision induced absorption for a pair of species
217
218Holds an the record data in a gridded field with grids of temperature and frequency in
219units of m^5 molec^(-2) )--");
220
221 wsv_groups.emplace_back("CallbackFunction",
222 "Used to inject custom code into *Agenda*");
223
224 wsv_groups.emplace_back("CovarianceMatrix", "Contains the covariance matrix");
225
226 wsv_groups.emplace_back("EnergyLevelMap",
227 R"--(Maps data based on energy levels
228
229Used for keeping track of non-local thermodynamic equilibrium data)--");
230
231 wsv_groups.emplace_back("GasAbsLookup", R"--(An absorption lookup table
232
233This class holds an absorption lookup table, as well as all
234information that is necessary to use the table to extract
235absorption)--");
236
237 wsv_groups.emplace_back("GridPos", "A position in a grid");
238
239 wsv_groups.emplace_back("GriddedField1",
240 R"--(A 1 dimensional gridded set of *Numeric* data
241
242The grid is 1 *Vector* or *ArrayOfString*
243
244Both the data and the grid may be named)--");
245
246 wsv_groups.emplace_back("GriddedField2",
247 R"--(A 2 dimensional gridded set *Numeric* data
248
249The grid is a combination of 2 *Vector* and/or *ArrayOfString*
250
251Both the data and the grid may be named)--");
252
253 wsv_groups.emplace_back("GriddedField3",
254 R"--(A 3 dimensional gridded set of *Numeric* data
255
256The grid is a combination of 3 *Vector* and/or *ArrayOfString*
257
258Both the data and the grid may be named)--");
259
260 wsv_groups.emplace_back("GriddedField4",
261 R"--(A 4 dimensional gridded set of *Numeric* data
262
263The grid is a combination of 4 *Vector* and/or *ArrayOfString*
264
265Both the data and the grid may be named)--");
266
267 wsv_groups.emplace_back("GriddedField5",
268 R"--(A 5 dimensional gridded set of *Numeric* data
269
270The grid is a combination of 5 *Vector* and/or *ArrayOfString*
271
272Both the data and the grid may be named)--");
273
274 wsv_groups.emplace_back("GriddedField6",
275 R"--(A 6 dimensional gridded set of *Numeric* data
276
277The grid is a combination of 6 *Vector* and/or *ArrayOfString*
278
279Both the data and the grid may be named)--");
280
281 wsv_groups.emplace_back("HitranRelaxationMatrixData",
282 "Wraps data required to use Hitran line mixing");
283
284 wsv_groups.emplace_back("Index", "A 64 bit signed integer type");
285
286 wsv_groups.emplace_back(
287 "JacobianTarget", "A single target if a partial derivative computation");
288
289 wsv_groups.emplace_back(
290 "MapOfErrorCorrectedSuddenData",
291 R"--(A map of data required for computing the error-corrected-sudden relaxation matrix
292
293This map contains a list of an underlying data type. This underlying data type contains a
294*QuantumIdentifier* and a list of species dependent computational data for various components
295required to compute the relaxation matrix
296
297If there is no identifier or species avaialable, default values that approximates a diagonal
298relaxation matrix are set)--");
299
300 wsv_groups.emplace_back("MCAntenna", "An Antenna object used by *MCGeneral*");
301
302 wsv_groups.emplace_back("Matrix", "A 2 dimensional array of *Numeric*");
303
304 wsv_groups.emplace_back("Numeric", "IEEE 754 binary64 floating point number");
305
306 wsv_groups.emplace_back("Ppath", "Describes a propagation path");
307
308 wsv_groups.emplace_back("PredefinedModelData",
309 R"--(Contains any data required for a predefined model)--");
310
311 wsv_groups.emplace_back("PropagationMatrix",
312 R"--(The propagation matrix data is help by this type
313
314This type is related to *StokesVector*
315
316The data type is *Tensor4* in units of [1/m]
317
318The dimensionality is kept as:
319
320Number of frequencies as *Index* (usually from *f_grid*)
321Number of zenith angles as *Index*
322Number of azimuth angles as *Index*
323The Stokes dimension as *Index* (usually from *stokes_dim*)
324
325An individual propagation matrix (i.e., for a given frequency, zenith,
326and azimuth angle) follows certain symmetries depending on the Stokes
327dimension
328
329For Stokes dimension 4:
330
331K11 K12 K13 K14
332K12 K11 K23 K24
333K13 -K23 K11 K34
334K14 -K24 -K34 K11
335
336For Stokes dimension 3:
337
338K11 K12 K13
339K12 K11 K23
340K13 -K23 K11
341
342For Stokes dimension 2:
343
344K11 K12
345K12 K11
346
347For Stokes dimension 1:
348
349K11
350
351The propagation matrix make use of these symmetries to computate the matrix inverses and exponents
352required to turn the data into a *TransmissionMatrix* (with information about the distance))--");
353
354 wsv_groups.emplace_back("QuantumIdentifier",
355 R"--(An ID for an absorption species state
356
357It contains information about the species and a set of quantum numbers
358and can thus be used to identify one of the following:
3591) a species
3602) an isotopologue of a species
3613) an absorption band of an isotopologue
3624) an absorption line of an isotopologue
3635) the energy level of absorption band(s) of an isotopologue
3646) the energy level of absorption line(s) of an isotopologue)--");
365
366 wsv_groups.emplace_back(
367 "RadiationVector",
368 R"--(Contains the radiation vector as a function of frequency
369
370This type is related to *TransmissionMatrix*
371
372The stokes dimensionality translates directly to the size of the vector
373
374Internally, this holds an efficiently packed list of these vectors
375
376This is often used in combination with *TransmissionMatrix* to compute the radiative
377transfer through the atmosphere
378
379It holds information about the radiance, unlike its cousin *StokesVector*, which holds information
380about the vector absorption/emission)--");
381
382 wsv_groups.emplace_back("Rational",
383 "Holds a rational number as two *Index* n / d");
384
385 wsv_groups.emplace_back("ScatteringMetaData",
386 "Holds meta data about the scattering");
387
388 wsv_groups.emplace_back("SingleScatteringData",
389 "Holds single scattering data");
390
391 wsv_groups.emplace_back("Sparse", "A sparse version of *Matrix*");
392
393 wsv_groups.emplace_back(
394 "SpeciesIsotopologueRatios",
395 "Contains a list of isotopologue ratios for all defined species");
396
397 wsv_groups.emplace_back("StokesVector", R"--(A stokes vector
398
399This type is related to *PropagationMatrix*
400
401The data type is *Tensor4* in units of [1/m]
402
403The dimensionality is kept as:
405Number of frequencies as *Index* (usually from *f_grid*)
406Number of zenith angles as *Index*
407Number of azimuth angles as *Index*
408The Stokes dimension as *Index* (usually from *stokes_dim*)
409
410This is often used to compute the source emission with the help of a *PropagationMatrix*)--");
411
412 wsv_groups.emplace_back("String", "Basic string type");
413
414 wsv_groups.emplace_back("TelsemAtlas", R"--(A telsem atlas
415
416Represents a Telsem2 atlas containing land surface microwave emissivities.
417Since the Atlas contains emissivities only for land surfaces, the data is
418stored in a sparse format.
419
420The emissivities are represented on an equal area grid and numbered
421sequentially starting with the first latitude band at -90 degrees and
422moving up to 90 degrees.
423
424The correspondance array contains the data indices for each cellnumber
425if it is contained in the Atlas and NAN otherwise.)--");
426
427 wsv_groups.emplace_back("Tensor3", "A 3 dimensional array of *Numeric*");
428
429 wsv_groups.emplace_back("Tensor4", "A 4 dimensional array of *Numeric*");
430
431 wsv_groups.emplace_back("Tensor5", "A 5 dimensional array of *Numeric*");
432
433 wsv_groups.emplace_back("Tensor6", "A 6 dimensional array of *Numeric*");
434
435 wsv_groups.emplace_back("Tensor7", "A 7 dimensional array of *Numeric*");
436
437 wsv_groups.emplace_back("Timer", "Represents a clock");
438
439 wsv_groups.emplace_back("Time", "Represents a time stamp");
440
441 wsv_groups.emplace_back(
442 "TessemNN", "Data required by TESSEM to calculate surface emissivity");
443
444 wsv_groups.emplace_back(
445 "TransmissionMatrix",
446 R"--(Contains the transmission matrix as a function of frequency
447
448This type is related to *RadiationVector*
449
450The stokes dimensionality squared translates directly to the size of the matrix
451
452Internally, this holds an efficiently packed list of these matrices
453
454This is often used in combination with *RadiationVector* to compute the radiative
455transfer through the atmosphere
456
457The transmission matrix is often computed from the combination of two *PropagationMatrix*
458at different atmospheric path points (using the distance between these points)
459
460It holds information about the polarized transmission, unlike its cousin *PropagationMatrix*,
461which holds information about the polarized absorption)--");
462
463 wsv_groups.emplace_back("Vector", "A 1 dimensional array of *Numeric*");
464
465 wsv_groups.emplace_back(
466 "Verbosity",
467 "Controls the screen, agenda, and file verbosity level (i.e. the level of information printed)");
468
469 std::sort(wsv_groups.begin(), wsv_groups.end(), [](auto& a, auto& b) {
470 return a.name < b.name;
471 });
472
474}
475
476Index get_wsv_group_id(const String& name) {
478 auto it = WsvGroupMap.find(name);
479 if (it == WsvGroupMap.end()) return -1;
480 return it->second;
481}
482
483void get_wsv_group_ids(ArrayOfIndex& ids, String name) {
484 ids.resize(0);
485
486 Index pos = 0;
487 while (pos < name.nelem()) {
488 switch (name[pos]) {
489 case ' ':
490 case '\r':
491 case '\t':
492 case '#':
493 name.erase(pos, 1);
494 break;
495 default:
496 pos++;
497 }
498 }
499
500 pos = 0;
501 Index prev = 0;
502 while (pos < name.nelem()) {
503 while (pos < name.nelem() && name[pos] != ',') pos++;
504 Index id = get_wsv_group_id(name.substr(prev, pos - prev));
505 if (id == -1) {
506 ids.resize(0);
507 return;
508 }
509 ids.push_back(id);
510 pos++;
511 prev = pos;
512 }
513}
514
515bool is_agenda_group_id(const Index group) {
516 return (group == get_wsv_group_id("Agenda") ||
517 group == get_wsv_group_id("ArrayOfAgenda"));
518}
519
520String get_array_groups_as_string(bool basetype_is_group,
521 bool return_basetype_only) {
523 String arraygroups;
524
525 bool first = true;
526 for (Index i = 0; i < wsv_groups.nelem(); i++) {
527 if (wsv_groups[i].name.substr(0, String("ArrayOf").length()) == "ArrayOf") {
528 const String basetype = wsv_groups[i].name.substr(
529 String("ArrayOf").length(), wsv_groups[i].name.length());
530 bool basetype_exists = (get_wsv_group_id(basetype) != -1);
531
532 if (return_basetype_only) {
533 // Return only the basetype of the array,
534 // skip arrays whose basetype is not a WSV group
535 if (basetype_exists) {
536 if (!first)
537 arraygroups += ", ";
538 else
539 first = false;
540 arraygroups += basetype;
541 }
542 } else {
543 if (!basetype_is_group || (basetype_is_group && basetype_exists)) {
544 if (!first)
545 arraygroups += ", ";
546 else
547 first = false;
548 arraygroups += wsv_groups[i];
549 }
550 }
551 }
552 }
553 return arraygroups;
554}
This file contains the definition of Array.
The global header file for ARTS.
This can be used to make arrays out of anything.
Definition: array.h:48
Index nelem() const ARTS_NOEXCEPT
Definition: array.h:92
Index nelem() const
Definition: mystring.h:189
Index get_wsv_group_id(const String &name)
Returns the id of the given group.
Definition: groups.cc:360
bool is_agenda_group_id(const Index group)
Check if group is an agenda group.
Definition: groups.cc:399
String get_array_groups_as_string(bool basetype_is_group, bool return_basetype_only)
Return string list of array types.
Definition: groups.cc:404
void get_wsv_group_ids(ArrayOfIndex &ids, String name)
Returns list of ids of the given group names.
Definition: groups.cc:367
void define_wsv_groups()
Define the array of workspace variable group names.
Definition: groups.cc:66
void define_wsv_group_map()
Definition: groups.cc:46
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
This file contains the definition of String, the ARTS string class.
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:216
const ArrayOfGroupRecord wsv_groups
The names associated with Wsv groups as Strings.
Definition: global_data.h:91
const map< String, Index > WsvGroupMap
The map associated with wsv_groups.
Definition: groups.cc:43
#define a
#define b