ARTS  2.0.49
refraction.cc
Go to the documentation of this file.
1 /* Copyright (C) 2002-2008 Patrick Eriksson <patrick.eriksson@chalmers.se>
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 
19 
20 /*===========================================================================
21  === File description
22  ===========================================================================*/
23 
34 /*===========================================================================
35  === External declarations
36  ===========================================================================*/
37 
38 #include <cmath>
39 #include "auto_md.h"
40 #include "interpolation.h"
41 #include "refraction.h"
42 #include "special_interp.h"
43 
44 extern const Numeric DEG2RAD;
45 extern const Numeric RAD2DEG;
46 
47 
48 
49 /*===========================================================================
50  === The functions (in alphabetical order)
51  ===========================================================================*/
52 
53 
55 
83  Workspace& ws,
84  Numeric& refr_index,
85  Numeric& a_pressure,
86  Numeric& a_temperature,
87  Vector& a_vmr_list,
88  const Agenda& refr_index_agenda,
89  ConstVectorView p_grid,
90  const Numeric& r_geoid,
91  ConstVectorView z_field,
92  ConstVectorView t_field,
93  ConstMatrixView vmr_field,
94  const Numeric& r )
95 {
96  // Altitude (equal to pressure) grid position
97  ArrayOfGridPos gp(1);
98  gridpos( gp, z_field, Vector( 1, r - r_geoid ) );
99 
100  // Altitude interpolation weights
101  Matrix itw(1,2);
102  interpweights( itw, gp );
103 
104  // Pressure
105  Vector dummy(1);
106  itw2p( dummy, p_grid, gp, itw );
107  a_pressure = dummy[0];
108 
109  // Temperature
110  interp( dummy, itw, t_field, gp );
111  a_temperature = dummy[0];
112 
113  // VMR
114  const Index ns = vmr_field.nrows();
115  //
116  a_vmr_list.resize(ns);
117  //
118  for( Index is=0; is<ns; is++ )
119  {
120  interp( dummy, itw, vmr_field(is,joker), gp );
121  a_vmr_list[is] = dummy[0];
122  }
123 
125  refr_index, a_pressure, a_temperature, a_vmr_list,
126  refr_index_agenda );
127 }
128 
129 
130 
132 
163  Workspace& ws,
164  Numeric& refr_index,
165  Numeric& a_pressure,
166  Numeric& a_temperature,
167  Vector& a_vmr_list,
168  const Agenda& refr_index_agenda,
169  ConstVectorView p_grid,
170  ConstVectorView lat_grid,
171  ConstVectorView r_geoid,
172  ConstMatrixView z_field,
173  ConstMatrixView t_field,
174  ConstTensor3View vmr_field,
175  const Numeric& r,
176  const Numeric& lat )
177 {
178  // Determine the geometric altitudes at *lat*
179  const Index np = p_grid.nelem();
180  Vector z_grid(np);
181  ArrayOfGridPos gp_lat(1);
182  //
183  gridpos( gp_lat, lat_grid, lat );
184  z_at_lat_2d( z_grid, p_grid, lat_grid, z_field, gp_lat[0] );
185 
186  // Determine the geoid radius at *lat*
187  Matrix itw(1,2);
188  Vector dummy(1);
189  interpweights( itw, gp_lat );
190  interp( dummy, itw, r_geoid, gp_lat );
191  const Numeric rgeoid = dummy[0];
192 
193  // Altitude (equal to pressure) grid position
194  ArrayOfGridPos gp_p(1);
195  gridpos( gp_p, z_grid, Vector( 1, r - rgeoid ) );
196 
197  // Altitude interpolation weights
198  interpweights( itw, gp_p );
199 
200  // Pressure
201  itw2p( dummy, p_grid, gp_p, itw );
202  a_pressure = dummy[0];
203 
204  // Temperature
205  itw.resize(1,4);
206  interpweights( itw, gp_p, gp_lat );
207  interp( dummy, itw, t_field, gp_p, gp_lat );
208  a_temperature = dummy[0];
209 
210  // VMR
211  const Index ns = vmr_field.npages();
212  //
213  a_vmr_list.resize(ns);
214  //
215  for( Index is=0; is<ns; is++ )
216  {
217  interp( dummy, itw, vmr_field(is,joker,joker), gp_p, gp_lat );
218  a_vmr_list[is] = dummy[0];
219  }
220 
222  refr_index, a_pressure, a_temperature, a_vmr_list,
223  refr_index_agenda );
224 }
225 
226 
227 
257  Workspace& ws,
258  Numeric& refr_index,
259  Numeric& a_pressure,
260  Numeric& a_temperature,
261  Vector& a_vmr_list,
262  const Agenda& refr_index_agenda,
263  ConstVectorView p_grid,
264  ConstVectorView lat_grid,
265  ConstVectorView lon_grid,
266  ConstMatrixView r_geoid,
267  ConstTensor3View z_field,
268  ConstTensor3View t_field,
269  ConstTensor4View vmr_field,
270  const Numeric& r,
271  const Numeric& lat,
272  const Numeric& lon )
273 {
274  // Determine the geometric altitudes at *lat* and *lon*
275  const Index np = p_grid.nelem();
276  Vector z_grid(np);
277  ArrayOfGridPos gp_lat(1), gp_lon(1);
278  //
279  gridpos( gp_lat, lat_grid, lat );
280  gridpos( gp_lon, lon_grid, lon );
281  z_at_latlon( z_grid, p_grid, lat_grid, lon_grid, z_field,
282  gp_lat[0], gp_lon[0] );
283 
284  // Determine the geoid radius at *lat*
285  Matrix itw(1,4);
286  Vector dummy(1);
287  interpweights( itw, gp_lat, gp_lon );
288  interp( dummy, itw, r_geoid, gp_lat, gp_lon );
289  const Numeric rgeoid = dummy[0];
290 
291  // Altitude (equal to pressure) grid position
292  ArrayOfGridPos gp_p(1);
293  gridpos( gp_p, z_grid, Vector( 1, r - rgeoid ) );
294 
295  // Altitude interpolation weights
296  itw.resize(1,2);
297  interpweights( itw, gp_p );
298 
299  // Pressure
300  itw2p( dummy, p_grid, gp_p, itw );
301  a_pressure = dummy[0];
302 
303  // Temperature
304  itw.resize(1,8);
305  interpweights( itw, gp_p, gp_lat, gp_lon );
306  interp( dummy, itw, t_field, gp_p, gp_lat, gp_lon );
307  a_temperature = dummy[0];
308 
309  // VMR
310  const Index ns = vmr_field.nbooks();
311  //
312  a_vmr_list.resize(ns);
313  //
314  for( Index is=0; is<ns; is++ )
315  {
316  interp( dummy, itw, vmr_field(is,joker,joker,joker), gp_p, gp_lat,
317  gp_lon );
318  a_vmr_list[is] = dummy[0];
319  }
320 
322  refr_index, a_pressure, a_temperature, a_vmr_list,
323  refr_index_agenda );
324 }
325 
326 
327 
329 
360  Workspace& ws,
361  Numeric& refr_index,
362  Numeric& dndr,
363  Numeric& a_pressure,
364  Numeric& a_temperature,
365  Vector& a_vmr_list,
366  const Agenda& refr_index_agenda,
367  ConstVectorView p_grid,
368  const Numeric& r_geoid,
369  ConstVectorView z_field,
370  ConstVectorView t_field,
371  ConstMatrixView vmr_field,
372  const Numeric& r )
373 {
374  get_refr_index_1d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
375  refr_index_agenda, p_grid,
376  r_geoid, z_field, t_field, vmr_field, r );
377 
378  const Numeric n0 = refr_index;
379 
380  get_refr_index_1d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
381  refr_index_agenda, p_grid,
382  r_geoid, z_field, t_field, vmr_field, r+1 );
383 
384  dndr = refr_index - n0;
385 
386  refr_index = n0;
387 }
388 
389 
390 
392 
431  Workspace& ws,
432  Numeric& refr_index,
433  Numeric& dndr,
434  Numeric& dndlat,
435  Numeric& a_pressure,
436  Numeric& a_temperature,
437  Vector& a_vmr_list,
438  const Agenda& refr_index_agenda,
439  ConstVectorView p_grid,
440  ConstVectorView lat_grid,
441  ConstVectorView r_geoid,
442  ConstMatrixView z_field,
443  ConstMatrixView t_field,
444  ConstTensor3View vmr_field,
445  const Numeric& r,
446  const Numeric& lat )
447 {
448  get_refr_index_2d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
449  refr_index_agenda, p_grid, lat_grid,
450  r_geoid, z_field, t_field, vmr_field, r, lat );
451 
452  const Numeric n0 = refr_index;
453 
454  get_refr_index_2d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
455  refr_index_agenda, p_grid, lat_grid, r_geoid,
456  z_field, t_field, vmr_field, r+1, lat );
457 
458  dndr = refr_index - n0;
459 
460  const Numeric dlat = 1e-4;
461 
462  get_refr_index_2d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
463  refr_index_agenda, p_grid, lat_grid, r_geoid,
464  z_field, t_field, vmr_field, r, lat+dlat );
465 
466  dndlat = ( refr_index - n0 ) / ( DEG2RAD * dlat * r );
467 
468  refr_index = n0;
469 }
470 
471 
472 
474 
512  Workspace& ws,
513  Numeric& refr_index,
514  Numeric& dndr,
515  Numeric& dndlat,
516  Numeric& dndlon,
517  Numeric& a_pressure,
518  Numeric& a_temperature,
519  Vector& a_vmr_list,
520  const Agenda& refr_index_agenda,
521  ConstVectorView p_grid,
522  ConstVectorView lat_grid,
523  ConstVectorView lon_grid,
524  ConstMatrixView r_geoid,
525  ConstTensor3View z_field,
526  ConstTensor3View t_field,
527  ConstTensor4View vmr_field,
528  const Numeric& r,
529  const Numeric& lat,
530  const Numeric& lon )
531 {
532  get_refr_index_3d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
533  refr_index_agenda, p_grid, lat_grid,
534  lon_grid, r_geoid, z_field, t_field, vmr_field, r, lat, lon );
535 
536  const Numeric n0 = refr_index;
537 
538  get_refr_index_3d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
539  refr_index_agenda, p_grid, lat_grid,
540  lon_grid, r_geoid, z_field, t_field, vmr_field, r+1, lat, lon );
541 
542  dndr = refr_index - n0;
543 
544  const Numeric dlat = 1e-4;
545 
546  get_refr_index_3d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
547  refr_index_agenda, p_grid, lat_grid,
548  lon_grid, r_geoid, z_field, t_field, vmr_field,
549  r, lat+dlat, lon );
550 
551  dndlat = ( refr_index - n0 ) / ( DEG2RAD * dlat * r );
552 
553  const Numeric dlon = 1e-4;
554 
555  get_refr_index_3d( ws, refr_index, a_pressure, a_temperature, a_vmr_list,
556  refr_index_agenda, p_grid, lat_grid,
557  lon_grid, r_geoid, z_field, t_field, vmr_field,
558  r, lat, lon+dlon);
559 
560  dndlon = ( refr_index - n0 ) / ( DEG2RAD * dlon * r * cos( DEG2RAD*lat ) );
561 
562  refr_index = n0;
563 }
564 
565 
566 
568 
582  Numeric& refr_index,
583  const Numeric& p,
584  const Numeric& t,
585  const Numeric& h2o_vmr )
586 {
587  const Numeric e = p * h2o_vmr;
588 
589  refr_index = 1 + ( 77.6e-8 * ( p - e ) +
590  ( 64.8e-8 + 3.776e-3 / t ) * e ) / t;
591 }
592 
594 
603  Numeric& refr_index,
604  const Numeric& p,
605  const Numeric& t )
606 {
607  const Numeric bn0 = 1.000272620045304;
608  const Numeric bk = 288.16 * (pow(bn0,Numeric(2.0))-1.0)/
609  (1013.25*(pow(bn0,Numeric(2.0))+2.0));
610 
611  // Pa -> HPa
612  refr_index = sqrt((2.0*bk*p/100.0+t)/(t-bk*p/100.0));
613 }
Matrix
The Matrix class.
Definition: matpackI.h:767
auto_md.h
refr_index_agendaExecute
void refr_index_agendaExecute(Workspace &ws, Numeric &refr_index, const Numeric rte_pressure, const Numeric rte_temperature, const Vector &rte_vmr_list, const Agenda &input_agenda)
Definition: auto_md.cc:10371
gridpos
void gridpos(ArrayOfGridPos &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Numeric &extpolfac)
Set up a grid position Array.
Definition: interpolation.cc:167
itw2p
void itw2p(VectorView p_values, ConstVectorView p_grid, const ArrayOfGridPos &gp, ConstMatrixView itw)
itw2p
Definition: special_interp.cc:763
joker
const Joker joker
interpolation.h
Header file for interpolation.cc.
interp
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
Definition: interpolation.cc:1000
refr_index_thayer_1974
void refr_index_thayer_1974(Numeric &refr_index, const Numeric &p, const Numeric &t, const Numeric &h2o_vmr)
refr_index_thayer_1974
Definition: refraction.cc:581
get_refr_index_2d
void get_refr_index_2d(Workspace &ws, Numeric &refr_index, Numeric &a_pressure, Numeric &a_temperature, Vector &a_vmr_list, const Agenda &refr_index_agenda, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView r_geoid, ConstMatrixView z_field, ConstMatrixView t_field, ConstTensor3View vmr_field, const Numeric &r, const Numeric &lat)
get_refr_index_2d
Definition: refraction.cc:162
z_at_latlon
void z_at_latlon(VectorView z, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstTensor3View z_field, const GridPos &gp_lat, const GridPos &gp_lon)
z_at_latlon
Definition: special_interp.cc:934
refr_gradients_3d
void refr_gradients_3d(Workspace &ws, Numeric &refr_index, Numeric &dndr, Numeric &dndlat, Numeric &dndlon, Numeric &a_pressure, Numeric &a_temperature, Vector &a_vmr_list, const Agenda &refr_index_agenda, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstMatrixView r_geoid, ConstTensor3View z_field, ConstTensor3View t_field, ConstTensor4View vmr_field, const Numeric &r, const Numeric &lat, const Numeric &lon)
refr_gradients_3d
Definition: refraction.cc:511
RAD2DEG
const Numeric RAD2DEG
refr_gradients_1d
void refr_gradients_1d(Workspace &ws, Numeric &refr_index, Numeric &dndr, Numeric &a_pressure, Numeric &a_temperature, Vector &a_vmr_list, const Agenda &refr_index_agenda, ConstVectorView p_grid, const Numeric &r_geoid, ConstVectorView z_field, ConstVectorView t_field, ConstMatrixView vmr_field, const Numeric &r)
refr_gradients_1d
Definition: refraction.cc:359
Vector::resize
void resize(Index n)
Resize function.
Definition: matpackI.cc:771
ConstMatrixView::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackI.cc:796
z_at_lat_2d
void z_at_lat_2d(VectorView z, ConstVectorView p_grid, ConstVectorView lat_grid, ConstMatrixView z_field, const GridPos &gp_lat)
z_at_lat_2d
Definition: special_interp.cc:882
Agenda
The Agenda class.
Definition: agenda_class.h:44
ConstTensor3View::npages
Index npages() const
Returns the number of pages.
Definition: matpackIII.h:151
ConstTensor4View
A constant view of a Tensor4.
Definition: matpackIV.h:149
Array< GridPos >
ConstVectorView::nelem
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:175
ns
#define ns
Definition: continua.cc:14564
refr_gradients_2d
void refr_gradients_2d(Workspace &ws, Numeric &refr_index, Numeric &dndr, Numeric &dndlat, Numeric &a_pressure, Numeric &a_temperature, Vector &a_vmr_list, const Agenda &refr_index_agenda, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView r_geoid, ConstMatrixView z_field, ConstMatrixView t_field, ConstTensor3View vmr_field, const Numeric &r, const Numeric &lat)
refr_gradients_2d
Definition: refraction.cc:430
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
ConstTensor4View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackIV.cc:60
get_refr_index_1d
void get_refr_index_1d(Workspace &ws, Numeric &refr_index, Numeric &a_pressure, Numeric &a_temperature, Vector &a_vmr_list, const Agenda &refr_index_agenda, ConstVectorView p_grid, const Numeric &r_geoid, ConstVectorView z_field, ConstVectorView t_field, ConstMatrixView vmr_field, const Numeric &r)
get_refr_index_1d
Definition: refraction.cc:82
Matrix::resize
void resize(Index r, Index c)
Resize function.
Definition: matpackI.cc:1549
ConstMatrixView
A constant view of a Matrix.
Definition: matpackI.h:591
refraction.h
Refraction functions.
refr_index_ir
void refr_index_ir(Numeric &refr_index, const Numeric &p, const Numeric &t)
refr_index_ir
Definition: refraction.cc:602
Workspace
Workspace class.
Definition: workspace_ng.h:47
ConstTensor3View
A constant view of a Tensor3.
Definition: matpackIII.h:147
special_interp.h
Header file for special_interp.cc.
get_refr_index_3d
void get_refr_index_3d(Workspace &ws, Numeric &refr_index, Numeric &a_pressure, Numeric &a_temperature, Vector &a_vmr_list, const Agenda &refr_index_agenda, ConstVectorView p_grid, ConstVectorView lat_grid, ConstVectorView lon_grid, ConstMatrixView r_geoid, ConstTensor3View z_field, ConstTensor3View t_field, ConstTensor4View vmr_field, const Numeric &r, const Numeric &lat, const Numeric &lon)
Definition: refraction.cc:256
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
DEG2RAD
const Numeric DEG2RAD
Vector
The Vector class.
Definition: matpackI.h:555
ConstVectorView
A constant view of a Vector.
Definition: matpackI.h:300
interpweights
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
Definition: interpolation.cc:756