ARTS 2.5.11 (git: 6827797f)
gridded_fields.cc
Go to the documentation of this file.
1
16/*===========================================================================
17 === External declarations
18 ===========================================================================*/
19
20#include "gridded_fields.h"
21#include <iostream>
22#include <stdexcept>
23#include "exceptions.h"
24#include "mystring.h"
25
26using std::endl;
27using std::ostream;
28using std::ostringstream;
29using std::runtime_error;
30
31/*===========================================================================
32 === The functions (in alphabetical order)
33 ===========================================================================*/
34
36
42 ARTS_ASSERT(gf.get_dim() == dim);
43
44 for (Index i = 0; i < dim; i++) {
45 switch (gf.get_grid_type(i)) {
49 mstringgrids[i].resize(0);
50 break;
54 mnumericgrids[i].resize(0);
55 break;
56 }
57 }
58}
59
61
69const Vector& GriddedField::get_numeric_grid(Index i) const {
70 ARTS_ASSERT(i < dim);
72 mname.length() ? var_string(mname, " Grid ") : var_string("Grid "),
73 mgridnames[i].length() ? var_string(mgridnames[i]) : var_string(i),
74 " is not a numeric grid.")
75 return mnumericgrids[i];
76}
77
79
88 ARTS_ASSERT(i < dim);
90 mname.length() ? var_string(mname, " Grid ") : var_string("Grid "),
91 mgridnames[i].length() ? var_string(mgridnames[i]) : var_string(i),
92 " is not a numeric grid.")
93 return mnumericgrids[i];
94}
95
97
106 ARTS_ASSERT(i < dim);
108 mname.length() ? var_string(mname, " Grid ") : var_string("Grid "),
109 mgridnames[i].length() ? var_string(mgridnames[i]) : var_string(i),
110 " is not a string grid.")
111 return (mstringgrids[i]);
112}
113
115
124 ARTS_ASSERT(i < dim);
126 mname.length() ? var_string(mname, " Grid ") : var_string("Grid "),
127 mgridnames[i].length() ? var_string(mgridnames[i]) : var_string(i),
128 " is not a string grid.")
129 return (mstringgrids[i]);
130}
131
133
139void GriddedField::set_grid(Index i, const Vector& g) {
140 ARTS_ASSERT(i < dim);
142 mstringgrids[i].resize(0);
143 mnumericgrids[i] = g;
144}
145
147
153void GriddedField::set_grid(Index i, const ArrayOfString& g) {
154 ARTS_ASSERT(i < dim);
156 mnumericgrids[i].resize(0);
157 mstringgrids[i] = g;
158}
159
161
167ostream& operator<<(ostream& os, const GriddedField& gf) {
168 if (gf.mname.size()) os << gf.mname << ":" << endl;
169
170 for (Index i = 0; i < gf.dim; i++) {
171 if (gf.mgridnames[i].size())
172 os << gf.mgridnames[i];
173 else
174 os << "Grid " << i;
175 os << ": ";
176 switch (gf.mgridtypes[i]) {
177 case GRID_TYPE_STRING:
178 os << gf.mstringgrids[i];
179 break;
181 os << gf.mnumericgrids[i];
182 break;
183 }
184 os << endl;
185 }
186
187 return os;
188}
189
191ostream& operator<<(ostream& os, const GriddedField1& gf) {
192 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
193}
194
196ostream& operator<<(ostream& os, const GriddedField2& gf) {
197 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
198}
199
201ostream& operator<<(ostream& os, const GriddedField3& gf) {
202 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
203}
204
206ostream& operator<<(ostream& os, const GriddedField4& gf) {
207 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
208}
209
211ostream& operator<<(ostream& os, const GriddedField5& gf) {
212 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
213}
214
216ostream& operator<<(ostream& os, const GriddedField6& gf) {
217 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
218}
ArrayOfVector mnumericgrids
ArrayOfString mgridnames
Array< ArrayOfString > mstringgrids
const ArrayOfString & get_string_grid(Index i) const
Get a string grid.
Index get_dim() const
Get the dimension of this gridded field.
void copy_grids(const GriddedField &gf)
Copy grids.
void set_grid(Index i, const Vector &g)
Set a numeric grid.
GridType get_grid_type(Index i) const
Get grid type.
const Vector & get_numeric_grid(Index i) const
Get a numeric grid.
Array< GridType > mgridtypes
#define ARTS_ASSERT(condition,...)
Definition: debug.h:84
std::string var_string(Args &&... args)
Definition: debug.h:18
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:135
The declarations of all the exception classes.
ostream & operator<<(ostream &os, const GriddedField &gf)
Output operator for GriddedField.
Implementation of gridded fields.
@ GRID_TYPE_NUMERIC
@ GRID_TYPE_STRING
This file contains the definition of String, the ARTS string class.