ARTS 2.5.4 (git: 31ce4f0e)
test_gridded_fields.cc
Go to the documentation of this file.
1#include "gridded_fields.h"
2#include "matpack.h"
3
4using std::cout;
5using std::endl;
6
7int main(void) {
8 // Creating two gridded fields
10 GriddedField1 gfone("I'm a GriddedField1");
11 GriddedField2 gftwo;
12
13 gftwo.set_name("I'm a GriddedField2");
14
15 // Initializing the grids
17 Vector gfonegrid(1, 5, 1); // gfonegrid = [1,2,3,4,5]
18 gfone.set_grid(0, gfonegrid); // Set grid for the vector elements.
19
20 Vector gftwogrid0(1, 5, 1); // gftwogrid0 = [1,2,3,4,5]
21 ArrayOfString gftwogrid1{"Chan1", "Chan2", "Chan3"};
22
23 gftwo.set_grid(0, gftwogrid0); // Set grid for the matrix rows.
24 gftwo.set_grid(1, gftwogrid1); // Set grid for the matrix columns.
25
26 gfone.set_grid_name(0, "Pressure");
27
28 gftwo.set_grid_name(0, "Pressure");
29 gftwo.set_grid_name(1, "Channel");
30
31 // Initializing the data
33 Vector avector(1, 4, 0.5); // avector = [1,1.5,2,2.5]
34
35 gfone.data = avector;
36
37 cout << gfone;
38
39 Matrix amatrix(5, 3, 4.); // amatrix = [[4,4,4],[4,4,4],...]
40
41 gftwo.data = amatrix;
42
43 // Consistency check
45
46 if (!gfone.checksize())
47 cout << gfone.get_name() << ": Sizes of grid and data don't match" << endl;
48
49 // This should fail!
50 if (!gftwo.checksize())
51 cout << gftwo.get_name() << ": Sizes of grids and data don't match" << endl;
52
53 // Output
55
56 cout << "GriddedField1: " << gfone << endl;
57 cout << "GriddedField2: " << gftwo << endl;
58
59 return 0;
60}
bool checksize() const final
Consistency check.
bool checksize() const final
Consistency check.
const String & get_name() const
Get the name of this gridded field.
void set_name(const String &s)
Set name of this gridded field.
void set_grid_name(Index i, const String &s)
Set grid name.
void set_grid(Index i, const Vector &g)
Set a numeric grid.
The Matrix class.
Definition: matpackI.h:1261
The Vector class.
Definition: matpackI.h:899
Implementation of gridded fields.
int main(void)