testLowLevelAtmInterface.cc
Go to the documentation of this file.
1 
9 #include <det/Detector.h>
10 
11 #include <fdet/FDetector.h>
12 #include <fdet/Eye.h>
13 #include <fdet/Telescope.h>
14 #include <fdet/Pixel.h>
15 
16 #include <atm/AerosolDB.h>
17 #include <atm/OverallQualityDB.h>
18 #include <atm/AerosolZone.h>
19 #include <atm/AttSlice.h>
20 #include <atm/PFSlice.h>
21 #include <atm/MolecularZone.h>
22 #include <atm/LidarDB.h>
23 #include <atm/LidarZone.h>
24 #include <atm/VAODSlice.h>
25 #include <atm/MolecularIds.h>
26 #include <atm/MolecularDB.h>
27 #include <atm/GOESDB.h>
28 
29 #include <fwk/CentralConfig.h>
30 
31 #include <utl/ErrorLogger.h>
32 #include <utl/AugerUnits.h>
33 #include <utl/AugerException.h>
34 #include <utl/Point.h>
35 #include <fwk/CoordinateSystemRegistry.h>
36 
37 #include <cppunit/extensions/HelperMacros.h>
38 #include <tst/Verify.h>
39 
40 #include <iostream>
41 
42 // For some reason, CLHEP SystemOfUnits.h
43 // #defines pascal to hep_pascal, putting it in
44 // the global namespace and screwing up our own
45 // definition of pascal from AugerUnits.h. It appears
46 // the CLHEP units are being pulled in via the geometry
47 // package. The following line undoes the CLHEP sabotage.
48 #undef pascal
49 
50 using namespace std;
51 using namespace det;
52 using namespace atm;
53 using namespace fwk;
54 using namespace utl;
55 using namespace tst;
56 
57 namespace {
58  const double gNCloudProbabilityLevels = 5; // DB returns from [0, 4]
59 }
60 
61 class testAtmLowLevelAtmInterface : public CppUnit::TestFixture {
62 
63 
64  CPPUNIT_TEST_SUITE(testAtmLowLevelAtmInterface);
65 
66  CPPUNIT_TEST(testGOESDB);
67 
68  //
69  // All the Checks are performed against quantities stored in the
70  // validate_Atm_xyz databases.
71  //
72 
73  // Test AerosolDB interface (zone iterators and whatnot).
74  CPPUNIT_TEST(testAerosolDB);
75 
76  // Test iterating over and retrieving data from attenuation slices
77  CPPUNIT_TEST(testAttSlice);
78 
79  // Test iterating over and retrieving data from phase function slices
80  CPPUNIT_TEST(testPFSlice);
81 
82  // Test MolecularDB interface
83  // THIS TEST HAS BEEN COMMENTED OUT AS IT WAS PREPARED FOR VERSION 0_A OF
84  // THE MOLECULAR DATABASE. THIS VERSION USED SEASONAL PROFILES, WHICH HAVE
85  // SINCE BEEN REPLACED BY GDAS AND WEATHER STATION MEASUREMENTS, WHICH ARE
86  // WRITTEN IN VERSION 1_A OF THE MOLECULAR DB. THIS TEST SHOULD BE REWRITTEN
87  // BY SOMEONE TO CHECK VERSION 1_A. THIS WOULD INVOLVE ALSO CREATING A SIMPLE
88  // TEST DATABASE FOLLOWING THE SAME CONVENTIONS AS VERSION 1_A OF THE DATABASE.
89  // CPPUNIT_TEST(testMolecularDB);
90 
91  // Test iterating over and retrieveing data from molecular layers
92  CPPUNIT_TEST(testMolecularLayer);
93 
94  // Test failure to find data in molecular db
95  CPPUNIT_TEST(testMolecularDBNotFound);
96 
97  // Test case of no data in aerosol db
98  CPPUNIT_TEST(testAerosolDBNotFound);
99 
100  // Test OverallQualityDB interface
101  CPPUNIT_TEST(testOverallQualityDB);
102  CPPUNIT_TEST_EXCEPTION(testOverallQualityDBNotFound, DataNotFoundInDBException);
103 
104  // Test LidarDB interface
105  CPPUNIT_TEST(testLidarDB);
106 
107  // Test iterating over and retrieveing data from VAOD slices in Lidar db
108  CPPUNIT_TEST(testVAODSlice);
109 
110  // Test the GOES cloud db
111  CPPUNIT_TEST_EXCEPTION(testGOESDBNotFound1, DataNotFoundInDBException);
112  CPPUNIT_TEST_EXCEPTION(testGOESDBNotFound2, DataNotFoundInDBException);
113  CPPUNIT_TEST_EXCEPTION(testGOESDBNotFound3, NonExistentComponentException);
114 
115  // Test the cloud camera db.
116  // Somebody should write a cloud db test.
117  // CPPUNIT_TEST(testCloudDB);
118 
119  CPPUNIT_TEST_SUITE_END();
120 
121 public:
122  void
124  {
125  CentralConfig::GetInstance(BOOTSTRAPFILE);
126  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
127  }
128 
129  void tearDown() { }
130 
131  // Test interface to Atm_Aerosol database
132  void
134  {
135  Detector& det = Detector::GetInstance();
136  det.Update(1111112);
137 
138  const AerosolDB& aerosol1 = det.GetAtmosphere().GetAerosolDB();
139 
140  int numZonesAerosol1 = 0;
141  for (AerosolDB::ZoneIterator zIt = aerosol1.ZonesBegin();
142  zIt != aerosol1.ZonesEnd(); ++zIt) {
143 
144  if (zIt->GetName() == "Coihueco") {
145  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetNorthing(), 6114141.8*meter));
146  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetEasting(), 445346.*meter));
147  ++numZonesAerosol1;
148  }
149 
150  if (zIt->GetName() == "twilightZone") {
151  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetNorthing(), 144924.*meter));
152  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetEasting(), 1233122.*meter));
153  ++numZonesAerosol1;
154  }
155 
156  if (zIt->GetName() == "Los Morados") {
157  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetNorthing(), 6094571.*meter));
158  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetEasting(), 498885.*meter));
159  ++numZonesAerosol1;
160  }
161 
162  }
163  CPPUNIT_ASSERT(Verify<Equal>(numZonesAerosol1, 3)); // should be three entries for time 1111112
164 
165  det.Update(2222223);
166 
167  const AerosolDB& aerosol2 = det.GetAtmosphere().GetAerosolDB();
168 
169  int numZonesAerosol2 = 0;
170  for (AerosolDB::ZoneIterator zIt = aerosol2.ZonesBegin();
171  zIt != aerosol2.ZonesEnd(); ++zIt)
172  ++numZonesAerosol2;
173  CPPUNIT_ASSERT(Verify<Equal>(numZonesAerosol2, 2));
174  }
175 
176  void
178  {
179  Detector& det = Detector::GetInstance();
180  det.Update(1111112); // the second aerosol object !
181  const AerosolDB& aerosolDB = det.GetAtmosphere().GetAerosolDB();
182 
183  // iterate over zones
184  for (AerosolDB::ZoneIterator zIt = aerosolDB.ZonesBegin();
185  zIt != aerosolDB.ZonesEnd(); ++zIt) {
186 
187  double bogusValue = 0;
188  int iSliceNumber = 1;
189 
190  // iterate over attenuation slices for this zone
191  for (AerosolZone::AttSliceIterator attIt = zIt->AttSlicesBegin();
192  attIt != zIt->AttSlicesEnd(); ++attIt) {
193 
194  if (zIt->GetName() == "Coihueco") {
195  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinHeight(), bogusValue*meter));
196  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxHeight(), (bogusValue+10.)*meter));
197 
198  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetVAOD(), (bogusValue+11.)));
199  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinVAOD(), (bogusValue+12.)));
200  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxVAOD(), (bogusValue+13.)));
201 
202  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetAttAlpha(), (77.0 + bogusValue)/meter));
203  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinAttAlpha(), (0.77 - bogusValue/100.)/meter));
204  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxAttAlpha(), (0.77 + bogusValue/100.)/meter));
205 
206  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetAttLambda(), 78.0 + bogusValue));
207  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinAttLambda(), 0.78 - bogusValue/100.));
208  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxAttLambda(), 0.77 + bogusValue/100.));
209  }
210 
211  if (zIt->GetName() == "twilightZone") {
212  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinHeight(), 0.*m));
213  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxHeight(), 10000.*m));
214  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetVAOD(), 10000.));
215  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinVAOD(), 10.));
216  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxVAOD(), 10.));
217 
218 
219  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetAttAlpha(), 10./m));
220  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinAttAlpha(), 1./m));
221  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxAttAlpha(), 2./m));
222 
223  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetAttLambda(), 20.0));
224  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinAttLambda(), 2.));
225  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxAttLambda(), 3.));
226  }
227 
228  if (zIt->GetName() == "Los Morados") {
229  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinHeight(), 0.*meter));
230  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxHeight(), 1000.*meter));
231  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetVAOD(), 1000. ));
232  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinVAOD(), 10.));
233  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxVAOD(), 10.));
234 
235  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetAttAlpha(), 100./m));
236  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinAttAlpha(), 10./m));
237  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxAttAlpha(), 11./m));
238 
239  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetAttLambda(), 200.));
240  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMinAttLambda(), 20.));
241  CPPUNIT_ASSERT(Verify<CloseTo>(attIt->GetMaxAttLambda(), 21.));
242  }
243  ++iSliceNumber;
244  bogusValue += 10;
245  }
246 
247  } // iterating on zones
248  }
249 
250  void
252  {
253  Detector& theDet = Detector::GetInstance();
254 
255  theDet.Update(1111112); // the second aerosol object !
256 
257  const Atmosphere& theAtm = theDet.GetAtmosphere();
258  const AerosolDB& aerosolDB = theAtm.GetAerosolDB();
259 
260  for (AerosolDB::ZoneIterator zIt = aerosolDB.ZonesBegin();
261  zIt != aerosolDB.ZonesEnd(); ++zIt) {
262 
263  for (AerosolZone::PFSliceIterator pfIt = zIt->PFSlicesBegin();
264  pfIt != zIt->PFSlicesEnd(); ++pfIt) {
265 
266  if (zIt->GetName() == "Coihueco") {
267  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetMinHeight(), 0.*meter));
268  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetMaxHeight(), 10000.*meter));
269 
270  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetF(), 1.0));
271  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFError(), 0.2));
272  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetG(), 2.0));
273  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGError(), 0.3));
274 
275  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFLambda(), 4.));
276  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFLambdaError(), 0.4));
277  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGLambda(), 5.));
278  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGLambdaError(), 0.5));
279  }
280 
281  if (zIt->GetName() == "twilightZone") {
282  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetMinHeight(), 0.*m));
283  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetMaxHeight(), 11000.*m));
284 
285  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetF(), 66.));
286  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFError(), 0.66));
287  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetG(), 77.));
288  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGError(), 0.77));
289 
290  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFLambda(), 88.));
291  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFLambdaError(), 0.88));
292  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGLambda(), 99.));
293  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGLambdaError(), 0.99));
294  }
295 
296  if (zIt->GetName() == "Los Morados") {
297  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetMinHeight(), 0.*m));
298  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetMaxHeight(), 1100.*m));
299 
300  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetF(), 66.));
301  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFError(), 0.66));
302  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetG(), 77.));
303  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGError(), 0.77));
304 
305  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFLambda(), 88.));
306  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetFLambdaError(), 0.88));
307  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGLambda(), 99.));
308  CPPUNIT_ASSERT(Verify<CloseTo>(pfIt->GetGLambdaError(), 0.99));
309  }
310  }
311  }
312  }
313 
314  void
316  {
317  Detector& det = Detector::GetInstance();
318  det.Update(1111112);
319 
321 
322  CPPUNIT_ASSERT(molecular1.GetProfileName() == "weather station");
323  int numZonesMolecular1 = 0;
324  for (MolecularDB::ZoneIterator zIt = molecular1.ZonesBegin();
325  zIt != molecular1.ZonesEnd(); ++zIt) {
326 
327  if (zIt->GetName() == "CLF") {
328  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetNorthing(), 6095769.0*meter));
329  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetEasting(), 469378.0*meter));
330  }
331  ++numZonesMolecular1;
332  }
333 
334  CPPUNIT_ASSERT(Verify<Equal>(numZonesMolecular1, 1));
335 
336  det.Update(2222223);
338 
339  CPPUNIT_ASSERT(molecular2.GetProfileName() == "US-StdA");
340  int numZonesMolecular2 = 0;
341  for (MolecularDB::ZoneIterator zIt = molecular2.ZonesBegin();
342  zIt != molecular2.ZonesEnd(); ++zIt)
343  ++numZonesMolecular2;
344 
345  CPPUNIT_ASSERT(Verify<Equal>(numZonesMolecular2, 2));
346 
347  // test lookup for different profile types
348  //
349  det.Update(3333334);
350 
352  CPPUNIT_ASSERT(m1.GetProfileName() == string("Malargue January model"));
354  CPPUNIT_ASSERT(m2.GetProfileName() == string("Malargue February model"));
356  CPPUNIT_ASSERT(m3.GetProfileName() == string("Malargue March model"));
358  CPPUNIT_ASSERT(m4.GetProfileName() == string("Malargue April model"));
360  CPPUNIT_ASSERT(m5.GetProfileName() == string("Malargue May model"));
362  CPPUNIT_ASSERT(m6.GetProfileName() == string("Malargue June model"));
364  CPPUNIT_ASSERT(m7.GetProfileName() == string("Malargue July model"));
366  CPPUNIT_ASSERT(m8.GetProfileName() == string("Malargue August model"));
368  CPPUNIT_ASSERT(m9.GetProfileName() == string("Malargue September model"));
370  CPPUNIT_ASSERT(m10.GetProfileName() == string("Malargue October model"));
372  CPPUNIT_ASSERT(m11.GetProfileName() == string("Malargue November model"));
374  CPPUNIT_ASSERT(m12.GetProfileName() == string("Malargue December model"));
375  }
376 
377  void
379  {
380  Detector& det = Detector::GetInstance();
381  det.Update(1111112);
383 
384  // iterate over zones
385  for (MolecularDB::ZoneIterator zIt = molecularDB.ZonesBegin();
386  zIt != molecularDB.ZonesEnd(); ++zIt) {
387 
388  [[maybe_unused]] double bogusValue = 0;
389  int iLayerNumber = 1;
390 
391  // iterate over molecular layers for this zone
392  for (MolecularZone::LayerIterator sIt = zIt->LayersBegin();
393  sIt != zIt->LayersEnd(); ++sIt) {
394 
395  if (zIt->GetName() == "Coihueco") {
396 
397  const double dummy = iLayerNumber;
398  const double dummy_err = dummy/10.;
399 
400  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHeight(), dummy*meter));
401  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHeightError(), dummy_err*meter));
402  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetDepth(), dummy*g/cm2));
403  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetDepthError(), dummy_err*g/cm2));
404  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetPressure(), dummy*100.*pascal));
405  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetPressureError(), dummy_err*100.*pascal));
406  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetTemperature(), dummy*kelvin));
407  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetTemperatureError(), dummy_err*kelvin));
408  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHumidity(), dummy*percent));
409  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHumidityError(), dummy_err*percent));
410  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetWindSpeed(), dummy*m/s));
411  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetWindSpeedError(), dummy_err*m/s));
412  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetAirDensity(), dummy*kg/m3));
413  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetAirDensityError(), dummy_err*kg/m3));
414  }
415 
416  if (zIt->GetName() == "twilightZone") {
417  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHeight(), 1.*m));
418  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHeightError(), .1*m));
419  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetDepth(), 2.*g/cm2));
420  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetDepthError(), .2*g/cm2));
421  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetPressure(), 3.*100.*pascal));
422  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetPressureError(), .3*100.*pascal));
423  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetTemperature(), 4.*kelvin));
424  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetTemperatureError(), .4*kelvin));
425  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHumidity(), 5.*percent));
426  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHumidityError(), .5*percent));
427  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetWindSpeed(), 6.*m/s));
428  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetWindSpeedError(), .6*m/s));
429  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetAirDensity(), 7.*kg/m3));
430  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetAirDensityError(), .7*kg/m3));
431  }
432 
433  if (zIt->GetName() == "Los Morados") {
434  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHeight(), 11.*m));
435  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHeightError(), 1.*m));
436  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetDepth(), 12.*g/cm2));
437  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetDepthError(), 2.*g/cm2));
438  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetPressure(), 0.*100.*pascal));
439  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetPressureError(), 0.*100.*pascal));
440  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetTemperature(), 0.*kelvin));
441  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetTemperatureError(), 0.*kelvin));
442  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHumidity(), 0.));
443  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetHumidityError(), 0.));
444  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetWindSpeed(), 0.*m/s));
445  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetWindSpeedError(), 0.*m/s));
446  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetAirDensity(), 0.*kg/m3));
447  CPPUNIT_ASSERT(Verify<CloseTo>(sIt->GetAirDensityError(), 0.*kg/m3));
448  }
449  ++iLayerNumber;
450  bogusValue += 10;
451  }
452  }
453  }
454 
455  void
457  {
458  Detector& det = Detector::GetInstance();
459  det.Update(0);
460  const MolecularDB& molecular1 =
462 
463  int nzones = 0;
464  for (MolecularDB::ZoneIterator zIt = molecular1.ZonesBegin();
465  zIt != molecular1.ZonesEnd(); ++zIt)
466  ++nzones;
467 
468  CPPUNIT_ASSERT(Verify<Equal>(nzones, 0));
469  }
470 
471  void
473  {
474  Detector& det = Detector::GetInstance();
475  det.Update(0);
476 
477  const AerosolDB& aerosolDB = det.GetAtmosphere().GetAerosolDB();
478 
479  // confirm that no zones exist
480 
481  int nzones = 0;
482  for (AerosolDB::ZoneIterator zIt = aerosolDB.ZonesBegin();
483  zIt != aerosolDB.ZonesEnd(); ++zIt)
484  ++nzones;
485 
486  CPPUNIT_ASSERT(Verify<Equal>(nzones, 0));
487  }
488 
489  void
491  {
492  Detector& det = Detector::GetInstance();
493  det.Update(691901819);
494 
495  const OverallQualityDB& overallDB =
497 
498  CPPUNIT_ASSERT(Verify<CloseTo>(overallDB.GetHorizontalUniformity(), 0.9));
499  CPPUNIT_ASSERT(Verify<CloseTo>(overallDB.GetCloudCoverage(), 0.1));
500  CPPUNIT_ASSERT(Verify<CloseTo>(overallDB.GetMinCloudBase(), 1000*meter));
501 
502  det.Update(1383803637);
503  const OverallQualityDB& overallDB2 = det.GetAtmosphere().GetOverallQualityDB();
504 
505  CPPUNIT_ASSERT(Verify<CloseTo>(overallDB2.GetHorizontalUniformity(), 0.8));
506  CPPUNIT_ASSERT(Verify<CloseTo>(overallDB2.GetCloudCoverage(), 0.2));
507  CPPUNIT_ASSERT(Verify<CloseTo>(overallDB2.GetMinCloudBase(), 1000*meter));
508  }
509 
510  void
512  {
513  Detector& det = Detector::GetInstance();
514  det.Update(0);
515 
516  const OverallQualityDB& overallDB =
518  double cc = overallDB.GetCloudCoverage();
519  ++cc; // avoid gcc warning;
520  }
521 
522  void
524  {
525  Detector& det = Detector::GetInstance();
526  det.Update(2222223);
527 
528  const LidarDB& lidar = det.GetAtmosphere().GetLidarDB();
529 
530  int numLidarZones = 0;
531 
532  for (LidarDB::ZoneIterator zIt = lidar.ZonesBegin() ;
533  zIt != lidar.ZonesEnd(); ++zIt) {
534 
535  if (zIt->GetName() == "Coihueco") {
536  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetNorthing(), 6114141.8*meter));
537  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetEasting(), 445346.*meter));
538 
539  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetCloudCoverage(), .2));
540  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetLowestCloudHeight(), 2482*meter));
541  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetLowestCloudThickness(), 449*meter));
542  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetLowestCloudVAOD(), 0.168));
543  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetLidarMaxHeight(), 8000*meter));
544 
545  ++numLidarZones;
546  }
547 
548  if (zIt->GetName() == "myZone") {
549  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetNorthing(), 6083819*meter));
550  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetEasting(), 464292.5*meter));
551 
552  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetCloudCoverage(), .3));
553  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetLowestCloudHeight(), 1000*meter));
554  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetLowestCloudThickness(), 200*meter));
555  CPPUNIT_ASSERT(Verify<CloseTo>(zIt->GetLowestCloudVAOD(), 0.2));
556 
557  ++numLidarZones;
558  }
559  }
560  CPPUNIT_ASSERT(Verify<Equal>(numLidarZones, 2));
561  }
562 
563  void
565  {
566  Detector& det = Detector::GetInstance();
567  det.Update(2222223);
568  const LidarDB& lidarDB = det.GetAtmosphere().GetLidarDB();
569 
570  // iterate over zones
571  for (LidarDB::ZoneIterator zIt = lidarDB.ZonesBegin() ;
572  zIt != lidarDB.ZonesEnd(); ++zIt) {
573 
574  // ref the numbers written by the test program testAtmLidarHandler
575  double bogusValue = 0.;
576  int iSliceNumber = 1;
577 
578  // iterate over VAOD slices for this zone
579  for (LidarZone::VAODSliceIterator vaodIt = zIt->VAODSlicesBegin();
580  vaodIt != zIt->VAODSlicesEnd(); ++vaodIt) {
581 
582  if (zIt->GetName() == "Coihueco") {
583  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetMinHeight(), bogusValue*meter));
584  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetMaxHeight(), (bogusValue+10.)*meter));
585  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetVAOD() , bogusValue+11.));
586  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetMinVAOD() , bogusValue+12.));
587  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetMaxVAOD() , bogusValue+13.));
588  }
589 
590  if (zIt->GetName() == "myZone") {
591  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetMinHeight(), 1.*meter));
592  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetMaxHeight(), 1000.*meter));
593  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetVAOD(), 0.5));
594  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetMinVAOD(), 0.4));
595  CPPUNIT_ASSERT(Verify<CloseTo>(vaodIt->GetMaxVAOD(), 0.6));
596  }
597  ++iSliceNumber;
598  bogusValue += 10;
599  }
600  }
601  }
602 
603 
604  void
606  {
607  Detector& det = Detector::GetInstance();
608 
609  det.Update(691901819);
610  {
611  const fdet::Pixel& pix1 =
612  Detector::GetInstance().GetFDetector().GetEye("Los Leones").GetTelescope(1).GetPixel(1);
613  if (pix1.HasCloudFraction())
614  CPPUNIT_ASSERT(Verify<CloseTo>(double(pix1.GetCloudFraction()), 0.4));
615  }
616 
617  det.Update(691904871);
618  {
619  const fdet::Pixel& pix2 =
620  Detector::GetInstance().GetFDetector().GetEye("Coihueco").GetTelescope(3).GetPixel(3);
621  if (pix2.HasCloudFraction())
622  CPPUNIT_ASSERT(Verify<CloseTo>(double(pix2.GetCloudFraction()), 1.));
623  }
624  }
625 
626  void
628  {
629  Detector& det = Detector::GetInstance();
630 
631  det.Update(1);
632  {
633  const GOESDB& goesdb = det.GetAtmosphere().GetGOESDB();
634  CPPUNIT_ASSERT(Verify<Equal>(goesdb.HasData(0), false));
635  }
636 
637  int t = 692904871;
638  det.Update(t);
639  {
640  const GOESDB& goesDB = det.GetAtmosphere().GetGOESDB();
641 
642  // get a pixel by id
643  for (unsigned int idx = 0; idx <= 100; ++idx) {
644  const double cloudP = goesDB.GetCloudProbability(idx);
645  CPPUNIT_ASSERT(Verify<Equal>(cloudP, int(idx*4/100)/gNCloudProbabilityLevels));
646  }
647 
648  // do it again (now pixels should be cached)
649  for (unsigned int idx = 0; idx <= 100; ++idx) {
650  const double cloudP = goesDB.GetCloudProbability(idx);
651  CPPUNIT_ASSERT(Verify<Equal>(cloudP, int(idx*4/100)/gNCloudProbabilityLevels));
652  }
653  }
654 
655  // reset detector and get a pixel by id (at new time)
656  t += 3700;
657  det.Update(t);
658  {
659  const GOESDB& goesDB = det.GetAtmosphere().GetGOESDB();
660 
661  for (unsigned int idx = 0; idx <= 100; ++idx) {
662  double cloudP = goesDB.GetCloudProbability(idx);
663  CPPUNIT_ASSERT(Verify<Equal>(cloudP, 3./gNCloudProbabilityLevels));
664  }
665  }
666 
667  // get a pixel by location. This uses the same test
668  // data used to fill the GOES validation database.
669  // The code to fill the db is in
670  // OfflineTools/DBTools/Documentation/Examples/WriteToAtmGOESDB
671 
673  const Point pCLF = Point(0, 0, 0, csCLF);
674 
675  vector<int> prob;
676  vector<unsigned int> pixelId;
677 
678  det.Update(700);
679  {
680  const GOESDB& goesDB = det.GetAtmosphere().GetGOESDB();
681 
682  Reader r(TESTGOES, Reader::eNONE);
683  Branch tb = r.GetTopBranch();
684 
685  tb.GetChild("pixelId").GetData(pixelId);
686  tb.GetChild("prob").GetData(prob);
687 
688  for (vector<unsigned int>::iterator i = pixelId.begin(); i != pixelId.end(); ++i) {
689  CPPUNIT_ASSERT(Verify<Equal>(prob[*i]/gNCloudProbabilityLevels, goesDB.GetCloudProbability(*i)));
690  }
691 
692  // get a pixel over the CLF (to confirm I have the basic code correct in
693  // GetCloudProbability(Point) - that is, there should be some cloud data
694  // over the CLF
695 
696  CPPUNIT_ASSERT(Verify<Equal>(goesDB.GetCloudProbability(pCLF), 2./gNCloudProbabilityLevels));
697  }
698 
699  // starting from Malargue point and the magic numbers in GetCloudProbability(Point)
700  // step through all the pixels and confirm I read back the numbers in the test file
701 
702  // new db so we can check both the cached and the not-yet cached
703  // versions of GetCloudProbability
704  det.Update(701);
705  {
706  const GOESDB& goesDB = det.GetAtmosphere().GetGOESDB();
707 
708  // magic numbers to compute pixel id
709  const int fgNumEasting = 30; // pixels in easting
710  const double fgStartEasting = 553.2; // start of easting coverage
711  const double fgStartNorthing = 9736.34; // start of northing coverage
712  const double fgDeltaEasting = 2394.9; // size of pixel in easting
713  const double fgDeltaNorthing = 5493.03; // size of pixel in northing
714 
715  // get site coordinate sytem (usually Malargue)
716  CoordinateSystemPtr csDetectorSite = det.GetSiteCoordinateSystem();
717 
718  int northPosition = 0;
719  for (vector<unsigned int>::iterator i = pixelId.begin(); i != pixelId.end(); ++i) {
720  const double eastPosition = *i % fgNumEasting;
721 
722  // compute a position x,y somewhere in the current pixel.
723  // the fgDeltaEasting/(something) at the end is just a little margin to be sure
724  // we are inside the pixel. Note from Figure 2.1 in GAP 2011_091, the east pixels
725  // shift by 1 per 6 north pixels. So for x (below), fgDeltaEasting/6.1 should
726  // get us into the pixel without wandering off into the wrong pixel as we move
727  // to the north.
728  const double x = eastPosition*fgDeltaEasting + fgStartEasting + fgDeltaEasting/6.1;
729  const double y = northPosition*fgDeltaNorthing + fgStartNorthing + fgDeltaNorthing/2;
730  const Point p(x, y, 0, csDetectorSite);
731 
732  const double cloudP4 = goesDB.GetCloudProbability(p);
733  const double cloudP3 = goesDB.GetCloudProbability(p);
734 
735  CPPUNIT_ASSERT(Verify<Equal>(cloudP4, prob[*i]/gNCloudProbabilityLevels));
736  CPPUNIT_ASSERT(Verify<Equal>(cloudP3, prob[*i]/gNCloudProbabilityLevels));
737 
738  if (eastPosition == fgNumEasting - 1) {
739  northPosition += 1;
740  }
741  }
742 
743  // test maximum cloud probability along line of sight between CLF and XLF
744  // first calculate it by stepping between the two positions, then use
745  // GOESDB::GetMaximumCloudProbability(Point, Point)
746  const Point pXLF(0, 0, 0, CoordinateSystemRegistry::Get("XLF"));
747  const Vector clfToXLF = Normalized(pXLF - pCLF);
748  const double distance = (pXLF - pCLF).GetMag();
749  double currDistance = 0;
750  double maxPropBetweenCLFandXLF = 0;
751  while (currDistance < distance) {
752  const double currProb = goesDB.GetCloudProbability(pCLF + currDistance * clfToXLF);
753  if (currProb > maxPropBetweenCLFandXLF)
754  maxPropBetweenCLFandXLF = currProb;
755  currDistance += 10*m;
756  }
757 
758  const double cloudProbCLFXLF = goesDB.GetMaximumCloudProbability(pXLF, pCLF);
759  CPPUNIT_ASSERT(Verify<Equal>(cloudProbCLFXLF, maxPropBetweenCLFandXLF));
760 
761  // order of points shound not matter
762  const double cloudProbXLFCLF = goesDB.GetMaximumCloudProbability(pCLF, pXLF);
763  CPPUNIT_ASSERT(Verify<Equal>(cloudProbCLFXLF, cloudProbXLFCLF));
764  }
765  }
766 
767  void
769  {
770  Detector& det = Detector::GetInstance();
771 
772  det.Update(1);
773  const GOESDB& goesdb = det.GetAtmosphere().GetGOESDB();
774  goesdb.GetCloudProbability(0);
775  }
776 
777  void
779  {
780  Detector& det = Detector::GetInstance();
781 
782  det.Update(692904871);
783  const GOESDB& goesdb = det.GetAtmosphere().GetGOESDB();
784  goesdb.GetCloudProbability(12345);
785  }
786 
787  void
789  {
790  // confirm there is no cloud data over the malargue point
791  // (there is no GOES pixel in the database for that point)
792 
793  Detector& det = Detector::GetInstance();
794  det.Update(700);
795  const GOESDB& goesdb = det.GetAtmosphere().GetGOESDB();
796 
797  // get site coordinate sytem (usually Malargue)
798  CoordinateSystemPtr csDetectorSite = det.GetSiteCoordinateSystem();
799  Point pCLF = Point(0, 0, 0, csDetectorSite);
800 
801  goesdb.GetCloudProbability(pCLF);
802  }
803 
804 };
805 
806 
808 
809 
810 // Configure (x)emacs for this file ...
811 // Local Variables:
812 // mode: c++
813 // compile-command: "make -C .. -k testSEvent"
814 // End:
August Malargue model.
Definition: MolecularIds.h:29
boost::transform_iterator< InternalZoneFunctor, InternalZoneIterator, const LidarZone & > ZoneIterator
ZoneIterator returns a pointer to an LidarZone.
Definition: LidarDB.h:45
ZoneIterator ZonesBegin() const
Beginning of the collection of valid Zones.
Definition: AerosolDB.h:36
June Malargue model.
Definition: MolecularIds.h:25
void Update(const utl::TimeStamp &time, const bool invData=true, const bool invComp=true, const bool forceRadio=false)
Update detector: deletes currently constructed stations and sets new time.
Definition: Detector.cc:179
Top of the interface to Atmosphere information.
Point object.
Definition: Point.h:32
boost::transform_iterator< InternalZoneFunctor, InternalZoneIterator, const MolecularZone & > ZoneIterator
ZoneIterator returns a pointer to a MolecularZone.
Definition: MolecularDB.h:52
March Malargue model.
Definition: MolecularIds.h:19
Detector description interface for GOES cloud data.
Definition: GOESDB.h:29
const OverallQualityDB & GetOverallQualityDB() const
low-level interface to portion of the database summarizing overall quality
bool HasCloudFraction() const
May Malargue model.
Definition: MolecularIds.h:23
October Malargue model.
Definition: MolecularIds.h:33
ZoneIterator ZonesEnd() const
End of the collection of valid Zones.
Definition: LidarDB.h:52
ZoneIterator ZonesEnd() const
End of the collection of valid Zones.
Definition: MolecularDB.h:59
const double meter
Definition: GalacticUnits.h:29
constexpr double percent
Definition: AugerUnits.h:283
Traditional name.
Definition: Verbosity.h:17
Detector description interface for data in the Atm_Molecular database.
Definition: MolecularDB.h:29
from weather station
Definition: MolecularIds.h:11
constexpr double m2
Definition: AugerUnits.h:122
Base class for exceptions trying to access non-existing components.
November Malargue model.
Definition: MolecularIds.h:35
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
utl::CoordinateSystemPtr GetSiteCoordinateSystem() const
Get the coordinate system for the site.
Definition: Detector.h:137
July Malargue model.
Definition: MolecularIds.h:27
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
const Pixel & GetPixel(const unsigned int pixelId) const
Get Pixel by id, throw utl::NonExistentComponentException if n.a.
Branch GetTopBranch() const
Get the top Branch (represents same entity as document node)
Definition: Reader.h:45
boost::indirect_iterator< InternalVAODSliceIterator, const VAODSlice & > VAODSliceIterator
VAODSlice iterator returns a pointer to the attenuation data slice for this zone. ...
Definition: LidarZone.h:50
const atm::Atmosphere & GetAtmosphere() const
Definition: Detector.h:113
boost::transform_iterator< InternalZoneFunctor, InternalZoneIterator, const AerosolZone & > ZoneIterator
ZoneIterator returns a pointer to an AerosolZone.
Definition: AerosolDB.h:33
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Utility for parsing XML files.
Definition: Reader.h:25
Class representing a document branch.
Definition: Branch.h:107
Exception to use in case requested data not found in the database with detailed printout.
January Malargue model.
Definition: MolecularIds.h:15
Class for loading and storing a collection of aerosol data.
Definition: AerosolDB.h:14
constexpr double s
Definition: AugerUnits.h:163
double GetCloudProbability(const unsigned int pixelId) const
Get cloud probability from the pixel id.
Definition: GOESDB.cc:118
constexpr double pascal
Definition: AugerUnits.h:212
const GOESDB & GetGOESDB() const
low-level interface to the cloud information from the GOES database
constexpr double m3
Definition: AugerUnits.h:123
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
double GetMaximumCloudProbability(const utl::Point &pos1, const utl::Point &pos2) const
Get max. cloud probability along line of sight between pos1 and pos2.
Definition: GOESDB.cc:272
const MolecularDB & GetMolecularDB(const MolecularIds::ProfileId &id) const
Low-level interface to portion of the database with molecular information.
constexpr double g
Definition: AugerUnits.h:200
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
double GetMinCloudBase() const
const Telescope & GetTelescope() const
Access the telescope this Pixel belongs to.
AxialVector Normalized(const AxialVector &v)
Definition: AxialVector.h:81
constexpr double kelvin
Definition: AugerUnits.h:259
boost::indirect_iterator< InternalAttSliceIterator, const AttSlice & > AttSliceIterator
AttSlice iterator returns a pointer to the attenuation data slice for this zone.
Definition: AerosolZone.h:43
ZoneIterator ZonesBegin() const
Beginning of the collection of valid Zones.
Definition: MolecularDB.h:55
std::string GetProfileName() const
Return the name of profile type for this MolecularDB.
Definition: MolecularDB.h:47
December Malargue model.
Definition: MolecularIds.h:37
September Malargue model.
Definition: MolecularIds.h:31
float GetCloudFraction() const
how much of pixel is obscured by clouds
boost::indirect_iterator< InternalLayerIterator, const MolecularLayer & > LayerIterator
Layer iterator returns a pointer to the molecular data slice for this zone.
Definition: MolecularZone.h:43
Detector description interface for LidarDB-realted data.
Definition: LidarDB.h:26
ZoneIterator ZonesEnd() const
End of the collection of valid Zones.
Definition: AerosolDB.h:40
const AerosolDB & GetAerosolDB() const
Low-level interface to portion of the database with aerosol information.
Description of a pixel.
Vector object.
Definition: Vector.h:30
double GetCloudCoverage() const
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
bool HasData(const unsigned int pixelId) const
Check if cloud probability data exists for a given pixel at the current time.
Definition: GOESDB.cc:148
US standard atmosphere.
Definition: MolecularIds.h:41
Access to database describing overall atmospheric quality.
boost::indirect_iterator< InternalPFSliceIterator, const PFSlice & > PFSliceIterator
PFSlice Iterator returns a pointer to the phase function data slice for this zone.
Definition: AerosolZone.h:53
constexpr double m
Definition: AugerUnits.h:121
February Malargue model.
Definition: MolecularIds.h:17
April Malargue model.
Definition: MolecularIds.h:21
const LidarDB & GetLidarDB() const
low-level interface to portion of the database with cloud data from lidar analysis ...
constexpr double kg
Definition: AugerUnits.h:199
double GetHorizontalUniformity() const
ZoneIterator ZonesBegin() const
Beginning of the collection of valid Zones.
Definition: LidarDB.h:48
constexpr double cm2
Definition: AugerUnits.h:118

, generated on Tue Sep 26 2023.