ARTS 2.5.0 (git: 9ee3ac6c)
gridded_fields.cc
Go to the documentation of this file.
1/* Copyright (C) 2008-2012 Oliver Lemke <olemke@core-dump.info>
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*/
18
34/*===========================================================================
35 === External declarations
36 ===========================================================================*/
37
38#include "gridded_fields.h"
39#include <iostream>
40#include <stdexcept>
41#include "exceptions.h"
42#include "mystring.h"
43
44using std::endl;
45using std::ostream;
46using std::ostringstream;
47using std::runtime_error;
48
49/*===========================================================================
50 === The functions (in alphabetical order)
51 ===========================================================================*/
52
54
60 ARTS_ASSERT(gf.get_dim() == dim);
61
62 for (Index i = 0; i < dim; i++) {
63 switch (gf.get_grid_type(i)) {
67 mstringgrids[i].resize(0);
68 break;
72 mnumericgrids[i].resize(0);
73 break;
74 }
75 }
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 numeric grid.")
111 return mnumericgrids[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
142 ARTS_ASSERT(i < dim);
144 mname.length() ? var_string(mname, " Grid ") : var_string("Grid "),
145 mgridnames[i].length() ? var_string(mgridnames[i]) : var_string(i),
146 " is not a string grid.")
147 return (mstringgrids[i]);
148}
149
151
158 ARTS_ASSERT(i < dim);
160 mstringgrids[i].resize(0);
161 mnumericgrids[i] = g;
162}
163
165
172 ARTS_ASSERT(i < dim);
174 mnumericgrids[i].resize(0);
175 mstringgrids[i] = g;
176}
177
179
185ostream& operator<<(ostream& os, const GriddedField& gf) {
186 if (gf.mname.size()) os << gf.mname << ":" << endl;
187
188 for (Index i = 0; i < gf.dim; i++) {
189 if (gf.mgridnames[i].size())
190 os << gf.mgridnames[i];
191 else
192 os << "Grid " << i;
193 os << ": ";
194 switch (gf.mgridtypes[i]) {
195 case GRID_TYPE_STRING:
196 os << gf.mstringgrids[i];
197 break;
199 os << gf.mnumericgrids[i];
200 break;
201 }
202 os << endl;
203 }
204
205 return os;
206}
207
209ostream& operator<<(ostream& os, const GriddedField1& gf) {
210 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
211}
212
214ostream& operator<<(ostream& os, const GriddedField2& gf) {
215 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
216}
217
219ostream& operator<<(ostream& os, const GriddedField3& gf) {
220 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
221}
222
224ostream& operator<<(ostream& os, const GriddedField4& gf) {
225 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
226}
227
229ostream& operator<<(ostream& os, const GriddedField5& gf) {
230 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
231}
232
234ostream& operator<<(ostream& os, const GriddedField6& gf) {
235 return os << *((GriddedField*)&gf) << "Data:" << endl << gf.data << endl;
236}
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
The Vector class.
Definition: matpackI.h:876
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
std::string var_string(Args &&... args)
Definition: debug.h:36
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:134
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
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.