ParametricXMLProfileModel.cc
Go to the documentation of this file.
1 
11 #include <utl/Reader.h>
12 #include <utl/ErrorLogger.h>
13 #include <utl/AugerException.h>
14 #include <utl/AugerUnits.h>
15 #include <utl/MathConstants.h>
16 #include <utl/TabulatedFunction.h>
17 #include <utl/PhysicalConstants.h>
18 #include <utl/PhysicalFunctions.h>
19 
20 #include <fwk/CentralConfig.h>
21 
22 #include <atm/ProfileResult.h>
23 #include <atm/ParametricXMLProfileModel.h>
24 
25 #include <iostream>
26 #include <limits>
27 #include <string>
28 #include <sstream>
29 #include <vector>
30 
31 using namespace atm;
32 using namespace utl;
33 using namespace std;
34 using namespace fwk;
35 
37 }
38 
40 }
41 
43 
44  CentralConfig* cc = CentralConfig::GetInstance();
45 
46  Branch topB =
47  cc->GetTopBranch("ParametricXMLProfileModel");
48 
49  vector<double> pressure;
50  vector<double> height;
51  vector<double> density;
52  vector<double> temperature;
53  vector<double> humidity;
54 
55  topB.GetChild("height").GetData(height);
56  topB.GetChild("pressure").GetData(pressure);
57  topB.GetChild("density").GetData(density);
58  topB.GetChild("temperature").GetData(temperature);
59  topB.GetChild("humidity").GetData(humidity);
60 
61  if ((height.size()!=pressure.size())||
62  (height.size()!=density.size())||
63  (height.size()!=temperature.size())||
64  (height.size()!=humidity.size()))
65  {
66  ERROR("Dimensions of the atmosphere profile vectors are different. ");
68  }
69 
70  // make tabulated functions
71  TabulatedFunctionErrors tabRIVsHeight;
72  TabulatedFunctionErrors tabLogPressureVsHeight;
73  TabulatedFunctionErrors tabLogVaporPressureVsHeight;
74  TabulatedFunctionErrors tabTemperatureVsHeight;
75  TabulatedFunctionErrors tabLogDepthVsHeight;
76  TabulatedFunctionErrors tabLogDensityVsHeight;
77  TabulatedFunctionErrors tabHeightVsLogDepth;
78 
79  const double minLog = kLn10 * numeric_limits<double>::min_exponent10;
80 
81  for (unsigned int i = 0 ; i < height.size() ; i++) {
82 
83  tabLogDepthVsHeight.PushBack(
84  height[i], 0.,
85  log(pressure[i]*(kOverburdenSeaLevel/atmosphere)), minLog);
86 
87  // Move calculation of refraction index to base class once
88  // TabulatedFunction is fixed
89  const double refracIndex = utl::RefractionIndex::LorentzLorentz(pressure[i]*(kOverburdenSeaLevel/atmosphere));
90  tabRIVsHeight.PushBack(height[i], 0., refracIndex, 0.);
91 
92  tabLogPressureVsHeight.PushBack(height[i], 0., log(pressure[i]), minLog);
93 
94  tabLogVaporPressureVsHeight.PushBack(height[i], 0.,
95  (humidity[i] > 0.) ? log(humidity[i]) : minLog, minLog);
96 
97  tabTemperatureVsHeight.PushBack(height[i], 0., temperature[i], 0.);
98 
99  tabLogDensityVsHeight.PushBack(height[i], 0., log(density[i]), minLog);
100  }
101 
102  // have to fill tabulated functions in ascending order or ordinate (tabulated function should be fixed..)
103  for (int i = height.size()-1 ; i >= 0 ; i--) {
104  tabHeightVsLogDepth.PushBack(
105  log(pressure[i]*(kOverburdenSeaLevel/atmosphere)), minLog, height[i], 0.);
106  }
107 
108  INFO("CREATING PROFILE RESULTS");
109 
110  // create profile results
112  tabLogPressureVsHeight, ProfileResult::eLinear, ProfileResult::eLog);
113 
115  tabLogVaporPressureVsHeight, ProfileResult::eLinear, ProfileResult::eLog);
116 
118  tabTemperatureVsHeight, ProfileResult::eLinear, ProfileResult::eLinear);
119 
121  tabLogDensityVsHeight, ProfileResult::eLinear, ProfileResult::eLog);
122 
124  tabLogDepthVsHeight, ProfileResult::eLinear, ProfileResult::eLog);
125 
127  tabHeightVsLogDepth, ProfileResult::eLog, ProfileResult::eLinear);
128 
131 
132  INFO("DONE CREATING PROFILE RESULTS");
133 
134 }
135 
136 const ProfileResult&
138 {
139  return *fTabLogPressureVsHeight;
140 }
141 
142 const ProfileResult&
144 {
146 }
147 
148 const ProfileResult&
150 {
151  return *fTabTemperatureVsHeight;
152 }
153 
154 const ProfileResult&
156 {
157  return *fTabLogDensityVsHeight;
158 }
159 
160 const ProfileResult&
162 {
163  return *fTabLogDepthVsHeight;
164 }
165 
166 const ProfileResult&
168 {
169  return *fTabHeightVsLogDepth;
170 }
171 
172 const ProfileResult&
174 {
175  return *fTabRIVsHeight;
176 }
177 
178 
179 // Configure (x)emacs for this file ...
180 // Local Variables:
181 // mode:c++
182 // compile-command: "make -C .. -k"
183 // End:
184 
constexpr double atmosphere
Definition: AugerUnits.h:215
const ProfileResult & EvaluateVaporPressureVsHeight() const
Table of H2O vapor pressure as a function of height.
ProfileResult * fTabRIVsHeight
Definition: VProfileModel.h:74
virtual ~ParametricXMLProfileModel()
Destructor - should be virtual for base classes.
ProfileResult * fTabLogDepthVsHeight
Definition: VProfileModel.h:68
constexpr double kOverburdenSeaLevel
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
Base class for exceptions trying to access non-existing components.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
const atm::ProfileResult & EvaluateTemperatureVsHeight() const
Table of temperature as a function of height.
ProfileResult * fTabTemperatureVsHeight
Definition: VProfileModel.h:72
const atm::ProfileResult & EvaluatePressureVsHeight() const
Table of air pressure as a function of height.
const atm::ProfileResult & EvaluateDepthVsHeight() const
Table of depth as a function of height.
Class representing a document branch.
Definition: Branch.h:107
const atm::ProfileResult & EvaluateRefractionIndexVsHeight() const
Tabl of refraction index as a function of height.
Class describing the Atmospheric profile.
Definition: ProfileResult.h:25
ProfileResult * fTabLogVaporPressureVsHeight
Definition: VProfileModel.h:71
ProfileResult * fTabLogDensityVsHeight
Definition: VProfileModel.h:73
void PushBack(const double x, const double xErr, const double y, const double yErr)
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
constexpr double kLn10
Definition: MathConstants.h:29
const atm::ProfileResult & EvaluateDensityVsHeight() const
Table of density as a function of height.
double LorentzLorentz(const double verticalDepth)
Calculate the refraction index for a given depth.
ProfileResult * fTabLogPressureVsHeight
Definition: VProfileModel.h:70
Main configuration utility.
Definition: CentralConfig.h:51
ProfileResult * fTabHeightVsLogDepth
Definition: VProfileModel.h:69
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
const atm::ProfileResult & EvaluateHeightVsDepth() const
Table of height as a function of depth.
Base class for a Profile Model.
Definition: VProfileModel.h:26

, generated on Tue Sep 26 2023.