ARTS  2.4.0(git:4fb77825)
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;
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 
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];}
338  Numeric A0_EVEH(Index i) {return a0_eveh[i];}
339  Numeric A1_EVEH(Index i) {return a1_eveh[i];}
340  Numeric A2_EVEH(Index i) {return a2_eveh[i];}
341  Numeric A3_EVEH(Index i) {return a3_eveh[i];}
342  Numeric B0_EVEH(Index i) {return b0_eveh[i];}
343  Numeric B1_EVEH(Index i) {return b1_eveh[i];}
344  Numeric B2_EVEH(Index i) {return b2_eveh[i];}
345  Numeric B3_EVEH(Index i) {return b3_eveh[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 */
Matrix
The Matrix class.
Definition: matpackI.h:1193
TelsemAtlas::A0_K2
Numeric A0_K2(Index i)
Definition: telsem.h:337
TelsemAtlas::set_correl
void set_correl(const Tensor3 &t)
Definition: telsem.h:76
TelsemAtlas::B2_EVEH
Numeric B2_EVEH(Index i)
Definition: telsem.h:344
TelsemAtlas::A0_K1
Numeric A0_K1(Index i)
Definition: telsem.h:336
TelsemAtlas::calc_cellnum
Index calc_cellnum(Numeric lat, Numeric lon) const
Definition: telsem.cc:142
TelsemAtlas::b0_eveh
static const std::array< Numeric, 30 > b0_eveh
Definition: telsem.h:386
TelsemAtlas::TelsemAtlas
TelsemAtlas(const TelsemAtlas &)=default
TelsemAtlas::cellnums
ArrayOfIndex cellnums
Definition: telsem.h:374
TelsemAtlas::RAPPORT54_43
Numeric RAPPORT54_43(Index i)
Definition: telsem.h:347
ARTS::Var::lat
Numeric lat(Workspace &ws) noexcept
Definition: autoarts.h:3933
ArrayOfTelsemAtlas
Array< TelsemAtlas > ArrayOfTelsemAtlas
Definition: telsem.h:394
Tensor3
The Tensor3 class.
Definition: matpackIII.h:339
TelsemAtlas::interp_freq2
Numeric interp_freq2(Numeric emiss19, Numeric emiss37, Numeric emiss85, Numeric f, Index class2) const
Definition: telsem.cc:250
TelsemAtlas::equare
void equare()
Definition: telsem.cc:93
TelsemAtlas::B1_EVEH
Numeric B1_EVEH(Index i)
Definition: telsem.h:343
joker
const Joker joker
operator<<
std::ostream & operator<<(std::ostream &os, const TelsemAtlas &ta)
Definition: telsem.cc:346
TelsemAtlas::a0_eveh
static const std::array< Numeric, 30 > a0_eveh
Definition: telsem.h:382
TelsemAtlas::Classes2
ArrayOfIndex & Classes2()
Definition: telsem.h:326
TelsemAtlas::read
void read(std::istream &is)
Definition: telsem.cc:46
TelsemAtlas::A3_EVEH
Numeric A3_EVEH(Index i)
Definition: telsem.h:341
TelsemAtlas::B0_EVEH
Numeric B0_EVEH(Index i)
Definition: telsem.h:342
TelsemAtlas::Emis_err
Matrix & Emis_err()
Definition: telsem.h:319
TelsemAtlas::get_class2
Index get_class2(Index cellnumber) const
Definition: telsem.h:118
TelsemAtlas::contains
bool contains(Index cellnumber) const
Definition: telsem.h:83
TelsemAtlas
A telsem atlas.
Definition: telsem.h:57
TelsemAtlas::telsem_calc_correspondence
void telsem_calc_correspondence()
Definition: telsem.cc:134
TelsemAtlas::classes2
ArrayOfIndex classes2
Definition: telsem.h:372
TelsemAtlas::operator=
TelsemAtlas & operator=(TelsemAtlas &&)=default
TelsemAtlas::Classes1
ArrayOfIndex & Classes1()
Definition: telsem.h:325
TelsemAtlas::get_month
Index get_month() const
Definition: telsem.h:73
array.h
This file contains the definition of Array.
ARTS::Var::lon
Numeric lon(Workspace &ws) noexcept
Definition: autoarts.h:4064
TelsemAtlas::correspondence
ArrayOfIndex correspondence
Definition: telsem.h:376
TelsemAtlas::rapport54_43
static const std::array< Numeric, 4 > rapport54_43
Definition: telsem.h:391
TelsemAtlas::get_correl
const Tensor3 & get_correl() const
Definition: telsem.h:75
TelsemAtlas::Month
Index & Month()
Definition: telsem.h:304
TelsemAtlas::ndat
Index ndat
Definition: telsem.h:351
TelsemAtlas::get_emis_v
Vector get_emis_v(Index i) const
Definition: telsem.h:135
TelsemAtlas::A0_K0
Numeric A0_K0(Index i)
Definition: telsem.h:335
Array< Index >
TelsemAtlas::A0_EVEH
Numeric A0_EVEH(Index i)
Definition: telsem.h:338
TelsemAtlas::a0_k1
static const std::array< Numeric, 30 > a0_k1
Definition: telsem.h:380
TelsemAtlas::xml_read_from_stream
friend void xml_read_from_stream(istream &, TelsemAtlas &, bifstream *, const Verbosity &)
Reads TelsemAtlas from XML input stream.
Definition: xml_io_compound_types.cc:2057
TelsemAtlas::classes1
ArrayOfIndex classes1
Definition: telsem.h:371
TelsemAtlas::a0_k0
static const std::array< Numeric, 30 > a0_k0
Definition: telsem.h:379
TelsemAtlas::get_class1
Index get_class1(Index cellnumber) const
Definition: telsem.h:100
TelsemAtlas::xml_write_to_stream
friend void xml_write_to_stream(ostream &, const TelsemAtlas &, bofstream *, const String &, const Verbosity &)
Writes TelsemAtlas to XML output stream.
Definition: xml_io_compound_types.cc:2089
TelsemAtlas::Name
String & Name()
Definition: telsem.h:301
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:55
TelsemAtlas::operator[]
ConstVectorView operator[](Index cellnumber) const
Definition: telsem.h:181
TelsemAtlas::b3_eveh
static const std::array< Numeric, 30 > b3_eveh
Definition: telsem.h:389
TelsemAtlas::Correlations
Tensor3 & Correlations()
Definition: telsem.h:322
TelsemAtlas::TelsemAtlas
TelsemAtlas(TelsemAtlas &&)=default
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:49
bifstream
Binary output file stream class.
Definition: bifstream.h:42
matpackIII.h
TelsemAtlas::emis_interp
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
TelsemAtlas::b1_eveh
static const std::array< Numeric, 30 > b1_eveh
Definition: telsem.h:387
TelsemAtlas::FirstCells
ArrayOfIndex & FirstCells()
Definition: telsem.h:313
TelsemAtlas::calc_cellnum_nearest_neighbor
Index calc_cellnum_nearest_neighbor(Numeric lat, Numeric lon) const
Definition: telsem.cc:174
TelsemAtlas::B3_EVEH
Numeric B3_EVEH(Index i)
Definition: telsem.h:345
TelsemAtlas::~TelsemAtlas
~TelsemAtlas()=default
TelsemAtlas::rapport43_32
static const std::array< Numeric, 4 > rapport43_32
Definition: telsem.h:390
TelsemAtlas::Lat
Numeric & Lat()
Definition: telsem.h:307
TelsemAtlas::ChannelCount
Index & ChannelCount()
Definition: telsem.h:298
TelsemAtlas::month
Index month
Definition: telsem.h:357
TelsemAtlas::Correspondance
ArrayOfIndex & Correspondance()
Definition: telsem.h:332
TelsemAtlas::a0_k2
static const std::array< Numeric, 30 > a0_k2
Definition: telsem.h:381
TelsemAtlas::a1_eveh
static const std::array< Numeric, 30 > a1_eveh
Definition: telsem.h:383
TelsemAtlas::A2_EVEH
Numeric A2_EVEH(Index i)
Definition: telsem.h:340
TelsemAtlas::DataCount
Index & DataCount()
Definition: telsem.h:295
TelsemAtlas::dlat
Numeric dlat
Definition: telsem.h:359
TelsemAtlas::firstcells
ArrayOfIndex firstcells
Definition: telsem.h:363
TelsemAtlas::operator<<
friend std::ostream & operator<<(std::ostream &os, const TelsemAtlas &ta)
Definition: telsem.cc:346
TelsemAtlas::name
String name
Definition: telsem.h:355
TelsemAtlas::A1_EVEH
Numeric A1_EVEH(Index i)
Definition: telsem.h:339
TelsemAtlas::correl
Tensor3 correl
Definition: telsem.h:369
TelsemAtlas::operator=
TelsemAtlas & operator=(const TelsemAtlas &)=default
TelsemAtlas::Cellnumber
ArrayOfIndex & Cellnumber()
Definition: telsem.h:329
TelsemAtlas::a3_eveh
static const std::array< Numeric, 30 > a3_eveh
Definition: telsem.h:385
TelsemAtlas::b2_eveh
static const std::array< Numeric, 30 > b2_eveh
Definition: telsem.h:388
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
TelsemAtlas::ncells
ArrayOfIndex ncells
Definition: telsem.h:361
TelsemAtlas::get_coordinates
std::pair< Numeric, Numeric > get_coordinates(Index cellnum) const
Definition: telsem.cc:229
TelsemAtlas::Emis
Matrix & Emis()
Definition: telsem.h:316
Vector
The Vector class.
Definition: matpackI.h:860
TelsemAtlas::TelsemAtlas
TelsemAtlas()=default
TelsemAtlas::get_emis_h
Vector get_emis_h(Index cellnum) const
Definition: telsem.h:157
ConstVectorView
A constant view of a Vector.
Definition: matpackI.h:476
TelsemAtlas::emis
Matrix emis
Definition: telsem.h:365
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:195
mystring.h
This file contains the definition of String, the ARTS string class.
TelsemAtlas::nchan
Index nchan
Definition: telsem.h:353
TelsemAtlas::RAPPORT43_32
Numeric RAPPORT43_32(Index i)
Definition: telsem.h:346
xml_io.h
This file contains basic functions to handle XML data files.
bofstream
Binary output file stream class.
Definition: bofstream.h:42
TelsemAtlas::Cells
ArrayOfIndex & Cells()
Definition: telsem.h:310
TelsemAtlas::emis_err
Matrix emis_err
Definition: telsem.h:367
TelsemAtlas::a2_eveh
static const std::array< Numeric, 30 > a2_eveh
Definition: telsem.h:384
TelsemAtlas::set_month
void set_month(Index m)
Definition: telsem.h:72