testRadiosondeDBProfileModel.cc
Go to the documentation of this file.
1 
10 #include <det/Detector.h>
11 #include <atm/AerosolDB.h>
12 #include <atm/AerosolZone.h>
13 #include <atm/AttSlice.h>
14 #include <atm/PFSlice.h>
15 #include <atm/MolecularZone.h>
16 #include <atm/ProfileResult.h>
17 
18 #include <atm/RadiosondeDBProfileModel.h>
19 
20 #include <fwk/CentralConfig.h>
21 
22 #include <utl/TimeStamp.h>
23 #include <utl/ErrorLogger.h>
24 
25 #include <cppunit/extensions/HelperMacros.h>
26 #include <tst/Verify.h>
27 
28 #include <iostream>
29 
30 using namespace std;
31 using namespace det;
32 using namespace atm;
33 using namespace fwk;
34 using namespace utl;
35 using namespace tst;
36 
37 
38 class testRadiosondeDBProfileModel : public CppUnit::TestFixture{
39 
40  CPPUNIT_TEST_SUITE(testRadiosondeDBProfileModel);
41 
42  CPPUNIT_TEST(testHasData);
43  CPPUNIT_TEST_EXCEPTION(testNoDataForTimeStamp, NoDataForModelException);
44 
45  CPPUNIT_TEST(testEvaluateDepthVsHeight);
46  CPPUNIT_TEST(testEvaluateHeightVsDepth);
47  CPPUNIT_TEST(testEvaluateTemperatureVsHeight);
48  CPPUNIT_TEST(testEvaluateDensityVsHeight);
49  CPPUNIT_TEST(testEvaluateRefractionIndexVsHeight);
50  CPPUNIT_TEST(testNoDataMultipleCalls); // checks bug 456
51 
52  CPPUNIT_TEST_SUITE_END();
53 
54 private:
55 
56 public:
57 
58  void setUp(){
59  //CentralConfig* theCC =
60  CentralConfig::GetInstance(BOOTSTRAPFILE);
61  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
62  }
63 
64  void tearDown(){
65  }
66 
67  void testHasData() {
68 
69  Detector::GetInstance().Update(TimeStamp());
70  RadiosondeDBProfileModel modelWithoutData;
71  modelWithoutData.Init();
72  CPPUNIT_ASSERT(Verify<Equal>(modelWithoutData.HasData(), false));
73 
74  Detector::GetInstance().Update(TimeStamp(1111112));
75  RadiosondeDBProfileModel modelWithData;
76  modelWithData.Init();
77  CPPUNIT_ASSERT(Verify<Equal>(modelWithData.HasData(), true));
78 
79  }
80 
82 
83  Detector::GetInstance().Update(TimeStamp(1111112));
84  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
85  ProfileResult depthVsHeight = theAtm.EvaluateDepthVsHeight();
86 
87  CPPUNIT_ASSERT(Verify<CloseTo>( depthVsHeight.Y(500.*meter), 973.732*gram/cm/cm, 1e-3));
88  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateDepthError(500.*meter), 973.732*gram/cm/cm / 10., 1e-3));
89 
90  CPPUNIT_ASSERT(Verify<CloseTo>( depthVsHeight.Y(11000.*meter), 230.918*gram/cm/cm, 1e-3));
91  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateDepthError(11000.*meter), 230.918*gram/cm/cm / 10., 1e-3));
92 
93  CPPUNIT_ASSERT(Verify<CloseTo>( depthVsHeight.Y(26500.*meter), 20.3484*gram/cm/cm, 1e-3));
94  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateDepthError(26500.*meter), 20.3484*gram/cm/cm / 10., 1e-2));
95 
96  CPPUNIT_ASSERT(Verify<CloseTo>( depthVsHeight.Y(0.), 1033.93*gram/cm/cm, 1e-3));
97 // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateDepthError(0.), 1033.93*gram/cm/cm / 10., 1e-3));
98 
99 
100  CPPUNIT_ASSERT(Verify<CloseTo>( depthVsHeight.Y(500.*meter),
101  depthVsHeight.Y( theAtm.EvaluateHeightVsDepth().Y( depthVsHeight.Y(500.*m))), 1e-3));
102 
103  ProfileResult heightVsDepth = theAtm.EvaluateHeightVsDepth();
104  CPPUNIT_ASSERT(Verify<CloseTo>( depthVsHeight.MaxX(), heightVsDepth.Y(heightVsDepth.MinX()) ));
105  CPPUNIT_ASSERT(Verify<CloseTo>( depthVsHeight.MinX(), heightVsDepth.Y(heightVsDepth.MaxX()) ));
106 
107  }
108 
110 
111  Detector::GetInstance().Update(TimeStamp(1111112));
112  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
113  ProfileResult heightVsDepth = theAtm.EvaluateHeightVsDepth();
114 
115 
116  CPPUNIT_ASSERT(Verify<CloseTo>( heightVsDepth.Y(20.3484*gram/cm/cm), 26500.*meter, 1e-3));
117 // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateHeightError(20.3484*gram/cm/cm),
118 // theAtm.EvaluateHeight(20.3484*gram/cm/cm)/10., 1e-3));
119 
120  CPPUNIT_ASSERT(Verify<CloseTo>( heightVsDepth.Y(973.732*gram/cm/cm), 500.*meter, 1e-3));
121 // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateHeightError(973.732*gram/cm/cm),
122 // theAtm.EvaluateHeight(973.732*gram/cm/cm)/10., 1e-3));
123 
124  CPPUNIT_ASSERT(Verify<CloseTo>( heightVsDepth.Y(230.918*gram/cm/cm), 11000.*meter, 1e-3));
125 // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateHeightError(230.918*gram/cm/cm),
126 // theAtm.EvaluateHeight(230.918*gram/cm/cm)/10., 1e-3));
127 
128  }
129 
130 
132 
133  Detector::GetInstance().Update(TimeStamp(1111112));
134  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
135  ProfileResult temperatureVsHeight = theAtm.EvaluateTemperatureVsHeight();
136 
137  CPPUNIT_ASSERT(Verify<CloseTo>( temperatureVsHeight.Y(0.), 288.15*kelvin, 1e-3));
138  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateTemperatureError(0.),288.15*kelvin / 10., 1e-3));
139 
140  CPPUNIT_ASSERT(Verify<CloseTo>( temperatureVsHeight.Y(11500.), 216.65*kelvin, 1e-3));
141  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateTemperatureError(11500.), 216.65*kelvin/10., 1e-3));
142 
143  CPPUNIT_ASSERT(Verify<CloseTo>( temperatureVsHeight.Y(29500.), 226.15*kelvin, 1e-3));
144  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateTemperatureError(29500.), 226.15*kelvin/10., 1e-3));
145  }
146 
147 
149 
150  Detector::GetInstance().Update(TimeStamp(1111112));
151  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
152  ProfileResult densityVsHeight = theAtm.EvaluateDensityVsHeight();
153 
154  CPPUNIT_ASSERT(Verify<CloseTo>( densityVsHeight.Y(0.), 1.23e-3*g/cm/cm/cm));
155  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateDensityError(0.), 1.23e-3*g/cm/cm/cm / 10.));
156 
157  CPPUNIT_ASSERT(Verify<CloseTo>( densityVsHeight.Y(11500.*meter), 3.36458e-4*g/cm/cm/cm));
158  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateDensityError(11500.*meter), 3.36458e-4*g/cm/cm/cm / 10., 1.e-2));
159 
160  CPPUNIT_ASSERT(Verify<CloseTo>( densityVsHeight.Y(29000.*meter), 2.10e-5*g/cm/cm/cm));
161  // CPPUNIT_ASSERT(Verify<CloseTo>( theAtm.EvaluateDensityError(29000.*meter), 2.10e-5*g/cm/cm/cm / 10.));
162 
163  }
164 
166 
167  Detector::GetInstance().Update(TimeStamp(1111112));
168  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
169  ProfileResult riVsHeight = theAtm.EvaluateRefractionIndexVsHeight();
170 
171  CPPUNIT_ASSERT(Verify<CloseTo>( riVsHeight.Y(0.), 1.00029, 1e-3));
172  }
173 
175  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
176  Detector::GetInstance().Update(TimeStamp());
178  }
179 
181  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
182  Detector::GetInstance().Update(TimeStamp(123));
183 
184  int numExceptions = 0;
185  for (int i=0 ; i<5 ; i++) {
186  try {
188  } catch (NoDataForModelException& ex) {
189  numExceptions++;
190  }
191  }
192  CPPUNIT_ASSERT(Verify<Equal>(numExceptions, 5));
193  }
194 };
195 
197 
198 
199 // Configure (x)emacs for this file ...
200 // Local Variables:
201 // mode:c++
202 // compile-command: "make -C .. -k"
203 // End:
Top of the interface to Atmosphere information.
Molecular profile taken from radiosonde database.
const atm::ProfileResult & EvaluateDensityVsHeight() const
Tabulated function giving Y=density as a function of X=height.
const double meter
Definition: GalacticUnits.h:29
Traditional name.
Definition: Verbosity.h:17
bool HasData() const
True if a data source is for the given model.
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
double Y(const double x) const
Get the Y value (coordinate) for given X (ordinate)
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
Exception to use in a atmosphere model cannot find data it needs.
Class describing the Atmospheric profile.
Definition: ProfileResult.h:25
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
constexpr double g
Definition: AugerUnits.h:200
constexpr double kelvin
Definition: AugerUnits.h:259
double MinX() const
Return the minimum value for X (ordinate) stored in the profile.
constexpr double cm
Definition: AugerUnits.h:117
const atm::ProfileResult & EvaluateHeightVsDepth() const
Tabulated function giving Y=height as a function of X=depth.
const atm::ProfileResult & EvaluateRefractionIndexVsHeight() const
Tabulated function giving Y=refraction index as a function of X=height.
constexpr double m
Definition: AugerUnits.h:121
constexpr double gram
Definition: AugerUnits.h:195
const atm::ProfileResult & EvaluateTemperatureVsHeight() const
Tabulated function giving Y=temperature as a function of X=height.
double MaxX() const
Return the maximum value for X (ordinate) stored in the profile.

, generated on Tue Sep 26 2023.