ARTS  2.2.66
test_gridded_fields.cc
Go to the documentation of this file.
1 #include "matpack.h"
2 #include "make_array.h"
3 #include "gridded_fields.h"
4 
5 using std::cout;
6 using std::endl;
7 
8 
9 int main (void)
10 {
11  // Creating two gridded fields
13  GriddedField1 gfone("I'm a GriddedField1");
14  GriddedField2 gftwo;
15 
16  gftwo.set_name ("I'm a GriddedField2");
17 
18 
19  // Initializing the grids
21  Vector gfonegrid(1,5,1); // gfonegrid = [1,2,3,4,5]
22  gfone.set_grid(0, gfonegrid); // Set grid for the vector elements.
23 
24  Vector gftwogrid0(1,5,1); // gftwogrid0 = [1,2,3,4,5]
25  MakeArray<String> gftwogrid1("Chan1", "Chan2", "Chan3");
26 
27  gftwo.set_grid(0, gftwogrid0); // Set grid for the matrix rows.
28  gftwo.set_grid(1, gftwogrid1); // Set grid for the matrix columns.
29 
30  gfone.set_grid_name (0, "Pressure");
31 
32  gftwo.set_grid_name (0, "Pressure");
33  gftwo.set_grid_name (1, "Channel");
34 
35  // Initializing the data
37  Vector avector(1,4,0.5); // avector = [1,1.5,2,2.5]
38 
39  gfone.data = avector;
40 
41  cout << gfone;
42 
43  Matrix amatrix(5,3,4.); // amatrix = [[4,4,4],[4,4,4],...]
44 
45  gftwo.data = amatrix;
46 
47  // Consistency check
49 
50  if (!gfone.checksize())
51  cout << gfone.get_name() << ": Sizes of grid and data don't match" << endl;
52 
53  // This should fail!
54  if (!gftwo.checksize())
55  cout << gftwo.get_name() << ": Sizes of grids and data don't match" << endl;
56 
57  // Output
59 
60  cout << "GriddedField1: " << gfone << endl;
61  cout << "GriddedField2: " << gftwo << endl;
62 
63  return 0;
64 }
65 
GriddedField2
Definition: gridded_fields.h:250
Matrix
The Matrix class.
Definition: matpackI.h:788
gridded_fields.h
Implementation of gridded fields.
GriddedField::set_grid_name
void set_grid_name(Index i, const String &s)
Set grid name.
Definition: gridded_fields.h:166
matpack.h
main
int main(void)
Definition: test_gridded_fields.cc:9
GriddedField1::data
Vector data
Definition: gridded_fields.h:246
GriddedField2::data
Matrix data
Definition: gridded_fields.h:303
GriddedField::set_name
void set_name(const String &s)
Set name of this gridded field.
Definition: gridded_fields.h:174
make_array.h
Implements the class MakeArray, which is a derived class of Array, allowing explicit initialization.
GriddedField::get_name
const String & get_name() const
Get the name of this gridded field.
Definition: gridded_fields.h:153
GriddedField2::checksize
virtual bool checksize() const
Consistency check.
Definition: gridded_fields.h:258
GriddedField::set_grid
void set_grid(Index i, const Vector &g)
Set a numeric grid.
Definition: gridded_fields.cc:225
GriddedField1
Definition: gridded_fields.h:199
MakeArray
Explicit construction of Arrays.
Definition: make_array.h:52
Vector
The Vector class.
Definition: matpackI.h:556