testParametricXMLRayleighModel.cc
Go to the documentation of this file.
1 
10 #include <det/Detector.h>
11 #include <fdet/FDetector.h>
12 #include <fdet/Telescope.h>
13 #include <fdet/Eye.h>
14 
15 #include <atm/AttenuationResult.h>
16 #include <atm/ScatteringResult.h>
17 
18 #include <fwk/CentralConfig.h>
19 #include <fwk/CoordinateSystemRegistry.h>
20 
21 #include <utl/TimeStamp.h>
22 #include <utl/UTCDateTime.h>
23 #include <utl/ErrorLogger.h>
24 #include <utl/Point.h>
25 #include <utl/Vector.h>
26 #include <utl/TabulatedFunctionErrors.h>
27 #include <utl/ReferenceEllipsoid.h>
28 
29 #include <cppunit/extensions/HelperMacros.h>
30 #include <tst/Verify.h>
31 
32 #include <iostream>
33 
34 using namespace std;
35 using namespace det;
36 using namespace atm;
37 using namespace fwk;
38 using namespace utl;
39 using namespace tst;
40 
41 
42 class testParametricXMLRayleighModel : public CppUnit::TestFixture{
43 
44  CPPUNIT_TEST_SUITE(testParametricXMLRayleighModel);
45 
46  INFO("PLEASE IMPLEMENT ME");
47 
48 // CPPUNIT_TEST(testEvaluateAttenuation);
49 // CPPUNIT_TEST(testEvaluateScattering);
50 
51  CPPUNIT_TEST_SUITE_END();
52 
53 private:
54 
55 public:
56 
57  void setUp(){
58  CentralConfig::GetInstance(BOOTSTRAPFILE);
59  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
60  }
61 
62  void tearDown(){
63  }
64 
66 
67  Detector::GetInstance().Update(UTCDateTime(2005,1,1,0,0,0).GetTimeStamp());
68 
70  CSll(Detector::GetInstance().GetFDetector().GetEye("Los Leones").GetLocalCoordinateSystem() );
71 
72  //
73  // To test scattering and attenuation we define several
74  // points in the sky and compute scattering/attenuation between
75  // different pairs. Points are also defined in >1 coordinate system
76  // to ensure that the calculations are not CS dependent.
77  //
78  // 5 points are defined, arranged as indicated (schematically) below.
79  //
80  // C
81  //
82  //
83  //
84  //
85  // B D E
86  //
87  // A -------- z=0 in local CS ----------
88  //
89 
90  Point All(0., 0., 0., CSll);
91  Point Bll(0., 0., 2600.*m, CSll);
92  Point Cll(0., 0., 10000.*m, CSll);
93  Point Dll(0., 2000.*m, 2600.*m, CSll);
94  Point Ell(0.,20000.*m, 2600.*m, CSll);
95 
96  CoordinateSystemPtr CSst( Detector::GetInstance().GetSiteCoordinateSystem() );
97  Point Cst(0., 0., 10000.*m, CSst);
98 
99  vector<double> wlength;
100  wlength.push_back(300.*nanometer);
101  wlength.push_back(350.*nanometer);
102  wlength.push_back(400.*nanometer);
103 
104 
105  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
106 
107 
108  AttenuationResult attABll = theAtm.EvaluateRayleighAttenuation(All,
109  Bll,
110  wlength);
111  CPPUNIT_ASSERT(Verify<CloseTo>(attABll.GetTransmissionFactor().Y(300.*nanometer),0.771771));
112 
113 
114  AttenuationResult attACll = theAtm.EvaluateRayleighAttenuation(All,
115  Cll,
116  wlength);
117  CPPUNIT_ASSERT(Verify<CloseTo>(attACll.GetTransmissionFactor().Y(300.*nanometer), 0.498456));
118 
119  AttenuationResult attADll = theAtm.EvaluateRayleighAttenuation(All,
120  Dll,
121  wlength);
122  CPPUNIT_ASSERT(Verify<CloseTo>(attADll.GetTransmissionFactor().Y(300.*nanometer),0.721197));
123 
124  AttenuationResult attBDll = theAtm.EvaluateRayleighAttenuation(Bll,
125  Dll,
126  wlength);
127  CPPUNIT_ASSERT(Verify<CloseTo>(attBDll.GetTransmissionFactor().Y(300.*nanometer), 0.838598));
128 
129  AttenuationResult attBEll = theAtm.EvaluateRayleighAttenuation(Bll,
130  Ell,
131  wlength);
132  CPPUNIT_ASSERT(Verify<CloseTo>(attBEll.GetTransmissionFactor().Y(300.*nanometer), 0.172627));
133 
134  //
135  //
136  // Calculate distance between sea level and a fixed height above sea level using two different
137  // coordinate systems. The results should be identical (modulo difference in
138  // the vertical due to earth curvature). This test turns up error if, for eg.,
139  // you use GetZ(some CS) rather than the height above reference ellipsoid
140  // in ParametricXMLRayleighModel::GDistance
141  //
142  double heightSLll = ( (ReferenceEllipsoid::Get(ReferenceEllipsoid::eWGS84)).
143  PointToLatitudeLongitudeHeight( Point(0., 0., 0., CSll)) ).get<2>();
144  double heightSLst = ( (ReferenceEllipsoid::Get(ReferenceEllipsoid::eWGS84)).
145  PointToLatitudeLongitudeHeight( Point(0., 0., 0., CSst)) ).get<2>();
146 
147  AttenuationResult attCGroundLl
148  = theAtm.EvaluateRayleighAttenuation(Point(0., 0., 0., CSll),
149  Point(0., 0., 10000*m, CSll),
150  wlength);
151  AttenuationResult attCGroundSt
152  = theAtm.EvaluateRayleighAttenuation(Point(0., 0., heightSLll - heightSLst, CSst),
153  Point(0., 0., heightSLll - heightSLst + 10000.*m, CSst),
154  wlength);
155 
156  CPPUNIT_ASSERT(Verify<CloseTo>( attCGroundLl.GetTransmissionFactor().Y(300.*nanometer),
157  attCGroundSt.GetTransmissionFactor().Y(300.*nanometer)));
158 
159  }
160 
162 
163  Detector::GetInstance().Update(UTCDateTime(2005,1,1,0,0,0).GetTimeStamp());
164  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
166  CSll(Detector::GetInstance().GetFDetector().GetEye("Los Leones").GetLocalCoordinateSystem() );
167 
168  vector<double> wlength;
169  wlength.push_back(300*nanometer);
170  wlength.push_back(350*nanometer);
171  wlength.push_back(400*nanometer);
172 
173  Point pointA(0., 0. , 0., CSll);
174  Point pointB(0., 0. , 500.*m, CSll);
175  Point pointC(0., 500.*m, 500.*m, CSll);
176 
177  // vary angle
178  //
179  ScatteringResult scatAB1 =
180  theAtm.EvaluateRayleighScattering(pointA, pointB,
181  0., 1.*km, wlength);
182  CPPUNIT_ASSERT(Verify<CloseTo>(1.e9*scatAB1.GetScatteringFactor().Y(400.*nanometer), 2.06171, 1e-5));
183 
184  ScatteringResult scatAB2 =
185  theAtm.EvaluateRayleighScattering(pointA, pointB,
186  10.*degree, 1.*km, wlength);
187  CPPUNIT_ASSERT(Verify<CloseTo>(1e9*scatAB2.GetScatteringFactor().Y(400.*nanometer), 2.03062, 1e-5));
188 
189  ScatteringResult scatAB3 =
190  theAtm.EvaluateRayleighScattering(pointA, pointB,
191  90.*degree, 1.*km, wlength);
192  CPPUNIT_ASSERT(Verify<CloseTo>(1e9*scatAB3.GetScatteringFactor().Y(400.*nanometer), 1.03085, 1e-5));
193 
194  ScatteringResult scatAB4 =
195  theAtm.EvaluateRayleighScattering(pointA, pointB,
196  120.*degree, 1.*km, wlength);
197  CPPUNIT_ASSERT(Verify<CloseTo>(1.e9*scatAB4.GetScatteringFactor().Y(400.*nanometer), 1.28857, 1e-5));
198 
199 
200  // vary distance
201  //
202  ScatteringResult scatAB5 =
203  theAtm.EvaluateRayleighScattering(pointA, pointB,
204  30.*degree, 10.*km, wlength);
205  CPPUNIT_ASSERT(Verify<CloseTo>(1.e11*scatAB5.GetScatteringFactor().Y(400*nanometer),
206  1.80399, 1e-5));
207 
208  ScatteringResult scatAB6 =
209  theAtm.EvaluateRayleighScattering(pointA, pointB,
210  60.*degree, 10.*km, wlength);
211  CPPUNIT_ASSERT(Verify<CloseTo>(1.e11*scatAB6.GetScatteringFactor().Y(400*nanometer),
212  1.28857, 1e-5));
213 
214 
215  // new pair of points (at same altitude)
216  //
217  ScatteringResult scatBC1 =
218  theAtm.EvaluateRayleighScattering(pointB, pointC,
219  0., 1.*km, wlength);
220  CPPUNIT_ASSERT(Verify<CloseTo>(1e9*scatBC1.GetScatteringFactor().Y(400*nanometer),
221  1.99968, 1e-5));
222 
223  ScatteringResult scatBC2 =
224  theAtm.EvaluateRayleighScattering(pointB, pointC,
225  10.*degree, 1.*km, wlength);
226  CPPUNIT_ASSERT(Verify<CloseTo>(1e9*scatBC2.GetScatteringFactor().Y(400*nanometer),
227  1.96953, 1e-5));
228 
229  ScatteringResult scatBC3 =
230  theAtm.EvaluateRayleighScattering(pointB, pointC,
231  90.*degree, 1.*km, wlength);
232  CPPUNIT_ASSERT(Verify<CloseTo>(1.e10*scatBC3.GetScatteringFactor().Y(400*nanometer),
233  9.99842, 1e-5));
234 
235  ScatteringResult scatBC4 =
236  theAtm.EvaluateRayleighScattering(pointB, pointC,
237  120.*degree, 1.*km, wlength);
238  CPPUNIT_ASSERT(Verify<CloseTo>(1e9*scatBC4.GetScatteringFactor().Y(400*nanometer),
239  1.2498, 1e-5));
240 
241  // TO DO : vary wavelengths
242  //
243 
244  // check angle returned by ScatteringResult
245  //
246  CPPUNIT_ASSERT(Verify<CloseTo>(scatAB1.GetScatteringAngle(), 0.));
247  CPPUNIT_ASSERT(Verify<CloseTo>(scatAB2.GetScatteringAngle(), 10.*degree));
248 
249 
250  }
251 
252 };
253 
255 
256 
257 
258 // Configure (x)emacs for this file ...
259 // Local Variables:
260 // mode:c++
261 // compile-command: "make -C .. -k"
262 // End:
double GetScatteringAngle() const
Get calculated scattering angle.
Top of the interface to Atmosphere information.
const double degree
Point object.
Definition: Point.h:32
const utl::TabulatedFunctionErrors & GetTransmissionFactor() const
Transmission factor.
Traditional name.
Definition: Verbosity.h:17
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
constexpr double nanometer
Definition: AugerUnits.h:102
Class holding the output of the ScatteringResult function.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
atm::AttenuationResult EvaluateRayleighAttenuation(const utl::Point &xInit, const utl::Point &xFinal, const std::vector< double > &wLength) const
Compute Rayleigh attenuation between points.
atm::ScatteringResult EvaluateRayleighScattering(const utl::Point &xA, const utl::Point &xB, const double angle, const double distance, const std::vector< double > &xLength) const
const double km
const utl::TabulatedFunctionErrors & GetScatteringFactor() const
Scattering factor.
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
constexpr double m
Definition: AugerUnits.h:121
Class describing the Atmospheric attenuation.

, generated on Tue Sep 26 2023.