ARTS 2.5.0 (git: 9ee3ac6c)
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 <map>
32#include "array.h"
33#include "arts.h"
34#include "mystring.h"
35#include "wsv_aux.h"
36
39namespace global_data {
41map<String, Index> WsvGroupMap;
42} // namespace global_data
43
46
48 valid_keyword_groups.resize(0);
49 valid_keyword_groups.push_back(get_wsv_group_id("String"));
50 valid_keyword_groups.push_back(get_wsv_group_id("Index"));
51 valid_keyword_groups.push_back(get_wsv_group_id("Numeric"));
52 valid_keyword_groups.push_back(get_wsv_group_id("ArrayOfString"));
53 valid_keyword_groups.push_back(get_wsv_group_id("ArrayOfIndex"));
54 valid_keyword_groups.push_back(get_wsv_group_id("Vector"));
55}
56
60 for (Index i = 0; i < wsv_group_names.nelem(); ++i) {
62 }
63}
64
66
79
80 //--------------------< Build the group names array >--------------------
81 // Initialize to empty, just in case.
82 wsv_group_names.resize(0);
83
84 wsv_group_names.push_back("AbsorptionLines");
85 wsv_group_names.push_back("Agenda");
86 wsv_group_names.push_back("Any");
87 wsv_group_names.push_back("ArrayOfAbsorptionLines");
88 wsv_group_names.push_back("ArrayOfArrayOfAbsorptionLines");
89 wsv_group_names.push_back("ArrayOfAgenda");
90 wsv_group_names.push_back("ArrayOfArrayOfGriddedField1");
91 wsv_group_names.push_back("ArrayOfArrayOfGriddedField2");
92 wsv_group_names.push_back("ArrayOfArrayOfGriddedField3");
93 wsv_group_names.push_back("ArrayOfArrayOfIndex");
94 wsv_group_names.push_back("ArrayOfArrayOfMatrix");
95 wsv_group_names.push_back("ArrayOfPpath");
96 wsv_group_names.push_back("ArrayOfArrayOfPropagationMatrix");
97 wsv_group_names.push_back("ArrayOfArrayOfRadiationVector");
98 wsv_group_names.push_back("ArrayOfArrayOfScatteringMetaData");
99 wsv_group_names.push_back("ArrayOfArrayOfSingleScatteringData");
100 wsv_group_names.push_back("ArrayOfArrayOfSpeciesTag");
101 wsv_group_names.push_back("ArrayOfArrayOfStokesVector");
102 wsv_group_names.push_back("ArrayOfArrayOfString");
103 wsv_group_names.push_back("ArrayOfArrayOfTensor3");
104 wsv_group_names.push_back("ArrayOfArrayOfTensor6");
105 wsv_group_names.push_back("ArrayOfArrayOfTime");
106 wsv_group_names.push_back("ArrayOfArrayOfTransmissionMatrix");
107 wsv_group_names.push_back("ArrayOfArrayOfVector");
108 wsv_group_names.push_back("ArrayOfCIARecord");
109 wsv_group_names.push_back("ArrayOfGriddedField1");
110 wsv_group_names.push_back("ArrayOfGriddedField2");
111 wsv_group_names.push_back("ArrayOfGriddedField3");
112 wsv_group_names.push_back("ArrayOfGriddedField4");
113 wsv_group_names.push_back("ArrayOfIndex");
114 wsv_group_names.push_back("ArrayOfJacobianTarget");
115 wsv_group_names.push_back("ArrayOfMatrix");
116 wsv_group_names.push_back("ArrayOfPropagationMatrix");
117 wsv_group_names.push_back("ArrayOfQuantumIdentifier");
118 wsv_group_names.push_back("ArrayOfRadiationVector");
119 wsv_group_names.push_back("ArrayOfRetrievalQuantity");
120 wsv_group_names.push_back("ArrayOfScatteringMetaData");
121 wsv_group_names.push_back("ArrayOfSingleScatteringData");
122 wsv_group_names.push_back("ArrayOfSpeciesTag");
123 wsv_group_names.push_back("ArrayOfSparse");
124 wsv_group_names.push_back("ArrayOfStokesVector");
125 wsv_group_names.push_back("ArrayOfString");
126 wsv_group_names.push_back("ArrayOfTelsemAtlas");
127 wsv_group_names.push_back("ArrayOfTensor3");
128 wsv_group_names.push_back("ArrayOfTensor4");
129 wsv_group_names.push_back("ArrayOfTensor5");
130 wsv_group_names.push_back("ArrayOfTensor6");
131 wsv_group_names.push_back("ArrayOfTensor7");
132 wsv_group_names.push_back("ArrayOfTime");
133 wsv_group_names.push_back("ArrayOfTransmissionMatrix");
134 wsv_group_names.push_back("ArrayOfVector");
135 wsv_group_names.push_back("ArrayOfXsecRecord");
136 wsv_group_names.push_back("CIARecord");
137 wsv_group_names.push_back("CovarianceMatrix");
138 wsv_group_names.push_back("EnergyLevelMap");
139 wsv_group_names.push_back("GasAbsLookup");
140 wsv_group_names.push_back("GridPos");
141 wsv_group_names.push_back("GriddedField1");
142 wsv_group_names.push_back("GriddedField2");
143 wsv_group_names.push_back("GriddedField3");
144 wsv_group_names.push_back("GriddedField4");
145 wsv_group_names.push_back("GriddedField5");
146 wsv_group_names.push_back("GriddedField6");
147 wsv_group_names.push_back("HitranRelaxationMatrixData");
148 wsv_group_names.push_back("Index");
149 wsv_group_names.push_back("JacobianTarget");
150 wsv_group_names.push_back("MapOfErrorCorrectedSuddenData");
151 wsv_group_names.push_back("MCAntenna");
152 wsv_group_names.push_back("Matrix");
153 wsv_group_names.push_back("Numeric");
154 wsv_group_names.push_back("Ppath");
155 wsv_group_names.push_back("PropagationMatrix");
156 wsv_group_names.push_back("QuantumIdentifier");
157 wsv_group_names.push_back("RadiationVector");
158 wsv_group_names.push_back("Rational");
159 wsv_group_names.push_back("ScatteringMetaData");
160 wsv_group_names.push_back("SingleScatteringData");
161 wsv_group_names.push_back("Sparse");
162 wsv_group_names.push_back("SpeciesIsotopologueRatios");
163 wsv_group_names.push_back("StokesVector");
164 wsv_group_names.push_back("String");
165 wsv_group_names.push_back("TelsemAtlas");
166 wsv_group_names.push_back("Tensor3");
167 wsv_group_names.push_back("Tensor4");
168 wsv_group_names.push_back("Tensor5");
169 wsv_group_names.push_back("Tensor6");
170 wsv_group_names.push_back("Tensor7");
171 wsv_group_names.push_back("Timer");
172 wsv_group_names.push_back("Time");
173 wsv_group_names.push_back("TessemNN");
174 wsv_group_names.push_back("TransmissionMatrix");
175 wsv_group_names.push_back("Vector");
176 wsv_group_names.push_back("Verbosity");
177
180}
181
182bool is_valid_keyword_group(const Index group) {
183 for (Index i = 0; i < valid_keyword_groups.nelem(); i++) {
184 if (valid_keyword_groups[i] == group) return true;
185 }
186
187 return false;
188}
189
191 ids.resize(0);
192
193 Index pos = 0;
194 while (pos < name.nelem()) {
195 switch (name[pos]) {
196 case ' ':
197 case '\r':
198 case '\t':
199 case '#':
200 name.erase(pos, 1);
201 break;
202 default:
203 pos++;
204 }
205 }
206
207 pos = 0;
208 Index prev = 0;
209 while (pos < name.nelem()) {
210 while (pos < name.nelem() && name[pos] != ',') pos++;
211 Index id = get_wsv_group_id(name.substr(prev, pos - prev));
212 if (id == -1) {
213 ids.resize(0);
214 return;
215 }
216 ids.push_back(id);
217 pos++;
218 prev = pos;
219 }
220}
221
222bool is_agenda_group_id(const Index group) {
223 return (group == get_wsv_group_id("Agenda") ||
224 group == get_wsv_group_id("ArrayOfAgenda"));
225}
226
229 map<String, Index>::const_iterator it = WsvGroupMap.find(name);
230 if (it == WsvGroupMap.end())
231 return -1;
232 else
233 return it->second;
234}
235
236String get_array_groups_as_string(bool basetype_is_group,
237 bool return_basetype_only) {
239 String arraygroups;
240
241 bool first = true;
242 for (Index i = 0; i < wsv_group_names.nelem(); i++) {
243 if (wsv_group_names[i].substr(0, String("ArrayOf").length()) == "ArrayOf") {
244 const String basetype = wsv_group_names[i].substr(
245 String("ArrayOf").length(), wsv_group_names[i].length());
246 bool basetype_exists = (get_wsv_group_id(basetype) != -1);
247
248 if (return_basetype_only) {
249 // Return only the basetype of the array,
250 // skip arrays whose basetype is not a WSV group
251 if (basetype_exists) {
252 if (!first)
253 arraygroups += ", ";
254 else
255 first = false;
256 arraygroups += basetype;
257 }
258 } else {
259 if (!basetype_is_group || (basetype_is_group && basetype_exists)) {
260 if (!first)
261 arraygroups += ", ";
262 else
263 first = false;
264 arraygroups += wsv_group_names[i];
265 }
266 }
267 }
268 }
269 return arraygroups;
270}
This file contains the definition of Array.
The global header file for ARTS.
Index nelem() const ARTS_NOEXCEPT
Number of elements.
Definition: array.h:195
Index nelem() const
Number of elements.
Definition: mystring.h:253
Index get_wsv_group_id(const String &name)
Returns the id of the given group.
Definition: groups.cc:227
bool is_agenda_group_id(const Index group)
Check if group is an agenda group.
Definition: groups.cc:222
String get_array_groups_as_string(bool basetype_is_group, bool return_basetype_only)
Return string list of array types.
Definition: groups.cc:236
void define_valid_keyword_groups()
Definition: groups.cc:47
void define_wsv_group_names()
Define the array of workspace variable group names.
Definition: groups.cc:77
bool is_valid_keyword_group(const Index group)
Definition: groups.cc:182
void get_wsv_group_ids(ArrayOfIndex &ids, String name)
Returns list of ids of the given group names.
Definition: groups.cc:190
ArrayOfIndex valid_keyword_groups
Definition: groups.cc:45
void define_wsv_group_map()
Definition: groups.cc:57
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:287
const map< String, Index > WsvGroupMap
The map associated with wsv_group_names.
Definition: groups.cc:41
const ArrayOfString wsv_group_names
The names associated with Wsv groups as Strings.
Definition: global_data.h:90
Auxiliary header stuff related to workspace variable groups.