ARTS  1.0.222
m_batch.cc
Go to the documentation of this file.
1 /* Copyright (C) 2000, 2001 Patrick Eriksson <patrick@rss.chalmers.se>
2  Stefan Buehler <sbuehler@uni-bremen.de>
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 
20 
22 // File description
24 
33 #if HAVE_CONFIG_H
34 #include "config.h"
35 #endif
36 
38 // External declarations
40 
41 #include "arts.h"
42 #include "atm_funcs.h"
43 #include "absorption.h"
44 #include "math_funcs.h"
45 #include "messages.h"
46 #include "file.h"
47 #include "auto_md.h"
48 
49 
50 #ifdef HDF_SUPPORT
51 
52 
54 // Help functions
56 
58 
68 void filename_batch(
69  String& filename,
70  const String& batchname,
71  const String& varname )
72 {
73  if ( "" == filename )
74  filename = batchname+"."+varname+".ab";
75 }
76 
77 
78 
80 
93 void read_batchdata(
94  Matrix& x,
95  const String& batchname,
96  const String& filename,
97  const String& varname,
98  const Index& length,
99  const Index& n )
100 {
101  String fname = filename;
102  filename_batch( fname, batchname, varname );
103  MatrixReadBinary( x, "", fname );
104  if ( x.nrows() != length )
105  {
106  ostringstream os;
107  os << "The file " << fname << " contains data of length " << x.nrows()
108  << ", but a length of " << length << " is expected.\n";
109  throw runtime_error(os.str());
110  }
111  if ( x.ncols() < n )
112  {
113  ostringstream os;
114  os << "The file " << fname << " contains data for only " << x.ncols()
115  << " spectra when " << n << " spectra shall be calculated.\n";
116  throw runtime_error(os.str());
117  }
118  // Remove a possible excess of data
119  if ( x.ncols() > n )
120  {
121  Matrix dummy(x(Range(joker),Range(0,n))); // Matpack can initialize a
122  // new Matrix from another
123  // Matrix. Used here in
124  // connection with
125  // Ranges to select a
126  // submatrix of the
127  // original Matrix.
128  // Copy dummy back to x:
129  x.resize( x.nrows(), n );
130  x = dummy; // Matpack can copy the contents of
131  // matrices like this. The dimensions
132  // must be the same!
133  }
134 }
135 
136 #endif // HDF_SUPPORT
137 
138 
140 // Workspace methods
142 
149 #ifdef HDF_SUPPORT
150 void ybatchCalc(
151  // WS Output:
152  Matrix& ybatch,
153  // WS Input:
154  const Vector& f_mono,
155  const Vector& p_abs,
156  const Vector& t_abs,
157  const Vector& n2_abs,
158  const Vector& h2o_abs,
159  const Matrix& vmrs,
160  const ArrayOfArrayOfLineRecord& lines_per_tag,
161  const ArrayOfLineshapeSpec& lineshape,
162  const Vector& z_abs,
163  const Numeric& z_plat,
164  const Vector& za_pencil,
165  const Numeric& l_step,
166  const Index& refr,
167  const Index& refr_lfac,
168  const Vector& refr_index,
169  const Numeric& z_ground,
170  const Numeric& r_geoid,
171  const Index& emission,
172  const Vector& y_space,
173  const Vector& e_ground,
174  const Numeric& t_ground,
175  const String& batchname,
176  const TagGroups& tgs,
177  const ArrayOfString& cont_description_names,
178  const ArrayOfVector& cont_description_parameters,
179  const ArrayOfString& cont_description_models,
180  // Control Parameters:
181  const Index& ncalc,
182  const Index& do_t,
183  const String& t_file,
184  const Index& do_z,
185  const String& z_file,
186  const ArrayOfString& do_tags,
187  const ArrayOfString& tag_files,
188  const Index& do_f,
189  const String& f_file,
190  const Index& do_za,
191  const String& za_file )
192 {
193  const Index np = p_abs.nelem(); // Number of pressure levels
194  // const Index ntgs = tgs.nelem(); // Number of absorption tags
195  const Index ndo = do_tags.nelem(); // Number of tags to do here
196  ArrayOfIndex tagindex; // Index in tgs for do_tags
197 
198  if ( ndo != tag_files.nelem() )
199  {
200  ostringstream os;
201  os << "There is " << ndo << " tga groups and only " << tag_files.nelem()
202  << " tag_files, even if they are empty they should match.\n";
203  throw runtime_error(os.str());
204  }
205 
206  // Check if do_tags can be found in tgs and store indeces
207  if ( ndo > 0 )
208  get_tagindex_for_Strings( tagindex, tgs, do_tags );
209 
210  out2 << " Reading data from files.\n";
211 
212  // Read data from file(s) or use the workspace varaible
213 
214  // Temperature
215  Vector t(t_abs); // Matpack can initialize a
216  // new Vector from another
217  // Vector
218  Matrix Ts;
219  if ( do_t )
220  read_batchdata( Ts, batchname, t_file, "t_abs", np, ncalc );
221 
222  // Altitudes
223  Vector z(z_abs); // Matpack can initialize a
224  // new Vector from another
225  // Vector
226 
227  Matrix Zs;
228  if ( do_z )
229  read_batchdata( Zs, batchname, z_file, "z_abs", np, ncalc );
230 
231  // Frequencies
232  Vector f(f_mono); // Matpack can initialize a
233  // new Vector from another
234  // Vector
235 
236  Matrix f_oss;
237  if ( do_f )
238  read_batchdata( f_oss, batchname, f_file, "f_mono", 1, ncalc );
239 
240  // Zenith angles
241  Vector za(za_pencil); // Matpack can initialize a
242  // new Vector from another
243  // Vector
244 
245  Matrix za_oss;
246  if ( do_za )
247  read_batchdata( za_oss, batchname, za_file, "za_pencil", 1, ncalc );
248 
249  // Species profiles
250  Matrix vs(vmrs); // Matpack can initalize a matrix from
251  // another matrix.
252 
253  Index itag;
254  ArrayOfMatrix VMRs(ndo);
255  extern const Array<SpeciesRecord> species_data; // The species lookup data:
256  for ( itag=0; itag<ndo; itag++ )
257  {
258  // Determine the name of the molecule for itag
259  String molname = species_data[tgs[tagindex[itag]][0].Species()].Name();
260  read_batchdata( VMRs[itag], batchname, tag_files[itag], molname, np, ncalc );
261  }
262 
263 
264 
265  //--- Loop and calculate the spectra --------------------------------------
266  Matrix abs;
267  ArrayOfMatrix abs_per_tag;
268  Los los;
269  ArrayOfMatrix trans, source;
270  Vector y, z_tan;
271 
272  out2 << " Calculating spectra.\n";
273 
274  for ( Index i=0; i<Index(ncalc); i++ )
275  {
276  out2 << " -------- Batch spectrum " << i << " --------\n";
277  // Copy from file data for the "do" quantities
278  if ( do_t )
279  {
280  assert( t.nelem()==Ts.nrows() );
281  t = Ts(Range(joker),i); // Copy ith column of Matrix Ts to
282  // Vector t.
283  }
284  if ( do_z )
285  {
286  assert( z.nelem()==Zs.nrows() );
287  z = Zs(Range(joker),i); // copy ith column of Matrix Zs to
288  // Vector z.
289  }
290  if ( do_f )
291  {
292  f = f_mono; // Copy contents of f_mono to f.
293  f += f_oss(0,i); // Add f_oss(0,i) to all elements.
294  }
295  if ( do_za )
296  {
297  za = za_pencil; // Copy contents of za_pencil to za.
298  za += za_oss(0,i); // Add za_oss(0,i) to all elements.
299  }
300  for ( itag=0; itag<ndo; itag++ )
301  {
302  assert( vs.ncols()==VMRs[itag].nrows() );
303  vs(tagindex[itag],Range(joker)) = VMRs[itag](Range(joker),i);
304  // Set the row of vs for itag from ith column of VMRs[itag].
305  }
306 
307 
308  // Do the calculations
309  //
310  if ( (i==0) || do_t || ndo || do_f )
311  absCalc( abs, abs_per_tag, tgs, f, p_abs, t, n2_abs, h2o_abs, vs,
312  lines_per_tag, lineshape,
313  cont_description_names,
314  cont_description_models,
315  cont_description_parameters);
316 
317  if ( (i==0) || do_z || do_za )
318  losCalc( los, z_tan, z_plat, za, l_step, p_abs, z, refr, refr_lfac,
319  refr_index, z_ground, r_geoid );
320  if ( (i==0) || do_t || do_z || do_f || do_za )
321  sourceCalc( source, emission, los, p_abs, t, f );
322  transCalc( trans, los, p_abs, abs );
323  yCalc ( y, emission, los, f, y_space, source, trans, e_ground, t_ground );
324 
325  // Move to ybatch
326  if ( i == 0 )
327  ybatch.resize( y.nelem(), ncalc );
328 
329  ybatch(Range(joker),i) = y; // Copy to ith column of ybatch.
330  }
331  out2 << " ------------------------------------\n";
332 }
333 #else
335  // WS Output:
336  Matrix& /* ybatch */,
337  // WS Input:
338  const Vector& /* f_mono */,
339  const Vector& /* p_abs */,
340  const Vector& /* t_abs */,
341  const Vector& /* n2_abs */,
342  const Vector& /* h2o_abs */,
343  const Matrix& /* vmrs */,
344  const ArrayOfArrayOfLineRecord& /* lines_per_tag */,
345  const ArrayOfLineshapeSpec& /* lineshape */,
346  const Vector& /* z_abs */,
347  const Numeric& /* z_plat */,
348  const Vector& /* za_pencil */,
349  const Numeric& /* l_step */,
350  const Index& /* refr */,
351  const Index& /* refr_lfac */,
352  const Vector& /* refr_index */,
353  const Numeric& /* z_ground */,
354  const Numeric& /* r_geoid */,
355  const Index& /* emission */,
356  const Vector& /* y_space */,
357  const Vector& /* e_ground */,
358  const Numeric& /* t_ground */,
359  const String& /* batchname */,
360  const TagGroups& /* tgs */,
361  const ArrayOfString& /* cont_description_names */,
362  const ArrayOfVector& /* cont_description_parameters */,
363  const ArrayOfString& /* cont_description_models */,
364  // Control Parameters:
365  const Index& /* ncalc */,
366  const Index& /* do_t */,
367  const String& /* t_file */,
368  const Index& /* do_z */,
369  const String& /* z_file */,
370  const ArrayOfString& /* do_tags */,
371  const ArrayOfString& /* tag_files */,
372  const Index& /* do_f */,
373  const String& /* f_file */,
374  const Index& /* do_za */,
375  const String& /* za_file */ )
376 {
377  throw runtime_error("This method is only available when arts is compiled with HDF support.");
378 }
379 #endif // HDF_SUPPORT
380 
381 void ybatchFromRadiosonde(// WS Output:
382  Matrix& ybatch,
383  ArrayOfMatrix& absbatch,
384  ArrayOfMatrix& jacbatch,
385  // WS Input:
386  const ArrayOfMatrix& radiosonde_data,
387  const Vector& f_mono,
388  const ArrayOfArrayOfLineRecord& lines_per_tg,
389  const ArrayOfLineshapeSpec& lineshape,
390  const Numeric& z_plat,
391  const Vector& za_pencil,
392  const Numeric& l_step,
393  const Index& refr,
394  const String& refr_model,
395  const Index& refr_lfac,
396  const Numeric& r_geoid,
397  const Index& emission,
398  const Vector& y_space,
399  const Vector& e_ground,
400  const TagGroups& tgs,
401  const ArrayOfString& cont_description_names,
402  const ArrayOfString& cont_description_models,
403  const ArrayOfVector& cont_description_parameters,
404  //Keyword
405  const Index& fine_abs_grid,
406  const Index& interpolation_in_rh,
407  const Index& za_batch,
408  const Index& e_ground_batch,
409  const Index& calc_abs,
410  const Index& calc_jac)
411 {
412  // Check value of the keyword
413  check_if_bool(fine_abs_grid, "Finegrid keyword" );
414  check_if_bool(interpolation_in_rh, "Interpolation in RH keyword" );
415  check_if_bool(za_batch, "za_batch keyword" );
416  check_if_bool(e_ground_batch, "e_ground_batch keyword" );
417  check_if_bool(calc_abs, "calc_abs keyword" );
418  check_if_bool(calc_jac, "calc_jac keyword" );
419 
420  // this variable is keep the original za_pencil
421  Vector za_pencil_profile;
422  Vector e_ground_profile;
423 
424  if (calc_abs)
425  {
426  absbatch.resize( radiosonde_data.nelem() );
427  }
428  else
429  {
430  absbatch.resize( 1 );
431  absbatch[0].resize( 1, 1 );
432  absbatch[0] = -1.0;
433  }
434 
435  if (calc_jac)
436  {
437  jacbatch.resize( radiosonde_data.nelem() );
438  }
439  else
440  {
441  jacbatch.resize( 1 );
442  jacbatch[0].resize( 1, 1 );
443  jacbatch[0] = -1.0;
444  }
445 
446  if (!za_batch)
447  {
448  // Initialize ybatch:
449  ybatch.resize( f_mono.nelem()*za_pencil.nelem(), radiosonde_data.nelem() );
450  ybatch = 0;
451  za_pencil_profile.resize( za_pencil.nelem() );
452  za_pencil_profile = za_pencil;
453  }
454  //The za_pencil vector now contains one za_pencil for each profile
455  else
456  {
457  //Check whether the number of matrices and the number of za_pencil
458  //are the same
459  if ( radiosonde_data.nelem() != za_pencil.nelem() )
460  {
461  ostringstream os;
462  os << "The number of Radiosonde profiles is " << radiosonde_data.nelem() << "\n"
463  << "The number of zenith angles given is " << za_pencil.nelem() << "\n"
464  << "But these two are expected to be the same.\n";
465  throw runtime_error(os.str());
466  }
467  // Initialize ybatch: since there can be only one angle for each profile
468  // the size of ybatch does not depend on the angles.
469  ybatch.resize( f_mono.nelem(), radiosonde_data.nelem() );
470  ybatch = 0;
471  za_pencil_profile.resize(1);
472 
473  }
474 
475  if (e_ground_batch)
476  {
477  if ( radiosonde_data.nelem() != e_ground.nelem() )
478  {
479  ostringstream os;
480  os << "The number of Radiosonde profiles is " << radiosonde_data.nelem() << "\n"
481  << "The number of emissivities given is " << e_ground.nelem() << "\n"
482  << "But these two are expected to be the same, when e_ground_per_profile = 1 .\n";
483  throw runtime_error(os.str());
484  }
485  }
486  else
487  {
488  e_ground_profile.resize( f_mono.nelem() );
489  e_ground_profile = e_ground;
490  }
491 
492  // Loop over all radiosonde profiles:
493  for ( Index i=0; i<radiosonde_data.nelem(); ++i )
494  {
495  const Matrix& rd = radiosonde_data[i];
496 
497  // When za_batch is set, it should be extracted from
498  // the za_pencil for each profile
499  if (za_batch)
500  {
501  za_pencil_profile[0] = za_pencil[i];
502  }
503 
504  // When e_ground_batch is set, it should be extracted from
505  // the e_gound for each profile
506  if (e_ground_batch)
507  {
508  e_ground_profile.resize( f_mono.nelem() );
509  e_ground_profile = e_ground[i];
510  }
511 
512  // Check whether the launch has reached upto 100 hpa
513  Numeric min_p = rd(rd.nrows() - 1, 0);
514 
515  // The launch reached up to or above 100 hPa
516  if (min_p <= 10000.0)
517  {
518  Numeric t_ground, z_ground;
519  Vector p_abs, t_abs, z_abs, h2o_abs, n2_abs;
520  Matrix vmrs;
521 
522  // The absorption is calculated on a grid which is
523  // the same as the radiosonde levels
524  if (!fine_abs_grid)
525  {
526  // Create p_abs, t_abs, z_abs:
527  p_abs.resize(rd.nrows());
528  t_abs.resize(rd.nrows());
529  z_abs.resize(rd.nrows());
530 
531  p_abs = rd(Range(joker),0);
532  t_abs = rd(Range(joker),1);
533  z_abs = rd(Range(joker),2);
534 
535  // FIXME: ARTS-RTTOV paper
536  if (calc_abs)
537  {
538  absbatch[i].resize( f_mono.nelem(), p_abs.nelem() );
539  absbatch[i] = 0;
540  }
541 
542  // Create vmrs:
543  vmrs.resize(3, rd.nrows());
544  vmrs(0,Range(joker)) = rd(Range(joker),3); // H2O
545  vmrs(1,Range(joker)) = 0.209; // O2
546  vmrs(2,Range(joker)) = 0.782; // N2
547 
548 
549  // Set the physical H2O profile from the H2O profile in vmrs:
550  h2o_abs.resize(rd.nrows());
551  h2o_abs = vmrs(0,Range(joker));
552 
553  // Set the physical N2 profile from the N2 profile in vmrs:
554  n2_abs.resize(rd.nrows());
555  Vector n2_abs = vmrs(2,Range(joker));
556 
557  // Set t_ground from lowest level of t_abs:
558  t_ground = t_abs[0];
559 
560  // Set z_ground from lowest level of z_abs:
561  z_ground = z_abs[0];
562 
563  }
564 
565  // The absorption is calculated on a very fine grid
566  else
567  {
568  // Number of levels in the launch
569  Index n_rows = rd.nrows();
570 
571  // Create p_abs, t_abs, z_abs:
572  Vector p_raw(n_rows + 1);
573  Vector t_raw(n_rows + 1);
574  Vector z_raw(n_rows + 1);
575 
576  // Adding one more level at the bottom
577  // Pressure is set as 1040 hpa
578  // Temperature is the lowermost value from the sonde
579  // Height is -99.0 m (a dummy value below ground)
580  p_raw[0] = 104000.0;
581  t_raw[0] = rd(0,1);
582  z_raw[0] = -99.0;
583 
584  p_raw[Range(1, n_rows)] = rd(Range(joker),0);
585  t_raw[Range(1, n_rows)] = rd(Range(joker),1);
586  z_raw[Range(1, n_rows)] = rd(Range(joker),2);
587 
588  // Creating p_abs
589  VectorNLogSpace (p_abs,"p_abs", p_raw[0], 10000.0, 1001);
590 
591  t_abs.resize(p_abs.nelem());
592  z_abs.resize(p_abs.nelem());
593 
594  // Interpolating the profiles on p_abs
595  interpp (t_abs, p_raw, t_raw, p_abs);
596  interpp (z_abs, p_raw, z_raw, p_abs);
597 
598  // Create vmrs:
599  Vector vmr_raw(n_rows + 1);
600 
601  vmr_raw[0] = rd(0,3);
602  vmr_raw[Range(1, n_rows)] = rd(Range(joker),3); // H2O
603 
604  vmrs.resize(3, p_abs.nelem());
605 
606  // Checking whether the interpolation should be done
607  // in vmr or RH
608  if (interpolation_in_rh)
609  {
610  // Calculates RH and interpolating RH on p_abs grid and
611  // converting back to H2O VMR. This is done because the
612  // interpolation in RH gives more realistic Tbs than
613  // interpolation VMR
614  Vector sat_pres_raw(n_rows + 1);
615  Vector sat_pres_abs(p_abs.nelem());
616  Vector rh_raw(n_rows + 1);
617  Vector rh_abs(p_abs.nelem());
618 
619  assert( sat_pres_raw.nelem() == t_raw.nelem() );
620  assert( sat_pres_abs.nelem() == t_abs.nelem() );
621 
622  e_eq_water(sat_pres_raw, t_raw);
623  e_eq_water(sat_pres_abs, t_abs);
624 
625  // Calculates RH for the raw profile
626  for ( Index j=0; j<rh_raw.nelem(); ++j )
627  {
628  rh_raw[j] = vmr_raw[j] / sat_pres_raw[j];
629  }
630 
631  // Interpolates raw RH on p_abs grid
632  interpp (rh_abs, p_raw, rh_raw, p_abs);
633 
634  // Converts RH back to VMR
635  for ( Index j=0; j<rh_abs.nelem(); ++j )
636  {
637  vmrs(0, j) = rh_abs[j] * sat_pres_abs[j];
638  }
639  }
640  else
641  {
642  // Interpolating H2O VMR on p_abs grid
643  interpp (vmrs(0, Range(joker)), p_raw, vmr_raw, p_abs);
644  }
645 
646  vmrs(1,Range(joker)) = 0.209; // O2
647  vmrs(2,Range(joker)) = 0.782; // N2
648 
649  // Set the physical H2O profile from the H2O profile in vmrs:
650  h2o_abs.resize(p_abs.nelem());
651  h2o_abs = vmrs(0,Range(joker));
652 
653  // Set the physical N2 profile from the N2 profile in vmrs:
654  n2_abs.resize(p_abs.nelem());
655  n2_abs = vmrs(2,Range(joker));
656 
657  // Set t_ground from lowest level of launch:
658  t_ground = rd(0,1);
659 
660  // Set z_ground from lowest level of launch:
661  z_ground = rd(0,2);
662  }
663 
664  // Calculate absorption:
665  Matrix abs;
666  ArrayOfMatrix abs_per_tg;
667  // ... call the workspace method absCalc:
668  absCalc(// Output:
669  abs,
670  abs_per_tg,
671  // Input:
672  tgs,
673  f_mono,
674  p_abs,
675  t_abs,
676  n2_abs,
677  h2o_abs,
678  vmrs,
679  lines_per_tg,
680  lineshape,
681  cont_description_names,
682  cont_description_models,
683  cont_description_parameters);
684 
685  // FIXME : ARTS-RTTOV paper
686  if (calc_abs)
687  {
688  absbatch[i] = abs;
689  }
690 
691  // Calculate refractive index:
692  Vector refr_index;
693  refrCalc(// Output:
694  refr_index,
695  // Input:
696  p_abs,
697  t_abs,
698  h2o_abs,
699  refr,
700  refr_model);
701 
702  // Calculate the line of sight:
703  Los los;
704  Vector z_tan;
705  losCalc(// Output:
706  los,
707  z_tan,
708  // Input:
709  z_plat,
710  za_pencil_profile,
711  l_step,
712  p_abs,
713  z_abs,
714  refr,
715  refr_lfac,
716  refr_index,
717  z_ground,
718  r_geoid);
719 
720  // Calculate source:
721  ArrayOfMatrix source;
722  sourceCalc(// Output:
723  source,
724  // Input:
725  emission,
726  los,
727  p_abs,
728  t_abs,
729  f_mono);
730 
731  // Calculate transmittances:
732  ArrayOfMatrix trans;
733  transCalc(// Output:
734  trans,
735  //Input:
736  los,
737  p_abs,
738  abs);
739 
740  // Calculate Spectrum:
741  Vector y;
742  yCalc(// Output:
743  y,
744  // Input:
745  emission,
746  los,
747  f_mono,
748  y_space,
749  source,
750  trans,
751  e_ground_profile,
752  t_ground);
753 
754  // Calculation of Jacobian
755  if (calc_jac)
756  {
757  ArrayOfMatrix absloswfs;
758  absloswfsCalc(// Output:
759  absloswfs,
760  // Input:
761  emission,
762  los,
763  source,
764  trans,
765  y,
766  y_space,
767  f_mono,
768  e_ground_profile,
769  t_ground);
770 
771  Vector k_grid = p_abs;
772 
773  TagGroups wfs_tgs( 1 );
774  wfs_tgs = tgs[0];
775 
776  abs_per_tgReduce(// Output:
777  abs_per_tg,
778  // Input:
779  tgs,
780  wfs_tgs);
781 
782  Matrix k;
783  ArrayOfString k_names;
784  Matrix k_aux;
785  kSpecies(// Output:
786  k,
787  k_names,
788  k_aux,
789  // Input:
790  los,
791  absloswfs,
792  p_abs,
793  t_abs,
794  wfs_tgs,
795  abs_per_tg,
796  vmrs,
797  k_grid,
798  // Keywords:
799  "frac");
800 
801  // Convert to RJ brightness temperatures
802  for ( Index ik=0; ik<k.ncols(); ik++ )
803  {
804  invrayjean( k(Range(joker),ik), f_mono, za_pencil_profile );
805  }
806 
807  jacbatch[i] = k;
808  }
809 
810  // Convert Radiance to Planck Tb
811  yTB(y, f_mono, za_pencil_profile);
812 
813  // Assign y to this column of ybatch:
814  ybatch(Range(joker),i) = y;
815 
816 
817  }
818  // The launch did not reach upto or above 100 hPa
819  else
820  {
821  // Assign -1 to this column of ybatch:
822  ybatch(Range(joker),i) = -1.0;
823  }
824  }
825 }
826 
827 void ybatchFromRadiosondeGlobal(// WS Output:
828  Matrix& ybatch,
829  // WS Input:
830  const ArrayOfMatrix& radiosonde_data,
831  const Vector& f_mono,
832  const ArrayOfArrayOfLineRecord& lines_per_tg,
833  const ArrayOfLineshapeSpec& lineshape,
834  const Numeric& z_plat,
835  const Vector& za_pencil,
836  const Numeric& l_step,
837  const Index& refr,
838  const String& refr_model,
839  const Index& refr_lfac,
840  const Numeric& r_geoid,
841  const Index& emission,
842  const Vector& y_space,
843  const Vector& e_ground,
844  const TagGroups& tgs,
845  const ArrayOfString& cont_description_names,
846  const ArrayOfString& cont_description_models,
847  const ArrayOfVector& cont_description_parameters)
848 {
849 
850  // Initialize ybatch:
851  ybatch.resize( f_mono.nelem()*za_pencil.nelem(), radiosonde_data.nelem() );
852  ybatch = 0;
853 
854  // Loop over all radiosonde profiles:
855  for ( Index i=0; i<radiosonde_data.nelem(); ++i )
856  {
857  const Matrix& rd = radiosonde_data[i];
858 
859  ConstVectorView p_raw = rd(Range(joker),0);
860  ConstVectorView t_raw = rd(Range(joker),1);
861  ConstVectorView z_raw = rd(Range(joker),2);
862 
863  Vector p_abs;
864 
865  VectorNLogSpace (p_abs,"p_abs",p_raw[0],p_raw[p_raw.nelem()-1],100);
866  Vector t_abs( p_abs.nelem() );
867  Vector z_abs( p_abs.nelem() );
868 
869  interpp ( t_abs, p_raw, t_raw, p_abs );
870  interpp ( z_abs, p_raw, z_raw, p_abs );
871 
872  // Create vmrs:
873  ConstVectorView h2o_raw = rd( Range(joker), 3 );
874 
875  Matrix vmrs( tgs.nelem(), p_abs.nelem() );
876  interpp ( vmrs(0, Range( joker ) ), p_raw,h2o_raw, p_abs );
877  vmrs( 1, Range( joker ) ) = 0.209; // O2
878  vmrs( 2, Range( joker ) ) = 0.782; // N2
879 
880  // Set the physical H2O profile from the H2O profile in vmrs:
881  Vector h2o_abs = vmrs( 0, Range( joker ) );
882 
883  // Set the physical N2 profile from the N2 profile in vmrs:
884  Vector n2_abs = vmrs( 2, Range( joker ) );
885 
886  // Calculate absorption:
887  Matrix abs;
888  ArrayOfMatrix abs_per_tg;
889  // ... call the workspace method absCalc:
890  absCalc(// Output:
891  abs,
892  abs_per_tg,
893  // Input:
894  tgs,
895  f_mono,
896  p_abs,
897  t_abs,
898  n2_abs,
899  h2o_abs,
900  vmrs,
901  lines_per_tg,
902  lineshape,
903  cont_description_names,
904  cont_description_models,
905  cont_description_parameters);
906 
907  // Set t_ground from lowest level of t_abs:
908  Numeric t_ground = t_raw[0];
909 
910  // Set z_ground from lowest level of z_abs:
911  Numeric z_ground = z_raw[0];
912 
913  // Calculate refractive index:
914  Vector refr_index;
915  refrCalc(// Output:
916  refr_index,
917  // Input:
918  p_abs,
919  t_abs,
920  h2o_abs,
921  refr,
922  refr_model);
923 
924 
925  // Calculate the line of sight:
926  Los los;
927  Vector z_tan;
928  losCalc(// Output:
929  los,
930  z_tan,
931  // Input:
932  z_plat,
933  za_pencil,
934  l_step,
935  p_abs,
936  z_abs,
937  refr,
938  refr_lfac,
939  refr_index,
940  z_ground,
941  r_geoid);
942 
943  // Calculate source:
944  ArrayOfMatrix source;
945  sourceCalc(// Output:
946  source,
947  // Input:
948  emission,
949  los,
950  p_abs,
951  t_abs,
952  f_mono);
953 
954  // Calculate transmittances:
955  ArrayOfMatrix trans;
956  transCalc(// Output:
957  trans,
958  //Input:
959  los,
960  p_abs,
961  abs);
962 
963  // Calculate Spectrum:
964  Vector y;
965  yCalc(// Output:
966  y,
967  // Input:
968  emission,
969  los,
970  f_mono,
971  y_space,
972  source,
973  trans,
974  e_ground,
975  t_ground);
976 
977  // Assign y to this column of ybatch:
978  ybatch(Range(joker),i) = y;
979  }
980 }
981 
Matrix
The Matrix class.
Definition: matpackI.h:544
ybatchFromRadiosonde
void ybatchFromRadiosonde(Matrix &ybatch, ArrayOfMatrix &absbatch, ArrayOfMatrix &jacbatch, const ArrayOfMatrix &radiosonde_data, const Vector &f_mono, const ArrayOfArrayOfLineRecord &lines_per_tg, const ArrayOfLineshapeSpec &lineshape, const Numeric &z_plat, const Vector &za_pencil, const Numeric &l_step, const Index &refr, const String &refr_model, const Index &refr_lfac, const Numeric &r_geoid, const Index &emission, const Vector &y_space, const Vector &e_ground, const TagGroups &tgs, const ArrayOfString &cont_description_names, const ArrayOfString &cont_description_models, const ArrayOfVector &cont_description_parameters, const Index &fine_abs_grid, const Index &interpolation_in_rh, const Index &za_batch, const Index &e_ground_batch, const Index &calc_abs, const Index &calc_jac)
Definition: m_batch.cc:381
out2
Out2 out2
Level 2 output stream.
Definition: messages.cc:54
yCalc
void yCalc(Vector &, const Index &, const Los &, const Vector &, const Vector &, const ArrayOfMatrix &, const ArrayOfMatrix &, const Vector &, const Numeric &)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_los.cc:1483
auto_md.h
absorption.h
Declarations required for the calculation of absorption coefficients.
refrCalc
void refrCalc(Vector &, const Vector &, const Vector &, const Vector &, const Index &, const String &)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_abs.cc:2763
absloswfsCalc
void absloswfsCalc(ArrayOfMatrix &, const Index &, const Los &, const ArrayOfMatrix &, const ArrayOfMatrix &, const Vector &, const Vector &, const Vector &, const Vector &, const Numeric &)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_wfs.cc:2726
atm_funcs.h
This file contains declerations of functions releated to atmospheric physics or geometry.
Vector::resize
void resize(Index n)
Resize function.
Definition: matpackI.h:1467
transCalc
void transCalc(ArrayOfMatrix &, const Los &, const Vector &, const Matrix &)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_los.cc:1390
ConstMatrixView::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackI.h:1491
joker
Joker joker
Define the global joker objekt.
Definition: constants.cc:233
sourceCalc
void sourceCalc(ArrayOfMatrix &, const Index &, const Los &, const Vector &, const Vector &, const Vector &)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_los.cc:1321
Array< Array< LineRecord > >
yTB
void yTB(Vector &, const Vector &, const Vector &)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_los.cc:1624
check_if_bool
void check_if_bool(const Index &x, const String &x_name)
Checks if an integer is 0 or 1.
Definition: math_funcs.cc:468
abs_per_tgReduce
void abs_per_tgReduce(ArrayOfMatrix &, const TagGroups &, const TagGroups &)
Reduces the size of abs_per_tg.
Definition: m_abs.cc:2669
species_data
Array< SpeciesRecord > species_data
Definition: species_data.cc:36
messages.h
Declarations having to do with the four output streams.
invrayjean
void invrayjean(VectorView y, ConstVectorView f, ConstVectorView za)
Converts a vector with radiances to Rayleigh-Jean brightness temperatures.
Definition: atm_funcs.cc:202
ConstMatrixView::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackI.h:1497
my_basic_string< char >
absCalc
void absCalc(Matrix &, ArrayOfMatrix &, const TagGroups &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Matrix &, const ArrayOfArrayOfLineRecord &, const ArrayOfLineshapeSpec &, const ArrayOfString &, const ArrayOfString &, const ArrayOfVector &)
Calculates the absorption coefficients by first calculating the cross sections per tag group and then...
Definition: m_abs.cc:1956
abs
#define abs(x)
Definition: continua.cc:12946
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: arts.h:147
ConstVectorView::nelem
Index nelem() const
Returns the number of elements.
Definition: matpackI.h:937
e_eq_water
void e_eq_water(VectorView e_eq, ConstVectorView t)
Calculates the equilibrium water vapor pressure over liquid water.
Definition: atm_funcs.cc:998
VectorNLogSpace
void VectorNLogSpace(Vector &, const String &, const Numeric &start, const Numeric &stop, const Index &n)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_io.cc:904
math_funcs.h
Contains declerations of basic mathematical and vector/matrix functions.
Matrix::resize
void resize(Index r, Index c)
Resize function.
Definition: matpackI.h:2237
losCalc
void losCalc(Los &, Vector &, const Numeric &, const Vector &, const Numeric &, const Vector &, const Vector &, const Index &, const Index &, const Vector &, const Numeric &, const Numeric &)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_los.cc:1058
Range
The range class.
Definition: matpackI.h:139
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: arts.h:153
interpp
void interpp(VectorView x, ConstVectorView p0, ConstVectorView x0, ConstVectorView p)
Interpolates a vertical profile at a new set of pressures.
Definition: atm_funcs.cc:658
get_tagindex_for_Strings
void get_tagindex_for_Strings(ArrayOfIndex &tags1_index, const TagGroups &tags1, const ArrayOfString &tags2_Strings)
Returns the index among some tag groups for an array of tag Strings.
Definition: absorption.cc:2176
file.h
This file contains basic functions to handle ASCII and binary (HDF) data files.
ybatchFromRadiosondeGlobal
void ybatchFromRadiosondeGlobal(Matrix &ybatch, const ArrayOfMatrix &radiosonde_data, const Vector &f_mono, const ArrayOfArrayOfLineRecord &lines_per_tg, const ArrayOfLineshapeSpec &lineshape, const Numeric &z_plat, const Vector &za_pencil, const Numeric &l_step, const Index &refr, const String &refr_model, const Index &refr_lfac, const Numeric &r_geoid, const Index &emission, const Vector &y_space, const Vector &e_ground, const TagGroups &tgs, const ArrayOfString &cont_description_names, const ArrayOfString &cont_description_models, const ArrayOfVector &cont_description_parameters)
Definition: m_batch.cc:827
MatrixReadBinary
void MatrixReadBinary(Matrix &, const String &, const String &filename)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_hdf.cc:1616
Vector
The Vector class.
Definition: matpackI.h:389
Los
The line of sight (LOS).
Definition: los.h:103
ConstVectorView
A constant view of a Vector.
Definition: matpackI.h:232
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:115
kSpecies
void kSpecies(Matrix &, ArrayOfString &, Matrix &, const Los &, const ArrayOfMatrix &, const Vector &, const Vector &, const TagGroups &, const ArrayOfMatrix &, const Matrix &, const Vector &, const String &unit)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_wfs.cc:2778
ybatchCalc
void ybatchCalc(Matrix &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Matrix &, const ArrayOfArrayOfLineRecord &, const ArrayOfLineshapeSpec &, const Vector &, const Numeric &, const Vector &, const Numeric &, const Index &, const Index &, const Vector &, const Numeric &, const Numeric &, const Index &, const Vector &, const Vector &, const Numeric &, const String &, const TagGroups &, const ArrayOfString &, const ArrayOfVector &, const ArrayOfString &, const Index &, const Index &, const String &, const Index &, const String &, const ArrayOfString &, const ArrayOfString &, const Index &, const String &, const Index &, const String &)
See the the online help (arts -d FUNCTION_NAME)
Definition: m_batch.cc:334
arts.h
The global header file for ARTS.