testMonthlyAvgDBProfileModel.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 #include <atm/MonthlyAvgDBProfileModel.h>
18 
19 #include <atm/RadiosondeDBProfileModel.h>
20 
21 #include <fwk/CentralConfig.h>
22 
23 #include <utl/TimeStamp.h>
24 #include <utl/UTCDateTime.h>
25 #include <utl/ErrorLogger.h>
26 
27 #include <cppunit/extensions/HelperMacros.h>
28 #include <tst/Verify.h>
29 
30 #include <iostream>
31 
32 using namespace std;
33 using namespace det;
34 using namespace atm;
35 using namespace fwk;
36 using namespace utl;
37 using namespace tst;
38 
39 
40 class testMonthlyAvgDBProfileModel : public CppUnit::TestFixture {
41 
42  CPPUNIT_TEST_SUITE(testMonthlyAvgDBProfileModel);
43 
44  CPPUNIT_TEST(testCheckUpdates);
45  CPPUNIT_TEST(testHasData);
46  CPPUNIT_TEST_EXCEPTION(testNoDataForTimeStamp, NoDataForModelException);
47  // CPPUNIT_TEST_EXCEPTION(testOutOfBoundsHeightVsDepth, OutOfBoundException);
48  CPPUNIT_TEST_EXCEPTION(testOutOfBoundsDepthVsHeight, OutOfBoundException);
49  CPPUNIT_TEST_EXCEPTION(testOutOfBoundsTemperatureVsHeight, OutOfBoundException);
50 
51  CPPUNIT_TEST(testEvaluateDepthVsHeight);
52  CPPUNIT_TEST(testEvaluateHeightVsDepth);
53  CPPUNIT_TEST(testEvaluateTemperatureVsHeight);
54  CPPUNIT_TEST(testEvaluateDensityVsHeight);
55  CPPUNIT_TEST(testEvaluateRefractionIndexVsHeight);
56 
57  CPPUNIT_TEST_SUITE_END();
58 
59 private:
60 
61 public:
62 
63  void setUp()
64  {
65  CentralConfig::GetInstance(BOOTSTRAPFILE);
66  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
67  }
68 
69  void tearDown()
70  {
71  }
72 
73  void testHasData()
74  {
75  Detector::GetInstance().Update(TimeStamp());
76  MonthlyAvgDBProfileModel modelWithoutData;
77  modelWithoutData.Init();
78  CPPUNIT_ASSERT(Verify<Equal>(modelWithoutData.HasData(), false));
79 
80  Detector::GetInstance().Update(UTCDateTime(2005, 1, 1).GetTimeStamp());
81  MonthlyAvgDBProfileModel modelWithData;
82  modelWithData.Init();
83  CPPUNIT_ASSERT(Verify<Equal>(modelWithData.HasData(), true));
84  }
85 
87  {
88  Detector::GetInstance().Update(TimeStamp(1111112));
89  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
90  ProfileResult prof = theAtm.EvaluateDepthVsHeight();
91 
92  CPPUNIT_ASSERT(Verify<CloseTo>(prof.Y(0.5*km), 973.732*g/cm2, 1e-3));
93 
94  CPPUNIT_ASSERT(Verify<CloseTo>(prof.Y(11.*km), 230.918*g/cm2, 1e-3));
95 
96  CPPUNIT_ASSERT(Verify<CloseTo>(prof.Y(26.5*km), 20.3484*g/cm2, 1e-3));
97 
98  CPPUNIT_ASSERT(Verify<CloseTo>(prof.Y(0.), 1033.93*g/cm2, 1e-3));
99 
100  CPPUNIT_ASSERT(Verify<CloseTo>(prof.MinX(), 0.0*m));
101 
102  // Tables extended 'by hand' in MonthlyAvgDBProfileModel at request of
103  // Bruce, Bianca et al
104  CPPUNIT_ASSERT(Verify<CloseTo>(prof.MaxX(), 100.*km));
105 
106 // Try for heights above range officially defined in DB. TheMonthlyAvgDBPRofileModel
107 // extends height vs depth and depth vs height to heights of 100km
108 //
109  CPPUNIT_ASSERT(Verify<CloseTo>(prof.Y(100.*km), 0.001*g/cm2));
110  }
111 
113  {
114  Detector::GetInstance().Update(TimeStamp(1111112));
115  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
116  ProfileResult heightVsDepth = theAtm.EvaluateHeightVsDepth();
117 
118  CPPUNIT_ASSERT(Verify<CloseTo>(heightVsDepth.Y(20.3484*g/cm2), 26.5*km, 1e-3));
119 
120  CPPUNIT_ASSERT(Verify<CloseTo>(heightVsDepth.Y(973.732*g/cm2), 0.5*km, 1e-3));
121 
122  CPPUNIT_ASSERT(Verify<CloseTo>(heightVsDepth.Y(230.918*g/cm2), 11.*km, 1e-3));
123 
124  ProfileResult depthVsHeight = theAtm.EvaluateDepthVsHeight();
125  CPPUNIT_ASSERT(Verify<CloseTo>(
126  depthVsHeight.MaxX(), heightVsDepth.Y(heightVsDepth.MinX())
127  ));
128  CPPUNIT_ASSERT(Verify<CloseTo>(
129  depthVsHeight.MinX(), heightVsDepth.Y(heightVsDepth.MaxX())
130  ));
131 
132  // Try for heights above range officially defined in DB.
133  // The MonthlyAvgDBPRofileModel extends height vs depth and depth vs height
134  // to heights of 100km
135  CPPUNIT_ASSERT(Verify<CloseTo>(heightVsDepth.Y(0.001*g/cm2), 100.*km));
136  }
137 
139  {
140  Detector::GetInstance().Update(TimeStamp(1111112));
141  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
142  ProfileResult tempVsHeight = theAtm.EvaluateTemperatureVsHeight();
143 
144  CPPUNIT_ASSERT(Verify<CloseTo>(tempVsHeight.Y(0.), 288.15*kelvin, 1e-3));
145 
146  CPPUNIT_ASSERT(Verify<CloseTo>(tempVsHeight.Y(11.5*km), 216.65*kelvin, 1e-3));
147 
148  CPPUNIT_ASSERT(Verify<CloseTo>( tempVsHeight.Y(29.5*km), 226.15*kelvin, 1e-3));
149  }
150 
152  {
153  Detector::GetInstance().Update(TimeStamp(1111112));
154  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
155  ProfileResult densityVsHeight = theAtm.EvaluateDensityVsHeight();
156 
157  CPPUNIT_ASSERT(Verify<CloseTo>(densityVsHeight.Y(0.), 1.23*kg/m3));
158 
159  CPPUNIT_ASSERT(Verify<CloseTo>(densityVsHeight.Y(11.5*km), 0.336458*kg/m3));
160 
161  CPPUNIT_ASSERT(Verify<CloseTo>(densityVsHeight.Y(29.*km), 0.021*kg/m3));
162  }
163 
165  {
166  Detector::GetInstance().Update(TimeStamp(1111112));
167  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
168  ProfileResult refracVsHeight = theAtm.EvaluateRefractionIndexVsHeight();
169 
170  CPPUNIT_ASSERT(Verify<CloseTo>(refracVsHeight.Y(0.), 1.00029, 1.e-3));
171  }
172 
173  // deprecated
174 
176  {
177  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
178 
179  Detector::GetInstance().Update(UTCDateTime(2005, 1, 2, 0, 0, 0).GetTimeStamp());
180  CPPUNIT_ASSERT(Verify<CloseTo>(
181  theAtm.EvaluateTemperatureVsHeight().Y(1*km), 281.65*kelvin, 1e-3));
182 
183  Detector::GetInstance().Update(UTCDateTime(2005, 4, 2, 0, 0, 0).GetTimeStamp());
184  CPPUNIT_ASSERT(Verify<CloseTo>(
185  theAtm.EvaluateTemperatureVsHeight().Y(1*km), 2.*281.65*kelvin, 1e-3));
186  }
187 
189  {
190  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
191  Detector::GetInstance().Update(TimeStamp());
192  theAtm.EvaluateTemperatureVsHeight().Y(1*km);
193  }
194 
196  {
197  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
198  Detector::GetInstance().Update(UTCDateTime(2005, 1, 2, 0, 0, 0).GetTimeStamp());
199  ProfileResult heightVsDepth = theAtm.EvaluateHeightVsDepth();
200 
201  // extended to 100 km by MonthlyAvgDBProfileModel
202  heightVsDepth.Y(0.*g/cm2);
203  }
204 
206  {
207  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
208  Detector::GetInstance().Update(UTCDateTime(2005, 1, 2, 0, 0, 0).GetTimeStamp());
209  ProfileResult depthVsHeight = theAtm.EvaluateDepthVsHeight();
210 
211  // extended to 100 km by MonthlyAvgDBProfileModel
212  depthVsHeight.Y(500.*km);
213  }
214 
216  {
217  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
218  Detector::GetInstance().Update(UTCDateTime(2005, 1, 2, 0, 0, 0).GetTimeStamp());
219  ProfileResult temperatureVsHeight = theAtm.EvaluateTemperatureVsHeight();
220 
221  // extended to 100 km by MonthlyAvgDBProfileModel
222  temperatureVsHeight.Y(500.*km);
223  }
224 
225 };
226 
228 
Molecular profile information from database monthly averages.
Top of the interface to Atmosphere information.
const atm::ProfileResult & EvaluateDensityVsHeight() const
Tabulated function giving Y=density as a function of X=height.
Traditional name.
Definition: Verbosity.h:17
virtual bool HasData() const override
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.
Exception for reporting variable out of valid range.
Class describing the Atmospheric profile.
Definition: ProfileResult.h:25
constexpr double m3
Definition: AugerUnits.h:123
const atm::ProfileResult & EvaluateDepthVsHeight() const
Tabulated function giving Y=depth as a function of X=height.
const double km
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.
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
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.
constexpr double kg
Definition: AugerUnits.h:199
constexpr double cm2
Definition: AugerUnits.h:118

, generated on Tue Sep 26 2023.