ARTS  2.3.1285(git:92a29ea9-dirty)
telsem.h
Go to the documentation of this file.
1 /* Copyright (C) 2017
2  Oliver Lemke <olemke@core-dump.info>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License as published by the
6  Free Software Foundation; either version 2, or (at your option) any
7  later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17  USA.
18 */
19 
35 #ifndef telsem_h
36 #define telsem_h
37 
38 #include <array>
39 #include "array.h"
40 #include "matpackIII.h"
41 #include "mystring.h"
42 #include "xml_io.h"
43 
57 class TelsemAtlas {
58  public:
59  TelsemAtlas() = default;
60  TelsemAtlas(const TelsemAtlas &) = default;
61  TelsemAtlas(TelsemAtlas &&) = default;
62  TelsemAtlas &operator=(const TelsemAtlas &) = default;
63  TelsemAtlas &operator=(TelsemAtlas &&) = default;
64  ~TelsemAtlas() = default;
65 
70  TelsemAtlas(String filename);
71 
72  void set_month(Index m) { month = m; }
73  Index get_month() const { return month; }
74 
75  const Tensor3 &get_correl() const { return correl; }
76  void set_correl(const Tensor3 &t) { correl = t; }
77 
83  bool contains(Index cellnumber) const {
84  if (cellnumber >= correspondence.nelem()) {
85  return false;
86  }
87  return correspondence[cellnumber] >= 0;
88  }
89 
100  Index get_class1(Index cellnumber) const {
101  Index ind = correspondence[cellnumber];
102  if (ind < 0) {
103  throw std::runtime_error("The cell is not contained in the atlas.");
104  }
105  return classes1[ind];
106  }
107 
118  Index get_class2(Index cellnumber) const {
119  Index ind = correspondence[cellnumber];
120  if (ind < 0) {
121  throw std::runtime_error("The cell is not contained in the atlas.");
122  }
123  return classes2[ind];
124  }
125 
136  Index ind = correspondence[i];
137  Vector e_v(3);
138  if (ind < 0) {
139  throw std::runtime_error("The cell is not contained in the atlas.");
140  } else {
141  e_v[0] = emis(ind, 0);
142  e_v[1] = emis(ind, 3);
143  e_v[2] = emis(ind, 5);
144  }
145  return e_v;
146  }
147 
157  Vector get_emis_h(Index cellnum) const {
158  Index ind = correspondence[cellnum];
159  Vector e_h(3);
160  if (ind < 0) {
161  throw std::runtime_error("The cell is not contained in the atlas.");
162  } else {
163  e_h[0] = emis(ind, 1);
164  e_h[1] = emis(ind, 4);
165  e_h[2] = emis(ind, 6);
166  }
167  return e_h;
168  }
169 
181  ConstVectorView operator[](Index cellnumber) const {
182  Index ind = correspondence[cellnumber];
183  if (ind < 0) {
184  throw std::runtime_error("The cell is not contained in the atlas.");
185  } else {
186  return emis(ind, joker);
187  }
188  }
189 
192  void read(std::istream &is);
193 
201  void equare();
202 
210 
225  Index calc_cellnum(Numeric lat, Numeric lon) const;
226 
235 
242  std::pair<Numeric, Numeric> get_coordinates(Index cellnum) const;
243 
257  Numeric interp_freq2(Numeric emiss19,
258  Numeric emiss37,
259  Numeric emiss85,
260  Numeric f,
261  Index class2) const;
262 
275  std::pair<Numeric, Numeric> emis_interp(Numeric theta,
276  Numeric freq,
277  Index class1,
278  Index class2,
279  const ConstVectorView &ev,
280  const ConstVectorView &eh) const;
281 
282  friend std::ostream &operator<<(std::ostream &os, const TelsemAtlas &ta);
283  friend void xml_write_to_stream(ostream &,
284  const TelsemAtlas &,
285  bofstream *,
286  const String &,
287  const Verbosity &);
288 
289  friend void xml_read_from_stream(istream &,
290  TelsemAtlas &,
291  bifstream *,
292  const Verbosity &);
293 
294  // Number of lines in the Atlas.
295  Index& DataCount() {return ndat;}
296 
297  // Number of channels in the Atlas.
298  Index& ChannelCount() {return nchan;}
299 
300  // Name of the atlas (including version number).
301  String& Name() {return name;}
302 
303  // Month of the Atlas.
304  Index& Month() {return month;}
305 
306  // Resolution of the Atlas.
307  Numeric& Lat() {return dlat;}
308 
309  // Number of cells per lat band.
310  ArrayOfIndex& Cells() {return ncells;}
311 
312  // The first cell number of lat band.
314 
315  // Emissivities
316  Matrix& Emis() {return emis;}
317 
318  // Emissivity uncertainties.
319  Matrix& Emis_err() {return emis_err;}
320 
321  // Emissivity correlations.
323 
324  // Surface classes.
327 
328  // Cellnumber of each of the pixels in the atlas.
330 
331  // Derived from file data
333 
334  // Regression coefficients.
335  Numeric A0_K0(Index i) {return a0_k0[i];}
336  Numeric A0_K1(Index i) {return a0_k1[i];}
337  Numeric A0_K2(Index i) {return a0_k2[i];}
348 
349  private:
350  // Number of lines in the Atlas.
352  // Number of channels in the Atlas.
354  // Name of the atlas (including version number).
356  // Month of the Atlas.
358  // Resolution of the Atlas.
360  // Number of cells per lat band.
362  // The first cell number of lat band.
364  // Emissivities
366  // Emissivity uncertainties.
368  // Emissivity correlations.
370  // Surface classes.
373  // Cellnumber of each of the pixels in the atlas.
375  // Derived from file data
377 
378  // Regression coefficients.
379  static const std::array<Numeric, 30> a0_k0;
380  static const std::array<Numeric, 30> a0_k1;
381  static const std::array<Numeric, 30> a0_k2;
382  static const std::array<Numeric, 30> a0_eveh;
383  static const std::array<Numeric, 30> a1_eveh;
384  static const std::array<Numeric, 30> a2_eveh;
385  static const std::array<Numeric, 30> a3_eveh;
386  static const std::array<Numeric, 30> b0_eveh;
387  static const std::array<Numeric, 30> b1_eveh;
388  static const std::array<Numeric, 30> b2_eveh;
389  static const std::array<Numeric, 30> b3_eveh;
390  static const std::array<Numeric, 4> rapport43_32;
391  static const std::array<Numeric, 4> rapport54_43;
392 };
393 
395 
396 std::ostream &operator<<(std::ostream &os, const TelsemAtlas &ta);
397 
398 #endif /* telsem_h */
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
static const std::array< Numeric, 30 > a3_eveh
Definition: telsem.h:385
static const std::array< Numeric, 30 > b2_eveh
Definition: telsem.h:388
ArrayOfIndex ncells
Definition: telsem.h:361
std::pair< Numeric, Numeric > get_coordinates(Index cellnum) const
Definition: telsem.cc:229
void set_month(Index m)
Definition: telsem.h:72
Matrix & Emis()
Definition: telsem.h:316
Numeric B2_EVEH(Index i)
Definition: telsem.h:344
Numeric A0_K2(Index i)
Definition: telsem.h:337
Numeric interp_freq2(Numeric emiss19, Numeric emiss37, Numeric emiss85, Numeric f, Index class2) const
Definition: telsem.cc:250
TelsemAtlas()=default
Vector get_emis_h(Index cellnum) const
Definition: telsem.h:157
Index calc_cellnum(Numeric lat, Numeric lon) const
Definition: telsem.cc:142
Index nelem() const
Number of elements.
Definition: array.h:195
Numeric RAPPORT54_43(Index i)
Definition: telsem.h:347
void read(std::istream &is)
Definition: telsem.cc:46
ArrayOfIndex & Classes2()
Definition: telsem.h:326
Numeric A3_EVEH(Index i)
Definition: telsem.h:341
ArrayOfIndex & Cells()
Definition: telsem.h:310
Index get_month() const
Definition: telsem.h:73
Matrix & Emis_err()
Definition: telsem.h:319
The Vector class.
Definition: matpackI.h:860
static const std::array< Numeric, 30 > b0_eveh
Definition: telsem.h:386
bool contains(Index cellnumber) const
Definition: telsem.h:83
const Tensor3 & get_correl() const
Definition: telsem.h:75
static const std::array< Numeric, 30 > a0_eveh
Definition: telsem.h:382
Index ndat
Definition: telsem.h:351
ArrayOfIndex classes2
Definition: telsem.h:372
Numeric B0_EVEH(Index i)
Definition: telsem.h:342
void equare()
Definition: telsem.cc:93
This file contains basic functions to handle XML data files.
friend void xml_read_from_stream(istream &, TelsemAtlas &, bifstream *, const Verbosity &)
Reads TelsemAtlas from XML input stream.
Numeric B1_EVEH(Index i)
Definition: telsem.h:343
ArrayOfIndex correspondence
Definition: telsem.h:376
ArrayOfIndex & Classes1()
Definition: telsem.h:325
Index get_class2(Index cellnumber) const
Definition: telsem.h:118
This file contains the definition of Array.
The implementation for String, the ARTS string class.
Definition: mystring.h:55
static const std::array< Numeric, 4 > rapport54_43
Definition: telsem.h:391
Index get_class1(Index cellnumber) const
Definition: telsem.h:100
void telsem_calc_correspondence()
Definition: telsem.cc:134
The Tensor3 class.
Definition: matpackIII.h:339
Vector get_emis_v(Index i) const
Definition: telsem.h:135
ConstVectorView operator[](Index cellnumber) const
Definition: telsem.h:181
ArrayOfIndex & FirstCells()
Definition: telsem.h:313
Index calc_cellnum_nearest_neighbor(Numeric lat, Numeric lon) const
Definition: telsem.cc:174
Numeric B3_EVEH(Index i)
Definition: telsem.h:345
Numeric & Lat()
Definition: telsem.h:307
static const std::array< Numeric, 30 > a0_k0
Definition: telsem.h:379
Binary output file stream class.
Definition: bifstream.h:42
friend void xml_write_to_stream(ostream &, const TelsemAtlas &, bofstream *, const String &, const Verbosity &)
Writes TelsemAtlas to XML output stream.
Index & Month()
Definition: telsem.h:304
Numeric A0_K0(Index i)
Definition: telsem.h:335
Numeric A0_EVEH(Index i)
Definition: telsem.h:338
static const std::array< Numeric, 30 > a1_eveh
Definition: telsem.h:383
static const std::array< Numeric, 30 > a0_k1
Definition: telsem.h:380
Index & DataCount()
Definition: telsem.h:295
static const std::array< Numeric, 4 > rapport43_32
Definition: telsem.h:390
const Joker joker
ArrayOfIndex classes1
Definition: telsem.h:371
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
The Matrix class.
Definition: matpackI.h:1193
Index & ChannelCount()
Definition: telsem.h:298
String & Name()
Definition: telsem.h:301
String name
Definition: telsem.h:355
Array< TelsemAtlas > ArrayOfTelsemAtlas
Definition: telsem.h:394
std::pair< Numeric, Numeric > emis_interp(Numeric theta, Numeric freq, Index class1, Index class2, const ConstVectorView &ev, const ConstVectorView &eh) const
Definition: telsem.cc:291
static const std::array< Numeric, 30 > b1_eveh
Definition: telsem.h:387
static const std::array< Numeric, 30 > a0_k2
Definition: telsem.h:381
ArrayOfIndex & Cellnumber()
Definition: telsem.h:329
static const std::array< Numeric, 30 > b3_eveh
Definition: telsem.h:389
Tensor3 & Correlations()
Definition: telsem.h:322
~TelsemAtlas()=default
Numeric dlat
Definition: telsem.h:359
ArrayOfIndex firstcells
Definition: telsem.h:363
Index month
Definition: telsem.h:357
A telsem atlas.
Definition: telsem.h:57
TelsemAtlas & operator=(const TelsemAtlas &)=default
A constant view of a Vector.
Definition: matpackI.h:476
Binary output file stream class.
Definition: bofstream.h:42
Numeric RAPPORT43_32(Index i)
Definition: telsem.h:346
Matrix emis_err
Definition: telsem.h:367
Numeric A0_K1(Index i)
Definition: telsem.h:336
ArrayOfIndex & Correspondance()
Definition: telsem.h:332
Tensor3 correl
Definition: telsem.h:369
Numeric A2_EVEH(Index i)
Definition: telsem.h:340
Matrix emis
Definition: telsem.h:365
friend std::ostream & operator<<(std::ostream &os, const TelsemAtlas &ta)
Definition: telsem.cc:346
Index nchan
Definition: telsem.h:353
static const std::array< Numeric, 30 > a2_eveh
Definition: telsem.h:384
void set_correl(const Tensor3 &t)
Definition: telsem.h:76
Numeric A1_EVEH(Index i)
Definition: telsem.h:339
This file contains the definition of String, the ARTS string class.
ArrayOfIndex cellnums
Definition: telsem.h:374