16 #include <utl/Reader.h>
17 #include <utl/ErrorLogger.h>
18 #include <utl/AugerException.h>
19 #include <utl/AugerUnits.h>
20 #include <utl/MathConstants.h>
21 #include <utl/TabulatedFunction.h>
22 #include <utl/TimeStamp.h>
23 #include <utl/PhysicalConstants.h>
24 #include <utl/PhysicalFunctions.h>
26 #include <fwk/CentralConfig.h>
28 #include <atm/GDASProfileModel.h>
29 #include <atm/ProfileResult.h>
30 #include <atm/MolecularDB.h>
31 #include <atm/MolecularLayer.h>
32 #include <atm/MolecularZone.h>
33 #include <atm/ProfileResult.h>
34 #include <det/Detector.h>
36 #include <utl/ErrorLogger.h>
80 if (
fCurrentTime == det::Detector::GetInstance().GetTime() &&
103 const double minLog =
kLn10 * numeric_limits<double>::min_exponent10;
109 lIt != zIt->LayersEnd(); ++lIt) {
119 if (lIt != zIt->LayersBegin()) {
121 if (newIt->GetHeight() <= (--newIt)->GetHeight())
128 tabLogDepthVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
129 log(lIt->GetDepth()),
130 lIt->GetDepthError() / lIt->GetDepth());
133 tabRIVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
136 tabLogPressureVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
137 log(lIt->GetPressure()),
138 lIt->GetPressureError() / lIt->GetPressure());
142 const double pVapor = lIt->GetHumidity() * pSat;
143 const double dpVapor = lIt->GetHumidityError() * pSat;
145 tabLogVaporPressureVsHeight.
PushBack(
146 lIt->GetHeight(), lIt->GetHeightError(),
147 (pVapor > 0.) ? log(pVapor) : minLog,
148 (pVapor > 0. && dpVapor > 0.) ? pVapor / dpVapor : minLog);
150 tabTemperatureVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
151 lIt->GetTemperature(),
152 lIt->GetTemperatureError());
154 tabLogDensityVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
155 log(lIt->GetAirDensity()),
156 lIt->GetAirDensityError() / lIt->GetAirDensity());
162 if (nZonesCheck == 0) {
166 msg <<
"GDAS model requested data from database, "
167 <<
"but no data found for time "
168 << det::Detector::GetInstance().GetTime();
174 if (nZonesCheck != 1) {
180 const double groundHeight = 1. *
km;
181 const double minHeight = tabTemperatureVsHeight.
GetX(0);
182 const int nLayers = distance(tabTemperatureVsHeight.
Begin(),
183 tabTemperatureVsHeight.
End());
185 if (nLayers > 2 && minHeight > groundHeight) {
186 const double h1 = tabTemperatureVsHeight.
GetX(0);
187 const double h2 = tabTemperatureVsHeight.
GetX(1);
188 const double relH = (groundHeight-h1)/(h2-h1);
191 const double groundLogDepth = tabLogDepthVsHeight.
GetY(0) +
192 (tabLogDepthVsHeight.
GetY(1) - tabLogDepthVsHeight.
GetY(0)) * relH;
194 const double groundLogDensity = tabLogDensityVsHeight.
GetY(0) +
195 (tabLogDensityVsHeight.
GetY(1) - tabLogDensityVsHeight.
GetY(0)) * relH;
197 const double groundLogPressure = tabLogPressureVsHeight.
GetY(0) +
198 (tabLogPressureVsHeight.
GetY(1) - tabLogPressureVsHeight.
GetY(0)) * relH;
200 const double groundLogVaporPressure = tabLogVaporPressureVsHeight.
GetY(0) +
201 (tabLogVaporPressureVsHeight.
GetY(1) - tabLogVaporPressureVsHeight.
GetY(0)) * relH;
203 const double groundTemperature = tabTemperatureVsHeight.
GetY(0) +
204 (tabTemperatureVsHeight.
GetY(1) - tabTemperatureVsHeight.
GetY(0)) * relH;
206 const double groundRefIndex = tabRIVsHeight.
GetY(0) +
207 (tabRIVsHeight.
GetY(1) - tabRIVsHeight.
GetY(0)) * relH;
210 tabLogDepthVsHeight.
Insert(tabLogDepthVsHeight.
Begin(),
211 groundHeight, 0., groundLogDepth, minLog);
213 tabLogDensityVsHeight.
Insert(tabLogDensityVsHeight.
Begin(),
214 groundHeight, 0., groundLogDensity, minLog);
216 tabLogPressureVsHeight.
Insert(tabLogPressureVsHeight.
Begin(),
217 groundHeight, 0., groundLogPressure, minLog);
219 tabLogVaporPressureVsHeight.
Insert(tabLogVaporPressureVsHeight.
Begin(),
220 groundHeight, 0., groundLogVaporPressure, minLog);
222 tabTemperatureVsHeight.
Insert(tabTemperatureVsHeight.
Begin(),
223 groundHeight, 0., groundTemperature, 0.);
226 groundHeight, 0., groundRefIndex, 0.);
231 const int nLayersDepth = distance(tabLogDepthVsHeight.
Begin(),
232 tabLogDepthVsHeight.
End());
235 for (
int i = nLayersDepth-1; i >= 0; --i)
237 tabLogDepthVsHeight.
GetY(i), tabLogDepthVsHeight.
GetYErr(i),
238 tabLogDepthVsHeight.
GetX(i), tabLogDepthVsHeight.
GetXErr(i));
utl::TimeStamp fCurrentTime
boost::transform_iterator< InternalZoneFunctor, InternalZoneIterator, const MolecularZone & > ZoneIterator
ZoneIterator returns a pointer to a MolecularZone.
const atm::ProfileResult & EvaluateTemperatureVsHeight() const
Table of temperature as a function of height.
ProfileResult * fTabRIVsHeight
ProfileResult * fTabLogDepthVsHeight
ZoneIterator ZonesEnd() const
End of the collection of valid Zones.
Detector description interface for data in the Atm_Molecular database.
const ProfileResult & EvaluateVaporPressureVsHeight() const
Table of vapor pressure as a function of height.
void CleanRIVsWavelength() const
Clean up refraction indices. Derived modules decide when to do this.
ProfileResult * fTabTemperatureVsHeight
const double & GetYErr(const unsigned int idx) const
void ExtendProfilesTo100km() const
const atm::ProfileResult & EvaluateRefractionIndexVsHeight() const
Table of refraction index as a function of height.
Class describing the Atmospheric profile.
#define DEBUGLOG(message)
Macro for logging debugging messages.
bool HasData() const
True if a data source is for the given model.
ProfileResult * fTabLogVaporPressureVsHeight
double SaturationVaporPressure(const double temperature)
Evaluate the saturation vapor pressure over ice or water.
ProfileResult * fTabLogDensityVsHeight
const ProfileResult & EvaluateDepthVsHeight() const
Table of depth as a function of height.
void PushBack(const double x, const double xErr, const double y, const double yErr)
const double & GetXErr(const unsigned int idx) const
const double & GetY(const unsigned int idx) const
ZoneIterator ZonesBegin() const
Beginning of the collection of valid Zones.
double LorentzLorentz(const double verticalDepth)
Calculate the refraction index for a given depth.
boost::indirect_iterator< InternalLayerIterator, const MolecularLayer & > LayerIterator
Layer iterator returns a pointer to the molecular data slice for this zone.
ProfileResult * fTabLogPressureVsHeight
bool CheckForUpdates() const
IteratorErr Insert(const IteratorErr &pos, const double x, const double xErr, const double y, const double yErr)
const atm::ProfileResult & EvaluateHeightVsDepth() const
Table of height as a function of depth.
const double & GetX(const unsigned int idx) const
const atm::ProfileResult & EvaluateDensityVsHeight() const
Table of density as a function of height.
ProfileResult * fTabHeightVsLogDepth
const atm::ProfileResult & EvaluatePressureVsHeight() const
Table of air pressure as a function of height.
Base class for a Profile Model.