ARTS  2.4.0(git:4fb77825)
m_rt4.cc
Go to the documentation of this file.
1 /* Copyright (C) 2016 Jana Mendrok <jana.mendrok@gmail.com>
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 
30 /*===========================================================================
31  === External declarations
32  ===========================================================================*/
33 
34 #include <complex.h>
35 #include <stdexcept>
36 #include "auto_md.h"
37 #include "disort.h"
38 #include "m_xml.h"
39 #include "messages.h"
40 #include "rt4.h"
41 
42 #ifdef ENABLE_RT4
43 
44 const Numeric pfct_threshold = 0.05;
45 
46 /* Workspace method: Doxygen documentation will be auto-generated */
47 void RT4Calc(Workspace& ws,
48  // WS Output:
50  Vector& za_grid,
51  Vector& aa_grid,
52  // WS Input
53  const Index& atmfields_checked,
54  const Index& atmgeom_checked,
55  const Index& scat_data_checked,
56  const Index& cloudbox_checked,
57  const Index& cloudbox_on,
61  const Index& atmosphere_dim,
62  const Tensor4& pnd_field,
63  const Tensor3& t_field,
64  const Tensor3& z_field,
65  const Tensor4& vmr_field,
66  const Vector& p_grid,
68  const Vector& f_grid,
69  const Index& stokes_dim,
70  const Matrix& z_surface,
71  const Index& nstreams,
72  const String& pfct_method,
73  const String& quadtype,
74  const Index& add_straight_angles,
75  const Index& pfct_aa_grid_size,
76  //const Numeric& pfct_threshold,
77  const Index& auto_inc_nstreams,
78  const Index& robust,
79  const Index& za_interp_order,
80  const Index& cos_za_interp,
81  const Numeric& max_delta_tau,
82  const Verbosity& verbosity) {
83  if (!cloudbox_on) {
85  out1 << " Cloudbox is off, RT4 calculation is skipped.\n";
86  return;
87  }
88 
89  // FIXME: so far surface is implictly assumed at lowest atmospheric level.
90  // That should be fixed (using z_surface and allowing other altitudes) at some
91  // point.
92 
93  const String quad_type = quadtype.toupper();
94  Index nhza, nhstreams, nummu;
95  check_rt4_input(nhstreams,
96  nhza,
97  nummu,
104  scat_data,
106  stokes_dim,
107  nstreams,
108  quad_type,
109  add_straight_angles,
110  pnd_field.ncols());
111 
113 
114  // in RT4 mu_values is generally only output. however, we need the values for
115  // preparing the single scattering data at these angles. therefore, we
116  // calculate them here using RT4's proprietary quadrature methods. They
117  // simultaneously provide the quadrature weights, too. We keep them so far,
118  // might use them for ensuring proper normalization in the preparation of the
119  // single scattering data.
120  Vector mu_values(nummu, 0.);
121  Vector quad_weights(nummu, 0.);
122 
123  get_quad_angles(mu_values,
124  quad_weights,
125  za_grid,
126  aa_grid,
127  quad_type,
128  nhstreams,
129  nhza,
130  nummu);
131 
132  // Preparing surface setup.
133  //
134 
135  // Initializing surface related interface-related RT4 interface parameters.
136  const Index nf = f_grid.nelem();
137 
138  // dummy values for parameters not relevant for this ground_type
139  Numeric surface_skin_t = 0.;
140  Vector ground_albedo(nf, 0.);
141  Tensor3 ground_reflec(nf, stokes_dim, stokes_dim, 0.);
142  Complex gidef(1, 0.);
143  ComplexVector ground_index(nf, gidef);
144 
145  // parameters that will be updated below
146  Tensor5 surf_refl_mat(nf, nummu, stokes_dim, nummu, stokes_dim, 0.);
147  Tensor3 surf_emis_vec(nf, nummu, stokes_dim, 0.);
148 
149  surf_optpropCalc(ws,
150  surf_refl_mat,
151  surf_emis_vec,
153  f_grid,
154  za_grid,
155  mu_values,
156  quad_weights,
157  stokes_dim,
158  z_surface(0, 0));
159 
160  run_rt4(ws,
162  za_grid,
163  f_grid,
164  p_grid,
165  z_field(joker, 0, 0),
166  t_field(joker, 0, 0),
167  vmr_field(joker, joker, 0, 0),
168  pnd_field(joker, joker, 0, 0),
169  scat_data,
172  stokes_dim,
173  nummu,
174  nhza,
175  "A",
177  ground_albedo,
178  ground_reflec,
179  ground_index,
180  surf_refl_mat,
181  surf_emis_vec,
183  z_surface(0, 0),
184  quad_type,
185  mu_values,
186  quad_weights,
187  auto_inc_nstreams,
188  robust,
189  za_interp_order,
190  cos_za_interp,
191  pfct_method,
192  pfct_aa_grid_size,
193  pfct_threshold,
194  max_delta_tau,
195  verbosity);
196 
197  za_grid_adjust(za_grid, mu_values, nummu);
198 }
199 
200 /* Workspace method: Doxygen documentation will be auto-generated */
202  // WS Output:
204  Vector& za_grid,
205  Vector& aa_grid,
206  // WS Input
207  const Index& atmfields_checked,
208  const Index& atmgeom_checked,
209  const Index& scat_data_checked,
210  const Index& cloudbox_checked,
211  const Index& cloudbox_on,
214  const Index& atmosphere_dim,
215  const Tensor4& pnd_field,
216  const Tensor3& t_field,
217  const Tensor3& z_field,
218  const Tensor4& vmr_field,
219  const Vector& p_grid,
221  const Vector& f_grid,
222  const Index& stokes_dim,
223  const Matrix& z_surface,
224  const Numeric& surface_skin_t,
228  const Index& nstreams,
229  const String& pfct_method,
230  const String& groundtype,
231  const String& quadtype,
232  const Index& add_straight_angles,
233  const Index& pfct_aa_grid_size,
234  //const Numeric& pfct_threshold,
235  const Index& auto_inc_nstreams,
236  const Index& robust,
237  const Index& za_interp_order,
238  const Index& cos_za_interp,
239  const Numeric& max_delta_tau,
240  const Verbosity& verbosity) {
241  if (!cloudbox_on) {
242  CREATE_OUT0;
243  out0 << " Cloudbox is off, RT4 calculation will be skipped.\n";
244  return;
245  }
246 
247  // FIXME: so far surface is implictly assumed at lowest atmospheric level.
248  // That should be fixed (using z_surface and allowing other altitudes) at some
249  // point.
250 
251  const String quad_type = quadtype.toupper();
252  Index nhza, nhstreams, nummu;
253  check_rt4_input(nhstreams,
254  nhza,
255  nummu,
256  cloudbox_on,
262  scat_data,
264  stokes_dim,
265  nstreams,
266  quad_type,
267  add_straight_angles,
268  pnd_field.ncols());
269 
271 
272  // in RT4 mu_values is generally only output. however, we need the values for
273  // preparing the single scattering data at these angles. therefore, we
274  // calculate them here using RT4's proprietary quadrature methods. They
275  // simultaneously provide the quadrature weights, too. We keep them so far,
276  // might use them for ensuring proper normalization in the preparation of the
277  // single scattering data.
278  Vector mu_values(nummu, 0.);
279  Vector quad_weights(nummu, 0.);
280 
281  get_quad_angles(mu_values,
282  quad_weights,
283  za_grid,
284  aa_grid,
285  quad_type,
286  nhstreams,
287  nhza,
288  nummu);
289 
290  // Preparing surface setup.
291  //
292 
293  // Initializing surface related interface-related RT4 interface parameters.
294  const Index nf = f_grid.nelem();
295  const String ground_type = groundtype.toupper();
296 
297  // dummy values for parameters not relevant for this ground_type
298  Tensor5 surf_refl_mat(nf, nummu, stokes_dim, nummu, stokes_dim, 0.);
299  Tensor3 surf_emis_vec(nf, nummu, stokes_dim, 0.);
300 
301  // parameters that will be updated below
302  Vector ground_albedo(nf, 0.);
303  Tensor3 ground_reflec(nf, stokes_dim, stokes_dim, 0.);
304  Complex gidef(1, 0.);
305  ComplexVector ground_index(nf, gidef);
306 
307  get_rt4surf_props(ground_albedo,
308  ground_reflec,
309  ground_index,
310  f_grid,
311  ground_type,
316  stokes_dim);
317 
318  Agenda dummy_agenda;
319 
320  run_rt4(ws,
322  za_grid,
323  f_grid,
324  p_grid,
325  z_field(joker, 0, 0),
326  t_field(joker, 0, 0),
327  vmr_field(joker, joker, 0, 0),
328  pnd_field(joker, joker, 0, 0),
329  scat_data,
332  stokes_dim,
333  nummu,
334  nhza,
335  ground_type,
337  ground_albedo,
338  ground_reflec,
339  ground_index,
340  surf_refl_mat,
341  surf_emis_vec,
342  dummy_agenda,
343  z_surface(0, 0),
344  quad_type,
345  mu_values,
346  quad_weights,
347  auto_inc_nstreams,
348  robust,
349  za_interp_order,
350  cos_za_interp,
351  pfct_method,
352  pfct_aa_grid_size,
353  pfct_threshold,
354  max_delta_tau,
355  verbosity);
356 
357  za_grid_adjust(za_grid, mu_values, nummu);
358 }
359 
360 #else /* ENABLE_RT4 */
361 /* Workspace method: Doxygen documentation will be auto-generated */
363  // WS Output:
364  Tensor7&,
365  Vector&,
366  Vector&,
367  // WS Input
368  const Index&,
369  const Index&,
370  const Index&,
371  const Index&,
372  const Index&,
373  const ArrayOfIndex&,
374  const Agenda&,
375  const Agenda&,
376  const Index&,
377  const Tensor4&,
378  const Tensor3&,
379  const Tensor3&,
380  const Tensor4&,
381  const Vector&,
383  const Vector&,
384  const Index&,
385  const Matrix&,
386  const Index&,
387  const String&,
388  const String&,
389  const Index&,
390  const Index&,
391  //const Numeric&,
392  const Index&,
393  const Index&,
394  const Index&,
395  const Index&,
396  const Numeric&,
397  const Verbosity&) {
398  throw runtime_error("This version of ARTS was compiled without RT4 support.");
399 }
400 /* Workspace method: Doxygen documentation will be auto-generated */
402  // WS Output:
403  Tensor7&,
404  Vector&,
405  Vector&,
406  // WS Input
407  const Index&,
408  const Index&,
409  const Index&,
410  const Index&,
411  const Index&,
412  const ArrayOfIndex&,
413  const Agenda&,
414  const Index&,
415  const Tensor4&,
416  const Tensor3&,
417  const Tensor3&,
418  const Tensor4&,
419  const Vector&,
421  const Vector&,
422  const Index&,
423  const Matrix&,
424  const Numeric&,
425  const Vector&,
426  const Tensor3&,
427  const GriddedField3&,
428  const Index&,
429  const String&,
430  const String&,
431  const String&,
432  const Index&,
433  const Index&,
434  //const Numeric&,
435  const Index&,
436  const Index&,
437  const Index&,
438  const Index&,
439  const Numeric&,
440  const Verbosity&) {
441  throw runtime_error("This version of ARTS was compiled without RT4 support.");
442 }
443 
444 #endif /* ENABLE_RT4 */
445 
446 /* Workspace method: Doxygen documentation will be auto-generated */
447 #ifdef ENABLE_RT4
448 void RT4Test(Tensor4& out_rad,
449  const String& datapath,
450  const Verbosity& verbosity) {
451  rt4_test(out_rad, datapath, verbosity);
452 }
453 #else
454 void RT4Test(Tensor4&, const String&, const Verbosity&) {
455  throw runtime_error("This version of ARTS was compiled without RT4 support.");
456 }
457 #endif
Matrix
The Matrix class.
Definition: matpackI.h:1193
ARTS::Var::atmosphere_dim
Index atmosphere_dim(Workspace &ws) noexcept
Definition: autoarts.h:2510
ARTS::Var::z_field
Tensor3 z_field(Workspace &ws) noexcept
Definition: autoarts.h:7690
my_basic_string::toupper
void toupper()
Convert to upper case.
Definition: mystring.h:74
auto_md.h
ARTS::Var::atmgeom_checked
Index atmgeom_checked(Workspace &ws) noexcept
Definition: autoarts.h:2489
Tensor3
The Tensor3 class.
Definition: matpackIII.h:339
joker
const Joker joker
ARTS::Var::pnd_field
Tensor4 pnd_field(Workspace &ws) noexcept
Definition: autoarts.h:5081
ComplexVector
The ComplexVector class.
Definition: complex.h:573
ARTS::Var::verbosity
Verbosity verbosity(Workspace &ws) noexcept
Definition: autoarts.h:7112
ARTS::Var::cloudbox_limits
ArrayOfIndex cloudbox_limits(Workspace &ws) noexcept
Definition: autoarts.h:2762
ARTS::Var::stokes_dim
Index stokes_dim(Workspace &ws) noexcept
Definition: autoarts.h:6650
Complex
std::complex< Numeric > Complex
Definition: complex.h:33
Tensor4
The Tensor4 class.
Definition: matpackIV.h:421
ARTS::Var::surface_rtprop_agenda
Agenda surface_rtprop_agenda(Workspace &ws) noexcept
Definition: autoarts.h:6807
CREATE_OUT1
#define CREATE_OUT1
Definition: messages.h:205
Agenda
The Agenda class.
Definition: agenda_class.h:44
GriddedField3
Definition: gridded_fields.h:284
complex.h
A class implementing complex numbers for ARTS.
Array
This can be used to make arrays out of anything.
Definition: array.h:108
CREATE_OUT0
#define CREATE_OUT0
Definition: messages.h:204
messages.h
Declarations having to do with the four output streams.
my_basic_string< char >
ARTS::Var::vmr_field
Tensor4 vmr_field(Workspace &ws) noexcept
Definition: autoarts.h:7130
ARTS::Var::atmfields_checked
Index atmfields_checked(Workspace &ws) noexcept
Definition: autoarts.h:2473
ARTS::Var::p_grid
Vector p_grid(Workspace &ws) noexcept
Definition: autoarts.h:4763
RT4CalcWithRT4Surface
void RT4CalcWithRT4Surface(Workspace &, Tensor7 &, Vector &, Vector &, const Index &, const Index &, const Index &, const Index &, const Index &, const ArrayOfIndex &, const Agenda &, const Index &, const Tensor4 &, const Tensor3 &, const Tensor3 &, const Tensor4 &, const Vector &, const ArrayOfArrayOfSingleScatteringData &, const Vector &, const Index &, const Matrix &, const Numeric &, const Vector &, const Tensor3 &, const GriddedField3 &, const Index &, const String &, const String &, const String &, const Index &, const Index &, const Index &, const Index &, const Index &, const Index &, const Numeric &, const Verbosity &)
WORKSPACE METHOD: RT4CalcWithRT4Surface.
Definition: m_rt4.cc:401
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:49
ARTS::Var::surface_scalar_reflectivity
Vector surface_scalar_reflectivity(Workspace &ws) noexcept
Definition: autoarts.h:6864
ARTS::Var::f_grid
Vector f_grid(Workspace &ws) noexcept
Definition: autoarts.h:3449
ARTS::Var::scat_data
ArrayOfArrayOfSingleScatteringData scat_data(Workspace &ws) noexcept
Definition: autoarts.h:5840
m_xml.h
Workspace methods and template functions for supergeneric XML IO.
ARTS::Var::za_grid
Vector za_grid(Workspace &ws) noexcept
Definition: autoarts.h:7771
ARTS::Var::surface_complex_refr_index
GriddedField3 surface_complex_refr_index(Workspace &ws) noexcept
Definition: autoarts.h:6688
Tensor5
The Tensor5 class.
Definition: matpackV.h:506
ARTS::Var::scat_data_checked
Index scat_data_checked(Workspace &ws) noexcept
Definition: autoarts.h:5850
disort.h
Functions for disort interface.
ARTS::Var::t_field
Tensor3 t_field(Workspace &ws) noexcept
Definition: autoarts.h:6947
Workspace
Workspace class.
Definition: workspace_ng.h:40
RT4Test
void RT4Test(Tensor4 &, const String &, const Verbosity &)
WORKSPACE METHOD: RT4Test.
Definition: m_rt4.cc:454
init_ifield
void init_ifield(Tensor7 &cloudbox_field, const Vector &f_grid, const ArrayOfIndex &cloudbox_limits, const Index &nang, const Index &stokes_dim)
init_ifield.
Definition: disort.cc:207
ARTS::Var::cloudbox_field
Tensor7 cloudbox_field(Workspace &ws) noexcept
Definition: autoarts.h:2676
ARTS::Var::propmat_clearsky_agenda
Agenda propmat_clearsky_agenda(Workspace &ws) noexcept
Definition: autoarts.h:5405
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
ARTS::Var::surface_skin_t
Numeric surface_skin_t(Workspace &ws) noexcept
Definition: autoarts.h:6877
RT4Calc
void RT4Calc(Workspace &, Tensor7 &, Vector &, Vector &, const Index &, const Index &, const Index &, const Index &, const Index &, const ArrayOfIndex &, const Agenda &, const Agenda &, const Index &, const Tensor4 &, const Tensor3 &, const Tensor3 &, const Tensor4 &, const Vector &, const ArrayOfArrayOfSingleScatteringData &, const Vector &, const Index &, const Matrix &, const Index &, const String &, const String &, const Index &, const Index &, const Index &, const Index &, const Index &, const Index &, const Numeric &, const Verbosity &)
WORKSPACE METHOD: RT4Calc.
Definition: m_rt4.cc:362
Vector
The Vector class.
Definition: matpackI.h:860
ARTS::Var::aa_grid
Vector aa_grid(Workspace &ws) noexcept
Definition: autoarts.h:1717
ARTS::Var::cloudbox_checked
Index cloudbox_checked(Workspace &ws) noexcept
Definition: autoarts.h:2650
ARTS::Var::z_surface
Matrix z_surface(Workspace &ws) noexcept
Definition: autoarts.h:7754
ARTS::Var::surface_reflectivity
Tensor3 surface_reflectivity(Workspace &ws) noexcept
Definition: autoarts.h:6778
Tensor7
The Tensor7 class.
Definition: matpackVII.h:2382
rt4.h
Contains functions related to application of scattering solver RT4.
ARTS::Var::cloudbox_on
Index cloudbox_on(Workspace &ws) noexcept
Definition: autoarts.h:2782