ARTS  2.2.66
mc_antenna.cc
Go to the documentation of this file.
1 /* Copyright (C) 2005-2012 Cory Davis <cory@met.ed.ac.uk>
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 
33 /*===========================================================================
34  === External declarations
35  ===========================================================================*/
36 
37 #include "mc_antenna.h"
38 
39 #ifdef HAVE_SSTREAM
40 #include <sstream>
41 #else
42 #include "sstream.h"
43 #endif
44 
45 
46 
48 
66  Rng& rng,
67  const Numeric sigma)
68 {
69  Numeric x, y, r2;
70 
71  do
72  {
73  /* choose x,y in uniform square (-1,-1) to (+1,+1) */
74 
75  x = -1 + 2 * rng.draw();
76  y = -1 + 2 * rng.draw();
77 
78  /* see if it is in the unit circle */
79  r2 = x * x + y * y;
80  }
81  while (r2 > 1.0 || r2 == 0);
82 
83  /* Box-Muller transform */
84  return sigma * y * sqrt (-2.0 * log (r2) / r2);
85 }
86 
90 }
91 
93 
100 void MCAntenna::set_gaussian (const Numeric& za_sigma,
101  const Numeric& aa_sigma)
102 {
104  sigma_za=za_sigma;
105  sigma_aa=aa_sigma;
106 }
107 
109 
117  const Numeric& aa_fwhm)
118 {
120  sigma_za=za_fwhm/2.3548;
121  sigma_aa=aa_fwhm/2.3548;
122 }
123 
125 
135  ConstVectorView& aa_grid_,
136  ConstMatrixView& G_lookup_)
137 {
139  za_grid=za_grid_;
140  aa_grid=aa_grid_;
141  G_lookup=G_lookup_;
142 }
143 
145 
151 {
152  return atype;
153 }
154 
155 
156 
157 
159 
167 void MCAntenna::draw_los(VectorView& sampled_rte_los,
168  Rng& rng,
169  ConstVectorView bore_sight_los) const
170 {
171 
172  switch ( atype )
173  {
175  sampled_rte_los=bore_sight_los;
176  break;
178  sampled_rte_los[0]=bore_sight_los[0]+ran_gaussian(rng,sigma_za);
179  sampled_rte_los[1]=bore_sight_los[1]+ran_gaussian(rng,sigma_aa);
180  if ( sampled_rte_los[1]>180 )
181  {
182  sampled_rte_los[1]-=360;
183  }
184  break;
185  // case ANTENNA_TYPE_LOOKUP:
186  //ostringstream os;
187  //os << "Antenna type ANTENNA_TYPE_LOOKUP not yet implemented.";
188  //throw runtime_error( os.str() );
189  //break;
190  default:
191  ostringstream os;
192  os << "invalid Antenna type.";
193  throw runtime_error( os.str() );
194  }
195 
196 }
197 
198 ostream& operator<< (ostream& os, const MCAntenna&)
199 {
200  os << "MCAntenna: Output operator not implemented";
201  return os;
202 }
The VectorView class.
Definition: matpackI.h:372
void set_pencil_beam(void)
makes the antenna pattern a pencil beam
Definition: mc_antenna.cc:88
void set_gaussian(const Numeric &za_sigma, const Numeric &aa_sigma)
makes the antenna pattern a 2D gaussian specified by za and aa standard deviations ...
Definition: mc_antenna.cc:100
void draw_los(VectorView &sampled_rte_los, Rng &rng, ConstVectorView bore_sight_los) const
draws a line of sight by sampling the antenna response function
Definition: mc_antenna.cc:167
Numeric sigma_za
Definition: mc_antenna.h:58
Workspace functions for the solution of cloud-box radiative transfer by Monte Carlo methods...
Numeric ran_gaussian(Rng &rng, const Numeric sigma)
ran_gaussian
Definition: mc_antenna.cc:65
ostream & operator<<(ostream &os, const MCAntenna &)
Definition: mc_antenna.cc:198
AntennaType
Definition: mc_antenna.h:47
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
An Antenna object used by MCGeneral.
Definition: mc_antenna.h:56
double draw()
Definition: rng.cc:120
Definition: rng.h:569
A constant view of a Vector.
Definition: matpackI.h:292
Vector za_grid
Definition: mc_antenna.h:59
A constant view of a Matrix.
Definition: matpackI.h:596
Numeric sigma_aa
Definition: mc_antenna.h:58
AntennaType atype
Definition: mc_antenna.h:57
void set_gaussian_fwhm(const Numeric &za_fwhm, const Numeric &aa_fwhm)
makes the antenna pattern a 2D gaussian specified by za and aa FWHM
Definition: mc_antenna.cc:116
Matrix G_lookup
Definition: mc_antenna.h:60
Vector aa_grid
Definition: mc_antenna.h:59
void set_lookup(ConstVectorView &za_grid, ConstVectorView &aa_grid, ConstMatrixView &G_lookup)
makes the antenna pattern use a 2D lookup table to define the antenna response
Definition: mc_antenna.cc:134
AntennaType get_type(void) const
returns the antenna type
Definition: mc_antenna.cc:150