ARTS  2.0.49
m_batch.cc
Go to the documentation of this file.
1 
2 /* Copyright (C) 2004-2008
3  Patrick Eriksson <Patrick.Eriksson@rss.chalmers.se>
4  Stefan Buehler <sbuehler@ltu.se>
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by the
8  Free Software Foundation; either version 2, or (at your option) any
9  later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19  USA. */
20 
21 
22 
23 /*===========================================================================
24  === File description
25  ===========================================================================*/
26 
40 /*===========================================================================
41  === External declarations
42  ===========================================================================*/
43 
44 #include <cmath>
45 using namespace std;
46 
47 #include "arts.h"
48 #include "arts_omp.h"
49 #include "auto_md.h"
50 #include "math_funcs.h"
51 #include "physics_funcs.h"
52 #include "rte.h"
53 #include "xml_io.h"
54 
55 extern const Numeric PI;
56 extern const Numeric DEG2RAD;
57 extern const Numeric RAD2DEG;
58 extern const Index GFIELD3_P_GRID;
59 
60 
61 /*===========================================================================
62  === The functions (in alphabetical order)
63  ===========================================================================*/
64 
65 
66 /* Workspace method: Doxygen documentation will be auto-generated
67 
68  2008-07-21 Stefan Buehler */
69 void ForLoop(Workspace& ws,
70  // WS Input:
71  const Agenda& forloop_agenda,
72  // Control Parameters:
73  const Index& start,
74  const Index& stop,
75  const Index& step,
76  const Verbosity& verbosity)
77 {
79 
80  for (Index i=start; i<=stop; i+=step)
81  {
82  out1 << " Executing for loop body, index: " << i << "\n";
83  forloop_agendaExecute(ws, i, forloop_agenda);
84  }
85 }
86 
87 
88 /* Workspace method: Doxygen documentation will be auto-generated
89 
90  2004-09-15 Patrick Eriksson
91 
92  Added keyword to control if row or column is extracted.
93 
94  2007-07-24 Stefan Buehler */
96  // WS Generic Output:
97  Vector& v,
98  // WS Input:
99  // WS Generic Input:
100  const Matrix& m,
101  const Index& index,
102  // Control Parameters:
103  const String& direction,
104  const Verbosity&)
105 {
106  if (direction=="row")
107  {
108  if( index >= m.nrows() )
109  {
110  ostringstream os;
111  os << "The index " << index
112  << " is outside the row range of the Matrix.";
113  throw runtime_error( os.str() );
114 
115  }
116 
117  v.resize( m.ncols() );
118  v = m( index, joker );
119  }
120  else if (direction=="column")
121  {
122  if( index >= m.ncols() )
123  {
124  ostringstream os;
125  os << "The index " << index
126  << " is outside the column range of the Matrix.";
127  throw runtime_error( os.str() );
128 
129  }
130 
131  v.resize( m.nrows() );
132  v = m( joker, index );
133  }
134  else
135  {
136  ostringstream os;
137  os << "Keyword *direction* must be either *row* or *column*,"
138  << "but you gave: " << direction << ".";
139  throw runtime_error( os.str() );
140  }
141 }
142 
143 
144 /* Workspace method: Doxygen documentation will be auto-generated */
146  // WS Output:
147  Matrix& ybatch,
148  ArrayOfMatrix& ybatch_jacobians,
149  // WS Input:
150  const Index& ybatch_start,
151  const Index& ybatch_n,
152  const Agenda& ybatch_calc_agenda,
153  // Control Parameters:
154  const Index& robust,
155  const Verbosity& verbosity)
156 {
158 
159  Vector y;
160  Matrix jacobian;
161  bool is_first = true;
162  Index first_ybatch_index = 0;
163 
164  // We have to calculate the first y so that we can size the output
165  // matrix ybatch correctly. This is a bit complicated due to the
166  // robust option: We must handle the case that the first few jobs
167  // fail.
168 
169  // We allow a start index ybatch_start that is different from 0. We
170  // will calculate ybatch_n jobs starting at the start
171  // index. Internally, we count from zero, which is the right
172  // counting for the output array ybatch. When we call
173  // ybatch_calc_agenda, we add ybatch_start to the internal index
174  // count.
175 
176  // We create a counter, so that we can generate nice output about
177  // how many jobs are already done. (All parallel threads later will
178  // increment this, so that we really get an accurate total count!)
179  Index job_counter = 0;
180 
181  // A flag to indicate whether we are calculating (and storing)
182  // Jacobians. Default is that we don't. But this is set to true
183  // if the first batch job does return a non-empty Jacobian.
184  bool store_jacobians = false;
185 
186  while (is_first && first_ybatch_index < ybatch_n)
187  {
188  ++job_counter;
189 
190  out2 << " Job " << job_counter << " of " << ybatch_n
191  << ": Index " << ybatch_start+first_ybatch_index << "\n";
192 
193  try
194  {
196  y,
197  jacobian,
198  ybatch_start+first_ybatch_index,
199  ybatch_calc_agenda);
200 
201  // The size of ybatch has to be set after the first job
202  // has run successfully.
203  ybatch.resize( y.nelem(), ybatch_n);
204 
205  // Initialize with "-1" everywhere. This will also take
206  // care of the case that there were some unsuccessful
207  // jobs before the first successful one.
208  ybatch = -1;
209 
210  // Now resize also the container for all the Jacobians, ybatch_jacobians.
211 
212  // Dimensions of Jacobian:
213  const Index Knr = jacobian.nrows();
214  const Index Knc = jacobian.ncols();
215 
216  if (Knr!=0 || Knc!=0)
217  {
218  store_jacobians = true;
219 
220  if (Knr!=y.nelem())
221  {
222  out0 << "First dimension of Jacobian must have same length as the measurement *y*.\n"
223  << "Length of *y*: " << y.nelem() << "\n"
224  << "Dimensions of *jacobian*: (" << Knr << ", " << Knc << ")\n";
225  arts_exit();
226  // We jump to exit here directly, since runtime errors are ignored
227  // if the robust option is on. But mismatch of the Jacobian
228  // dimension is a fatal error and should result in program termination.
229  }
230 
231  // Resize the container for all the Jacobians:
232  ybatch_jacobians.resize(ybatch_n);
233 
234  // After creation, all individual Jacobi matrices in the array will be
235  // empty (size zero). No need for explicit initialization.
236  }
237 
238  is_first = false;
239 
240  if (y.nelem())
241  {
242  ybatch(joker, first_ybatch_index) = y;
243 
244  if(store_jacobians)
245  ybatch_jacobians[first_ybatch_index] = jacobian;
246  }
247  }
248  catch (runtime_error e)
249  {
250  if (robust)
251  {
252  out0 << "WARNING! Job failed. Output variable ybatch will be set\n"
253  << "to -1 for this job. The runtime error produced was:\n"
254  << e.what() << "\n";
255 
256  // No need to set ybatch to -1 here, since it is initialized
257  // with that value.
258  }
259  else
260  {
261  // The user wants the batch job to fail if one of the
262  // jobs goes wrong.
263  throw runtime_error(e.what());
264  }
265  }
266  first_ybatch_index++;
267  }
268 
269  // We have to make a local copy of the Workspace and the agendas because
270  // only non-reference types can be declared firstprivate in OpenMP
271  Workspace l_ws(ws);
272  Agenda l_ybatch_calc_agenda(ybatch_calc_agenda);
273 
274  // Go through the batch:
275 
276 /*#pragma omp parallel for \
277  if(!arts_omp_in_parallel()) \
278  default(none) \
279  shared(job_counter, first_ybatch_index, out2, joker, out0, \
280  ybatch_n, ybatch_start, ybatch, robust) \
281  firstprivate(l_ws, l_ybatch_calc_agenda) \
282  private(y) */
283 #pragma omp parallel for \
284  if(!arts_omp_in_parallel()) \
285  firstprivate(l_ws, l_ybatch_calc_agenda) \
286  private(y, jacobian)
287  for(Index ybatch_index = first_ybatch_index;
288  ybatch_index<ybatch_n;
289  ybatch_index++ )
290  {
291  Index l_job_counter; // Thread-local copy of job counter.
292 
293 #pragma omp critical
294  {
295  l_job_counter = ++job_counter;
296  }
297 
298  {
299  ostringstream os;
300  os << " Job " << l_job_counter << " of " << ybatch_n
301  << ", Index " << ybatch_start+ybatch_index << ", Thread-Id "
302  << arts_omp_get_thread_num() << "\n";
303  out2 << os.str();
304  }
305 
306  try
307  {
309  y,
310  jacobian,
311  ybatch_start+ybatch_index,
312  l_ybatch_calc_agenda );
313 
314  if (y.nelem())
315  {
316  ybatch( joker, ybatch_index ) = y;
317 
318  if(store_jacobians)
319  ybatch_jacobians[ybatch_index] = jacobian;
320  }
321  }
322  catch (runtime_error e)
323  {
324  if (robust)
325  {
326  ostringstream os;
327  os << "WARNING! Job failed. Output variable ybatch will be set\n"
328  << "to -1 for this job. The runtime error produced was:\n"
329  << e.what() << "\n";
330  out0 << os.str();
331 
332  // No need to set ybatch to -1 here, since it is initialized
333  // with that value.
334  }
335  else
336  {
337  // The user wants the batch job to fail if one of the
338  // jobs goes wrong.
339  exit_or_rethrow(e.what(), out0);
340  }
341  }
342  }
343 }
344 
345 
346 /* Workspace method: Doxygen documentation will be auto-generated */
348  Workspace& ws,
349  //Output
350  Matrix& ybatch,
351  //Input
352  const ArrayOfArrayOfSpeciesTag& abs_species,
353  const Agenda& met_profile_calc_agenda,
354  const Vector& f_grid,
355  const Matrix& met_amsu_data,
356  const Matrix& sensor_pos,
357  const Matrix& r_geoid,
358  const Vector& lat_grid,
359  const Vector& lon_grid,
360  const Index& atmosphere_dim,
361  const ArrayOfSingleScatteringData& scat_data_raw,
362  //Keyword
363  const Index& nelem_p_grid,
364  const String& met_profile_path,
365  const String& met_profile_pnd_path,
366  const Verbosity& verbosity)
367 {
368  GriddedField3 t_field_raw;
369  GriddedField3 z_field_raw;
370  ArrayOfGriddedField3 vmr_field_raw;
371  ArrayOfGriddedField3 pnd_field_raw;
372  Vector p_grid;
373  Matrix sensor_los;
374  Index cloudbox_on;
375  ArrayOfIndex cloudbox_limits;
376  Matrix z_surface;
377  Vector y;
378  Index no_profiles = met_amsu_data.nrows();
379 
380  // *vmr_field_raw* is an ArrayOfArrayOfTensor3 where the first array
381  //holds the gaseous species.
382  //Resize *vmr_field_raw* according to the number of gaseous species
383  //elements
384  vmr_field_raw.resize(abs_species.nelem());
385 
386  //pnd_field_raw is an ArrayOfArrayOfTensor3 where the first array
387  //holds particle species.
388  // Number of particle types:
389  const Index N_pt = scat_data_raw.nelem();
390 
391  pnd_field_raw.resize(N_pt);
392 
393  // The satellite zenith angle is read in from the amsu data
394  // and converted to arts sensor_los
395  ConstVectorView sat_za_from_data = met_amsu_data(Range(joker),3);
396 
397  sensor_los.resize(1,1);
398 
399  // The lat and lon are extracted to get the proper file names of
400  // profiles
401  ConstVectorView lat = met_amsu_data(Range(joker),0);
402  ConstVectorView lon = met_amsu_data(Range(joker),1);
403 
404  z_surface.resize(1,1);
405 
406  // The spectra .
407  y.resize(f_grid.nelem());
408 
409  // The batch spectra.
410  ybatch.resize(no_profiles, f_grid.nelem());
411 
412  // Loop over the number of profiles.
413  for (Index i = 0; i < no_profiles; ++ i)
414  {
415  ostringstream lat_os, lon_os;
416 
417  Index lat_prec = 3;
418  if(lat[i] < 0) lat_prec--;
419  if(abs(lat[i])>=10 )
420  {
421  lat_prec--;
422  if(abs(lat[i])>=100 ) lat_prec--;
423  }
424 
425  lat_os.setf (ios::showpoint | ios::fixed);
426  lat_os << setprecision((int)lat_prec) << lat[i];
427 
428  Index lon_prec = 4;
429  if(lon[i] < 0) lon_prec--;
430  if(abs(lon[i])>=10 )
431  {
432  lon_prec--;
433  if(abs(lon[i])>=100 ) lon_prec--;
434  }
435  lon_os.setf (ios::showpoint | ios::fixed);
436  lon_os << setprecision((int)lon_prec) << lon[i];
437 
438  sensor_los(0,0) =
439  180.0 - (asin(r_geoid(0,0) * sin(sat_za_from_data[i] * DEG2RAD) /sensor_pos(0,0)))* RAD2DEG;
440 
441  //Reads the t_field_raw from file
442  xml_read_from_file(met_profile_path +"profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".t.xml",
443  t_field_raw, verbosity);
444 
445  //Reads the z_field_raw from file
446  xml_read_from_file(met_profile_path +"profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".z.xml",
447  z_field_raw, verbosity);
448 
449  //Reads the humidity from file - it is only an ArrayofTensor3
450  xml_read_from_file(met_profile_path +"profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".H2O.xml",
451  vmr_field_raw[0], verbosity);
452 
453  //Reads the pnd_field_raw for one particle
454  //xml_read_from_file("/rinax/storage/users/rekha/uk_data/profiles/new_obs/newest_forecastfields/reff100/profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".pnd100.xml", pnd_field_raw[0]);
455 
456  //xml_read_from_file(met_profile_pnd_path +"reff100_newformat/profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".pnd100.xml", pnd_field_raw[0]);
457 
458  xml_read_from_file(met_profile_pnd_path +"lwc_reff15/profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".pnd15.xml",
459  pnd_field_raw[0], verbosity);
460  //Write the profile number into a file.
461  // xml_write_to_file("profile_number.xml", i);
462 
463  // Set z_surface from lowest level of z_field
464  z_surface(0,0) = z_field_raw.data(0,0,0);
465 
466  /* The vmr_field_raw is an ArrayofArrayofTensor3 where the outer
467  array is for species.
468 
469  The oxygen and nitrogen VMRs are set to constant values of 0.209
470  and 0.782, respectively and are used along with humidity field
471  to generate *vmr_field_raw*.*/
472 
473  /*The second element of the species. The first 3 Tensors in the
474  array are the same . They are pressure grid, latitude grid and
475  longitude grid. The third tensor which is the vmr is set to a
476  constant value of 0.782, corresponding to N2.*/
477 
478  vmr_field_raw[1].resize(vmr_field_raw[0]);
479  vmr_field_raw[1].copy_grids(vmr_field_raw[0]);
480  vmr_field_raw[1] = 0.782;//vmr of N2
481 
482  /*the third element of the species. the first 3 Tensors in the
483  array are the same . They are pressure grid, latitude grid and
484  longitude grid. The third tensor which is the vmr is set to a
485  constant value of 0.209, corresponding to O2.*/
486  vmr_field_raw[2].resize(vmr_field_raw[0]);
487  vmr_field_raw[2].copy_grids(vmr_field_raw[0]);
488  vmr_field_raw[2] = 0.209;//vmr of O2
489 
490  const ConstVectorView tfr_p_grid = t_field_raw.get_numeric_grid(GFIELD3_P_GRID);
491  // N_p is the number of elements in the pressure grid
492  Index N_p = tfr_p_grid.nelem();
493 
494  //Making a p_grid with the first and last element taken from the profile.
495  VectorNLogSpace(p_grid,
496  nelem_p_grid,
497  tfr_p_grid[0],
498  tfr_p_grid[N_p -1],
499  verbosity);
500 
501  /*To set the cloudbox limits, the lower and upper cloudbox limits
502  are to be set. The lower cloudbox limit is set to the lowest
503  pressure level. The upper level is the highest level where the
504  ice water content is non-zero.*/
505  Numeric cl_grid_min, cl_grid_max;
506 
507  //Lower limit = lowest pressure level of the original grid.
508  //Could it be the interpolated p_grid? FIXME STR
509  cl_grid_min = tfr_p_grid[0];
510 
511  // A counter for non-zero ice content
512  Index level_counter = 0;
513 
514  // Loop over all pressure levels
515  for (Index ip = 0; ip< N_p; ++ip)
516  {
517  //Checking for non-zero ice content. 0.001 is a threshold for
518  //ice water content.
519  // if((pnd_field_raw[0].data()(ip, 0, 0) > 0.001) || (pnd_field_raw[1](ip, 0, 0) > 0.001))
520  if(pnd_field_raw[0].data(ip, 0, 0) > 0.001)
521  {
522  ++level_counter;
523  //if non-zero ice content is found, it is set to upper
524  //cloudbox limit. Moreover, we take one level higher
525  // than the upper limit because we want the upper limit
526  //to have 0 pnd.
527  cl_grid_max = tfr_p_grid[ip +1];
528  }
529  }
530 
531  //cloudbox limits have dimensions 2*atmosphere_dim
532  cloudbox_limits.resize( atmosphere_dim*2 );
533 
534  //if there is no cloud in the considered profile, still we
535  //need to set the upper limit. I here set the first level
536  //for the upper cloudbox limit.
537  if(level_counter == 0)
538  {
539  cl_grid_max = p_grid[1];
540  }
541 
542  //Cloudbox is set.
543  cloudboxSetManually(cloudbox_on,
544  cloudbox_limits,
545  atmosphere_dim,
546  p_grid,
547  lat_grid,
548  lon_grid,
549  cl_grid_min,
550  cl_grid_max,
551  0,0,0,0,
552  verbosity);
553 
554  /*executing the met_profile_calc_agenda
555  Agenda communication variables are
556  Output of met_profile_calc_agenda : y
557  Input to met_profile_calc_agenda : t_field_raw,
558  z_field_raw, vmr_field_raw, pnd_field_raw, p_grid,
559  sensor_los, cloudbox_on, cloudbox_limits, z_surface, */
560 
561  met_profile_calc_agendaExecute (ws, y, t_field_raw, vmr_field_raw,
562  z_field_raw, pnd_field_raw, p_grid,
563  sensor_los, cloudbox_on,
564  cloudbox_limits, z_surface,
565  met_profile_calc_agenda );
566 
567  //putting in the spectra *y* for each profile, thus assigning y
568  //to the ith row of ybatch
569  ybatch(i, Range(joker)) = y;
570 
571  }// closing the loop over profile basenames
572 }
573 
574 
575 /* Workspace method: Doxygen documentation will be auto-generated */
577  Workspace& ws,
578  //Output
579  Matrix& ybatch,
580  //Input
581  const ArrayOfArrayOfSpeciesTag& abs_species,
582  const Agenda& met_profile_calc_agenda,
583  const Vector& f_grid,
584  const Matrix& met_amsu_data,
585  const Matrix& sensor_pos,
586  const Matrix& r_geoid,
587  //Keyword
588  const Index& nelem_p_grid,
589  const String& met_profile_path,
590  const Verbosity& verbosity)
591 {
592  GriddedField3 t_field_raw;
593  GriddedField3 z_field_raw;
594  ArrayOfGriddedField3 vmr_field_raw;
595  ArrayOfGriddedField3 pnd_field_raw;
596  Vector p_grid;
597  Matrix sensor_los;
598  Index cloudbox_on = 0;
599  ArrayOfIndex cloudbox_limits;
600  Matrix z_surface;
601  Vector y;
602  Index no_profiles = met_amsu_data.nrows();
603  //Index no_profiles = met_profile_basenames.nelem();
604  // The humidity data is stored as an ArrayOfTensor3 whereas
605  // vmr_field_raw is an ArrayOfArrayOfTensor3
606  GriddedField3 vmr_field_raw_h2o;
607 
608  vmr_field_raw.resize(abs_species.nelem());
609 
610  y.resize(f_grid.nelem());
611  ybatch.resize(no_profiles, f_grid.nelem());
612 
613  Vector sat_za_from_profile;
614  sat_za_from_profile = met_amsu_data(Range(joker),3);
615  Numeric sat_za;
616 
617  sensor_los.resize(1,1);
618 
619  Vector lat, lon;
620  lat = met_amsu_data(Range(joker),0);
621  lon = met_amsu_data(Range(joker),1);
622 
623  Vector oro_height;
624  oro_height = met_amsu_data(Range(joker),5);
625 
626  z_surface.resize(1,1);
627  for (Index i = 0; i < no_profiles; ++ i)
628  {
629  ostringstream lat_os, lon_os;
630 
631  Index lat_prec = 3;
632  if(lat[i] < 0) lat_prec--;
633  if(abs(lat[i])>=10 )
634  {
635  lat_prec--;
636  if(abs(lat[i])>=100 ) lat_prec--;
637  }
638 
639  lat_os.setf (ios::showpoint | ios::fixed);
640  lat_os << setprecision((int)lat_prec) << lat[i];
641 
642  Index lon_prec = 4;
643  if(lon[i] < 0) lon_prec--;
644  if(abs(lon[i])>=10 )
645  {
646  lon_prec--;
647  if(abs(lon[i])>=100 ) lon_prec--;
648  }
649  lon_os.setf (ios::showpoint | ios::fixed);
650  lon_os << setprecision((int)lon_prec) << lon[i];
651  cout<<lat_os.str()<<endl;
652  cout<<lon_os.str()<<endl;
653 
654 
655  sat_za = sat_za_from_profile[i];
656 
657  //sensor_los(Range(joker),0) =
658  // 180.0 - (asin(r_geoid(0,0) * sin(sat_za * PI/180.) /sensor_pos(0,0)))*180./PI;
659  sensor_los(Range(joker),0) =
660  180.0 - (asin(r_geoid(0,0) * sin(sat_za * PI/180.) /sensor_pos(0,0)))*180./PI;
661  cout<<"sensor_los"<<sat_za_from_profile[i]<<endl;
662  cout<<"sensor_los"<<sat_za<<endl;
663  cout<<"sensor_los"<<sensor_los<<endl;
664  //Reads the t_field_raw from file
665 
666  xml_read_from_file(met_profile_path +"profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".t.xml",
667  t_field_raw, verbosity);
668  //Reads the z_field_raw from file
669  xml_read_from_file(met_profile_path +"profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".z.xml",
670  z_field_raw, verbosity);
671 
672  //Reads the humidity from file - it is only an ArrayofTensor3
673  // The vmr_field_raw is an ArrayofArrayofTensor3 where the outer
674  // array is for species
675  xml_read_from_file(met_profile_path +"profile.lat_"+lat_os.str()+".lon_"+lon_os.str() + ".H2O.xml",
676  vmr_field_raw_h2o, verbosity);
677  //xml_read_from_file("/home/home01/rekha/uk/profiles/sat_vmr/profile.lat_"+lat_os.str()//+".lon_"+lon_os.str() + ".H2O_es.xml",
678  // vmr_field_raw_h2o, verbosity);
679 
680  cout << "--------------------------------------------------------------------------"<<endl;
681  cout << "The file" << met_profile_path +"profile.lat_"+lat_os.str()+".lon_"+lon_os.str()<< "is executed now"<<endl;
682  cout << "--------------------------------------------------------------------------"<<endl;
683  xml_write_to_file("profile_number.xml", i, FILE_TYPE_ASCII, verbosity);
684  // the first element of the species is water vapour.
685 
686  // N_p is the number of elements in the pressure grid
687  //z_surface(0,0) = oro_height[i]+ 0.01;
688  z_surface(0,0) = z_field_raw.data(0,0,0);
689  cout<<"z_surface"<<z_surface<<endl;
690  const ConstVectorView tfr_p_grid = t_field_raw.get_numeric_grid(GFIELD3_P_GRID);
691  Index N_p = tfr_p_grid.nelem();
692 
693  vmr_field_raw[0] = vmr_field_raw_h2o;
694 
695  // the second element of the species. the first 3 Tensors in the
696  //array are the same . They are pressure grid, latitude grid and
697  // longitude grid. The third tensor which is the vmr is set to a
698  // constant value of 0.782.
699  vmr_field_raw[1].resize(vmr_field_raw[0]);
700  vmr_field_raw[1].copy_grids(vmr_field_raw[0]);
701  vmr_field_raw[1].data(joker, joker, joker) = 0.782;
702 
703  // the second element of the species. the first 3 Tensors in the
704  //array are the same . They are pressure grid, latitude grid and
705  // longitude grid. The third tensor which is the vmr is set to a
706  // constant value of 0.209.
707  vmr_field_raw[2].resize(vmr_field_raw[0]);
708  vmr_field_raw[2].copy_grids(vmr_field_raw[0]);
709  vmr_field_raw[2].data(joker, joker, joker) = 0.209;
710 
711  //xml_write_to_file(met_profile_basenames[i]+ ".N2.xml", vmr_field_raw[1]);
712  //xml_write_to_file(met_profile_basenames[i]+ ".O2.xml", vmr_field_raw[2]);
713 
714  //Making a p_grid with the first and last element taken from the profile.
715  // this is because of the extrapolation problem.
716 
717  VectorNLogSpace(p_grid,
718  nelem_p_grid,
719  tfr_p_grid[0],
720  tfr_p_grid[N_p -1],
721  verbosity);
722  cout<<"t_field_raw[0](0,0,0)"<<tfr_p_grid[0]<<endl;
723  cout<<"t_field_raw[0](N_p -1,0,0)"<<tfr_p_grid[N_p -1] <<endl;
724  xml_write_to_file("p_grid.xml", p_grid, FILE_TYPE_ASCII, verbosity);
725 
726  // executing the met_profile_calc_agenda
727  met_profile_calc_agendaExecute (ws, y, t_field_raw, vmr_field_raw,
728  z_field_raw, pnd_field_raw, p_grid,
729  sensor_los, cloudbox_on,
730  cloudbox_limits, z_surface,
731  met_profile_calc_agenda );
732 
733  //putting in the spectra *y* for each profile
734  ybatch(i, Range(joker)) = y;
735 
736  }// closing the loop over profile basenames
737 }
738 
739 
740 
Matrix
The Matrix class.
Definition: matpackI.h:767
arts_omp_get_thread_num
int arts_omp_get_thread_num()
Wrapper for omp_get_thread_num.
Definition: arts_omp.cc:83
RAD2DEG
const Numeric RAD2DEG
auto_md.h
ybatch_calc_agendaExecute
void ybatch_calc_agendaExecute(Workspace &ws, Vector &y, Matrix &jacobian, const Index ybatch_index, const Agenda &input_agenda)
Definition: auto_md.cc:10669
cloudboxSetManually
void cloudboxSetManually(Index &cloudbox_on, ArrayOfIndex &cloudbox_limits, const Index &atmosphere_dim, const Vector &p_grid, const Vector &lat_grid, const Vector &lon_grid, const Numeric &p1, const Numeric &p2, const Numeric &lat1, const Numeric &lat2, const Numeric &lon1, const Numeric &lon2, const Verbosity &)
WORKSPACE METHOD: cloudboxSetManually.
Definition: m_cloudbox.cc:350
joker
const Joker joker
DEG2RAD
const Numeric DEG2RAD
PI
const Numeric PI
Vector::resize
void resize(Index n)
Resize function.
Definition: matpackI.cc:771
exit_or_rethrow
void exit_or_rethrow(const String &m, ArtsOut &out)
Exit ARTS or re-throw error.
Definition: arts.cc:98
ConstMatrixView::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackI.cc:796
GriddedField::get_numeric_grid
ConstVectorView get_numeric_grid(Index i) const
Get a numeric grid.
Definition: gridded_fields.cc:91
CREATE_OUT1
#define CREATE_OUT1
Definition: messages.h:206
Agenda
The Agenda class.
Definition: agenda_class.h:44
GriddedField3
Definition: gridded_fields.h:274
VectorExtractFromMatrix
void VectorExtractFromMatrix(Vector &v, const Matrix &m, const Index &index, const String &direction, const Verbosity &)
WORKSPACE METHOD: VectorExtractFromMatrix.
Definition: m_batch.cc:95
Array
This can be used to make arrays out of anything.
Definition: array.h:103
GriddedField3::data
Tensor3 data
Definition: gridded_fields.h:323
forloop_agendaExecute
void forloop_agendaExecute(Workspace &ws, const Index forloop_index, const Agenda &input_agenda)
Definition: auto_md.cc:9428
xml_read_from_file
void xml_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads data from XML file.
Definition: xml_io.cc:850
ConstMatrixView::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackI.cc:802
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:62
abs
#define abs(x)
Definition: continua.cc:13094
ConstVectorView::nelem
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:175
physics_funcs.h
ybatchMetProfiles
void ybatchMetProfiles(Workspace &ws, Matrix &ybatch, const ArrayOfArrayOfSpeciesTag &abs_species, const Agenda &met_profile_calc_agenda, const Vector &f_grid, const Matrix &met_amsu_data, const Matrix &sensor_pos, const Matrix &r_geoid, const Vector &lat_grid, const Vector &lon_grid, const Index &atmosphere_dim, const ArrayOfSingleScatteringData &scat_data_raw, const Index &nelem_p_grid, const String &met_profile_path, const String &met_profile_pnd_path, const Verbosity &verbosity)
WORKSPACE METHOD: ybatchMetProfiles.
Definition: m_batch.cc:347
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:50
math_funcs.h
Matrix::resize
void resize(Index r, Index c)
Resize function.
Definition: matpackI.cc:1549
ybatchMetProfilesClear
void ybatchMetProfilesClear(Workspace &ws, Matrix &ybatch, const ArrayOfArrayOfSpeciesTag &abs_species, const Agenda &met_profile_calc_agenda, const Vector &f_grid, const Matrix &met_amsu_data, const Matrix &sensor_pos, const Matrix &r_geoid, const Index &nelem_p_grid, const String &met_profile_path, const Verbosity &verbosity)
WORKSPACE METHOD: ybatchMetProfilesClear.
Definition: m_batch.cc:576
Range
The range class.
Definition: matpackI.h:148
ForLoop
void ForLoop(Workspace &ws, const Agenda &forloop_agenda, const Index &start, const Index &stop, const Index &step, const Verbosity &verbosity)
WORKSPACE METHOD: ForLoop.
Definition: m_batch.cc:69
rte.h
Declaration of functions in rte.cc.
ybatchCalc
void ybatchCalc(Workspace &ws, Matrix &ybatch, ArrayOfMatrix &ybatch_jacobians, const Index &ybatch_start, const Index &ybatch_n, const Agenda &ybatch_calc_agenda, const Index &robust, const Verbosity &verbosity)
WORKSPACE METHOD: ybatchCalc.
Definition: m_batch.cc:145
Workspace
Workspace class.
Definition: workspace_ng.h:47
VectorNLogSpace
void VectorNLogSpace(Vector &x, const Index &n, const Numeric &start, const Numeric &stop, const Verbosity &verbosity)
WORKSPACE METHOD: VectorNLogSpace.
Definition: m_basic_types.cc:949
FILE_TYPE_ASCII
@ FILE_TYPE_ASCII
Definition: xml_io.h:39
xml_write_to_file
void xml_write_to_file(const String &filename, const T &type, const FileType ftype, const Verbosity &verbosity)
Write data to XML file.
Definition: xml_io.cc:1017
GFIELD3_P_GRID
const Index GFIELD3_P_GRID
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
arts_exit
void arts_exit(int status)
This is the exit function of ARTS.
Definition: arts.cc:42
Vector
The Vector class.
Definition: matpackI.h:555
arts_omp.h
Header file for helper functions for OpenMP.
ConstVectorView
A constant view of a Vector.
Definition: matpackI.h:300
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:172
CREATE_OUTS
#define CREATE_OUTS
Definition: messages.h:210
arts.h
The global header file for ARTS.
xml_io.h
This file contains basic functions to handle XML data files.
met_profile_calc_agendaExecute
void met_profile_calc_agendaExecute(Workspace &ws, Vector &y, const GriddedField3 &t_field_raw, const ArrayOfGriddedField3 &vmr_field_raw, const GriddedField3 &z_field_raw, const ArrayOfGriddedField3 &pnd_field_raw, const Vector &p_grid, const Matrix &sensor_los, const Index cloudbox_on, const ArrayOfIndex &cloudbox_limits, const Matrix &z_surface, const Agenda &input_agenda)
Definition: auto_md.cc:9988