00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00033
00034
00035
00036
00037 #include "mc_antenna.h"
00038
00039 #ifdef HAVE_SSTREAM
00040 #include <sstream>
00041 #else
00042 #include "sstream.h"
00043 #endif
00044
00045
00046
00048
00065 Numeric ran_gaussian (
00066 Rng& rng,
00067 const Numeric sigma)
00068 {
00069 Numeric x, y, r2;
00070
00071 do
00072 {
00073
00074
00075 x = -1 + 2 * rng.draw();
00076 y = -1 + 2 * rng.draw();
00077
00078
00079 r2 = x * x + y * y;
00080 }
00081 while (r2 > 1.0 || r2 == 0);
00082
00083
00084 return sigma * y * sqrt (-2.0 * log (r2) / r2);
00085 }
00086
00088 void MCAntenna::set_pencil_beam (void){
00089 atype=ATYPE_PENCIL_BEAM;
00090 }
00091
00093
00100 void MCAntenna::set_gaussian (const Numeric& za_sigma,
00101 const Numeric& aa_sigma)
00102 {
00103 atype=ATYPE_GAUSSIAN;
00104 sigma_za=za_sigma;
00105 sigma_aa=aa_sigma;
00106 }
00107
00109
00116 void MCAntenna::set_gaussian_fwhm (const Numeric& za_fwhm,
00117 const Numeric& aa_fwhm)
00118 {
00119 atype=ATYPE_GAUSSIAN;
00120 sigma_za=za_fwhm/2.3548;
00121 sigma_aa=aa_fwhm/2.3548;
00122 }
00123
00125
00134 void MCAntenna::set_lookup (ConstVectorView& za_grid_,
00135 ConstVectorView& aa_grid_,
00136 ConstMatrixView& G_lookup_)
00137 {
00138 atype=ATYPE_LOOKUP;
00139 za_grid=za_grid_;
00140 aa_grid=aa_grid_;
00141 G_lookup=G_lookup_;
00142 }
00143
00145
00150 AType MCAntenna::get_type(void) const
00151 {
00152 return atype;
00153 }
00154
00155
00156
00157
00159
00167 void MCAntenna::draw_los(VectorView& sampled_rte_los,
00168 Rng& rng,
00169 ConstVectorView bore_sight_los) const
00170 {
00171
00172 switch ( atype )
00173 {
00174 case ATYPE_PENCIL_BEAM:
00175 sampled_rte_los=bore_sight_los;
00176 break;
00177 case ATYPE_GAUSSIAN:
00178 sampled_rte_los[0]=bore_sight_los[0]+ran_gaussian(rng,sigma_za);
00179 sampled_rte_los[1]=bore_sight_los[1]+ran_gaussian(rng,sigma_aa);
00180 if ( sampled_rte_los[1]>180 )
00181 {
00182 sampled_rte_los[1]-=360;
00183 }
00184 break;
00185
00186
00187
00188
00189
00190 default:
00191 ostringstream os;
00192 os << "invalid Antenna type.";
00193 throw runtime_error( os.str() );
00194 }
00195
00196 }
00197
00198 ostream& operator<< (ostream& os, const MCAntenna&)
00199 {
00200 os << "MCAntenna: Output operator not implemented";
00201 return os;
00202 }