ARTS  2.3.1285(git:92a29ea9-dirty)
m_disort.cc
Go to the documentation of this file.
1 /* Copyright (C) 2006-2012 Claudia Emde <claudia.emde@dlr.de>
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 
31 /*===========================================================================
32  === External declarations
33  ===========================================================================*/
34 
35 #include <cmath>
36 #include <cstdlib>
37 #include <cstring>
38 #include <iostream>
39 #include <stdexcept>
40 #include "array.h"
41 #include "arts.h"
42 #include "auto_md.h"
43 #include "disort.h"
44 #include "m_general.h"
45 #include "math_funcs.h"
46 #include "messages.h"
47 #include "wsv_aux.h"
48 #include "xml_io.h"
49 
50 /* Workspace method: Doxygen documentation will be auto-generated */
52  // WS Output:
53  Tensor7& cloudbox_field,
54  // WS Input
55  const Index& atmfields_checked,
56  const Index& atmgeom_checked,
57  const Index& scat_data_checked,
58  const Index& cloudbox_checked,
59  const Index& cloudbox_on,
60  const ArrayOfIndex& cloudbox_limits,
61  const Agenda& propmat_clearsky_agenda,
62  const Index& atmosphere_dim,
63  const Tensor4& pnd_field,
64  const Tensor3& t_field,
65  const Tensor3& z_field,
66  const Tensor4& vmr_field,
67  const Vector& p_grid,
68  const ArrayOfArrayOfSingleScatteringData& scat_data,
69  const Vector& f_grid,
70  const Vector& za_grid,
71  const Index& stokes_dim,
72  const Matrix& z_surface,
73  const Numeric& surface_skin_t,
74  const Vector& surface_scalar_reflectivity,
75  const Index& nstreams,
76  const String& pfct_method,
77  const Index& Npfct,
78  const Index& cdisort_quiet,
79  const Verbosity& verbosity) {
80  // Don't do anything if there's no cloudbox defined.
81  if (!cloudbox_on) {
83  out0 << " Cloudbox is off, DISORT calculation will be skipped.\n";
84  return;
85  }
86 
87  // FIXME: At the moment, combining scattering elements stored on different
88  // scattering angle grids is only possible for pfct_method 'interpolate'.
89 
90  check_disort_input(cloudbox_on,
91  atmfields_checked,
92  atmgeom_checked,
93  cloudbox_checked,
94  scat_data_checked,
95  atmosphere_dim,
96  stokes_dim,
97  cloudbox_limits,
98  scat_data,
99  za_grid,
100  nstreams,
101  pfct_method);
102 
103  init_ifield(
104  cloudbox_field, f_grid, cloudbox_limits, za_grid.nelem(), stokes_dim);
105 
106  Vector albedo(f_grid.nelem(), 0.);
107  Numeric btemp;
108 
110  albedo, btemp, f_grid, surface_skin_t, surface_scalar_reflectivity);
111 
112  run_cdisort(ws,
113  cloudbox_field,
114  f_grid,
115  p_grid,
116  z_field(joker, 0, 0),
117  z_surface(0, 0),
118  t_field(joker, 0, 0),
119  vmr_field(joker, joker, 0, 0),
120  pnd_field(joker, joker, 0, 0),
121  scat_data,
122  propmat_clearsky_agenda,
123  cloudbox_limits,
124  btemp,
125  albedo,
126  za_grid,
127  nstreams,
128  Npfct,
129  cdisort_quiet,
130  verbosity);
131 }
132 
133 /* Workspace method: Doxygen documentation will be auto-generated */
135  Workspace& ws,
136  // WS Output:
137  Tensor7& cloudbox_field,
138  // WS Input
139  const Index& atmfields_checked,
140  const Index& atmgeom_checked,
141  const Index& scat_data_checked,
142  const Index& cloudbox_checked,
143  const Index& cloudbox_on,
144  const ArrayOfIndex& cloudbox_limits,
145  const Agenda& propmat_clearsky_agenda,
146  const Agenda& surface_rtprop_agenda,
147  const Index& atmosphere_dim,
148  const Tensor4& pnd_field,
149  const Tensor3& t_field,
150  const Tensor3& z_field,
151  const Tensor4& vmr_field,
152  const Vector& p_grid,
153  const ArrayOfArrayOfSingleScatteringData& scat_data,
154  const Vector& f_grid,
155  const Vector& za_grid,
156  const Index& stokes_dim,
157  const Index& nstreams,
158  const String& pfct_method,
159  const Index& Npfct,
160  const Index& cdisort_quiet,
161  const Verbosity& verbosity) {
162  if (!cloudbox_on) {
163  CREATE_OUT0;
164  out0 << " Cloudbox is off, DISORT calculation will be skipped.\n";
165  return;
166  }
167 
168  // FIXME: so far surface is implictly assumed at lowest atmospheric level.
169  // That should be fixed (using z_surface and allowing other altitudes) at some
170  // point.
171 
172  // FIXME: At the moment, combining scattering elements stored on different
173  // scattering angle grids is only possible for pfct_method 'interpolate'.
174 
175  check_disort_input(cloudbox_on,
176  atmfields_checked,
177  atmgeom_checked,
178  cloudbox_checked,
179  scat_data_checked,
180  atmosphere_dim,
181  stokes_dim,
182  cloudbox_limits,
183  scat_data,
184  za_grid,
185  nstreams,
186  pfct_method);
187 
188  init_ifield(
189  cloudbox_field, f_grid, cloudbox_limits, za_grid.nelem(), stokes_dim);
190 
191  Vector albedo(f_grid.nelem(), 0.);
192  Numeric btemp;
193 
194  // for now, surface at lowest atm level. later use z_surface or the like
195  // for that.
196  // at the moment this is only required for groundtype "A", but
197  const Numeric surf_altitude = z_field(0, 0, 0);
198  //const Numeric surf_altitude = z_surface(0,0);
199 
200  surf_albedoCalc(ws,
201  albedo,
202  btemp,
203  surface_rtprop_agenda,
204  f_grid,
205  za_grid,
206  surf_altitude,
207  verbosity);
208 
209  run_cdisort(ws,
210  cloudbox_field,
211  f_grid,
212  p_grid,
213  z_field(joker, 0, 0),
214  surf_altitude,
215  t_field(joker, 0, 0),
216  vmr_field(joker, joker, 0, 0),
217  pnd_field(joker, joker, 0, 0),
218  scat_data,
219  propmat_clearsky_agenda,
220  cloudbox_limits,
221  btemp,
222  albedo,
223  za_grid,
224  nstreams,
225  Npfct,
226  cdisort_quiet,
227  verbosity);
228 }
229 
230 /* Workspace method: Doxygen documentation will be auto-generated */
232  Tensor7& spectral_radiance_field,
233  const Index& atmfields_checked,
234  const Index& atmgeom_checked,
235  const Agenda& propmat_clearsky_agenda,
236  const Index& atmosphere_dim,
237  const Tensor3& t_field,
238  const Tensor3& z_field,
239  const Tensor4& vmr_field,
240  const Vector& p_grid,
241  const Vector& f_grid,
242  const Vector& za_grid,
243  const Index& stokes_dim,
244  const Matrix& z_surface,
245  const Numeric& surface_skin_t,
246  const Vector& surface_scalar_reflectivity,
247  const Index& nstreams,
248  const Index& cdisort_quiet,
249  const Verbosity& verbosity) {
250  if (atmosphere_dim != 1)
251  throw runtime_error(
252  "For running DISORT, atmospheric dimensionality "
253  "must be 1.\n");
254 
255  // Set cloudbox to cover complete atmosphere
256  Index cloudbox_on;
257  ArrayOfIndex cloudbox_limits;
258  const Index cloudbox_checked = 1;
259  //
260  cloudboxSetFullAtm(cloudbox_on,
261  cloudbox_limits,
262  atmosphere_dim,
263  p_grid,
264  Vector(0),
265  Vector(0),
266  verbosity);
267 
268  // Create data matching no particles
269  Tensor4 pnd_field;
270  ArrayOfTensor4 dpnd_field_dx;
272  const Index scat_data_checked = 1;
273  //
274  pnd_fieldZero(pnd_field,
275  dpnd_field_dx,
276  scat_data,
277  atmosphere_dim,
278  f_grid,
279  cloudbox_limits,
281  verbosity);
282 
283  // Call standard DISORT method
284  DisortCalc(ws,
285  spectral_radiance_field,
286  atmfields_checked,
287  atmgeom_checked,
288  scat_data_checked,
289  cloudbox_checked,
290  cloudbox_on,
291  cloudbox_limits,
292  propmat_clearsky_agenda,
293  atmosphere_dim,
294  pnd_field,
295  t_field,
296  z_field,
297  vmr_field,
298  p_grid,
299  scat_data,
300  f_grid,
301  za_grid,
302  stokes_dim,
303  z_surface,
304  surface_skin_t,
305  surface_scalar_reflectivity,
306  nstreams,
307  "median",
308  181,
309  cdisort_quiet,
310  verbosity);
311 }
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Template functions for general supergeneric ws methods.
void DisortCalcClearsky(Workspace &ws, Tensor7 &spectral_radiance_field, const Index &atmfields_checked, const Index &atmgeom_checked, const Agenda &propmat_clearsky_agenda, const Index &atmosphere_dim, const Tensor3 &t_field, const Tensor3 &z_field, const Tensor4 &vmr_field, const Vector &p_grid, const Vector &f_grid, const Vector &za_grid, const Index &stokes_dim, const Matrix &z_surface, const Numeric &surface_skin_t, const Vector &surface_scalar_reflectivity, const Index &nstreams, const Index &cdisort_quiet, const Verbosity &verbosity)
WORKSPACE METHOD: DisortCalcClearsky.
Definition: m_disort.cc:231
The Agenda class.
Definition: agenda_class.h:44
Declarations having to do with the four output streams.
void run_cdisort(Workspace &ws, Tensor7 &cloudbox_field, ConstVectorView f_grid, ConstVectorView p_grid, ConstVectorView z_profile, const Numeric &z_surface, ConstVectorView t_profile, ConstMatrixView vmr_profiles, ConstMatrixView pnd_profiles, const ArrayOfArrayOfSingleScatteringData &scat_data, const Agenda &propmat_clearsky_agenda, const ArrayOfIndex &cloudbox_limits, const Numeric &surface_skin_t, const Vector &surface_scalar_reflectivity, ConstVectorView za_grid, const Index &nstreams, const Index &Npfct, const Index &quiet, const Verbosity &verbosity)
Calculate doit_i_feild with Disort.
Definition: disort.cc:769
The Vector class.
Definition: matpackI.h:860
void surf_albedoCalc(Workspace &ws, VectorView albedo, Numeric &btemp, const Agenda &surface_rtprop_agenda, ConstVectorView f_grid, ConstVectorView scat_za_grid, const Numeric &surf_alt, const Verbosity &verbosity)
Surface albed.
Definition: disort.cc:960
The Tensor4 class.
Definition: matpackIV.h:421
void get_disortsurf_props(Vector &albedo, Numeric &btemp, ConstVectorView f_grid, const Numeric &surface_skin_t, ConstVectorView surface_scalar_reflectivity)
get_disortsurf_props.
Definition: disort.cc:223
Array< RetrievalQuantity > ArrayOfRetrievalQuantity
Definition: jacobian.h:402
invlib::Vector< ArtsVector > Vector
invlib wrapper type for ARTS vectors.
Definition: oem.h:32
void check_disort_input(const Index &cloudbox_on, const Index &atmfields_checked, const Index &atmgeom_checked, const Index &cloudbox_checked, const Index &scat_data_checked, const Index &atmosphere_dim, const Index &stokes_dim, const ArrayOfIndex &cloudbox_limits, const ArrayOfArrayOfSingleScatteringData &scat_data, ConstVectorView za_grid, const Index &nstreams, const String &pfct_method)
check_disort_input.
Definition: disort.cc:55
This file contains basic functions to handle XML data files.
The Tensor7 class.
Definition: matpackVII.h:2382
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:51
This file contains the definition of Array.
void pnd_fieldZero(Tensor4 &pnd_field, ArrayOfTensor4 &dpnd_field_dx, ArrayOfArrayOfSingleScatteringData &scat_data, const Index &atmosphere_dim, const Vector &f_grid, const ArrayOfIndex &cloudbox_limits, const ArrayOfRetrievalQuantity &jacobian_quantities, const Verbosity &)
WORKSPACE METHOD: pnd_fieldZero.
Definition: m_cloudbox.cc:2030
The Tensor3 class.
Definition: matpackIII.h:339
The global header file for ARTS.
void DisortCalc(Workspace &ws, Tensor7 &cloudbox_field, const Index &atmfields_checked, const Index &atmgeom_checked, const Index &scat_data_checked, const Index &cloudbox_checked, const Index &cloudbox_on, const ArrayOfIndex &cloudbox_limits, const Agenda &propmat_clearsky_agenda, const Index &atmosphere_dim, const Tensor4 &pnd_field, const Tensor3 &t_field, const Tensor3 &z_field, const Tensor4 &vmr_field, const Vector &p_grid, const ArrayOfArrayOfSingleScatteringData &scat_data, const Vector &f_grid, const Vector &za_grid, const Index &stokes_dim, const Matrix &z_surface, const Numeric &surface_skin_t, const Vector &surface_scalar_reflectivity, const Index &nstreams, const String &pfct_method, const Index &Npfct, const Index &cdisort_quiet, const Verbosity &verbosity)
WORKSPACE METHOD: DisortCalc.
Definition: m_disort.cc:51
void DisortCalcWithARTSSurface(Workspace &ws, Tensor7 &cloudbox_field, const Index &atmfields_checked, const Index &atmgeom_checked, const Index &scat_data_checked, const Index &cloudbox_checked, const Index &cloudbox_on, const ArrayOfIndex &cloudbox_limits, const Agenda &propmat_clearsky_agenda, const Agenda &surface_rtprop_agenda, const Index &atmosphere_dim, const Tensor4 &pnd_field, const Tensor3 &t_field, const Tensor3 &z_field, const Tensor4 &vmr_field, const Vector &p_grid, const ArrayOfArrayOfSingleScatteringData &scat_data, const Vector &f_grid, const Vector &za_grid, const Index &stokes_dim, const Index &nstreams, const String &pfct_method, const Index &Npfct, const Index &cdisort_quiet, const Verbosity &verbosity)
WORKSPACE METHOD: DisortCalcWithARTSSurface.
Definition: m_disort.cc:134
const Joker joker
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
The Matrix class.
Definition: matpackI.h:1193
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
This can be used to make arrays out of anything.
Definition: array.h:40
Workspace class.
Definition: workspace_ng.h:40
void cloudboxSetFullAtm(Index &cloudbox_on, ArrayOfIndex &cloudbox_limits, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Verbosity &)
WORKSPACE METHOD: cloudboxSetFullAtm.
Definition: m_cloudbox.cc:283
#define CREATE_OUT0
Definition: messages.h:204
Functions for disort interface.
Auxiliary header stuff related to workspace variable groups.