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/RadiosondeDBProfileModel.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) {
113 if (lIt != zIt->LayersBegin()) {
115 if (newIt->GetHeight() <= (--newIt)->GetHeight())
122 tabLogDepthVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
123 log(lIt->GetDepth()),
124 lIt->GetDepthError() / lIt->GetDepth());
127 tabRIVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
130 tabLogPressureVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
131 log(lIt->GetPressure()),
132 lIt->GetPressureError() / lIt->GetPressure());
136 const double pVapor = lIt->GetHumidity() * pSat;
137 const double dpVapor = lIt->GetHumidityError() * pSat;
139 tabLogVaporPressureVsHeight.
PushBack(
140 lIt->GetHeight(), lIt->GetHeightError(),
141 (pVapor > 0.) ? log(pVapor) : minLog,
142 (pVapor > 0. && dpVapor > 0.) ? pVapor / dpVapor : minLog);
144 tabTemperatureVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
145 lIt->GetTemperature(),
146 lIt->GetTemperatureError());
148 tabLogDensityVsHeight.
PushBack(lIt->GetHeight(), lIt->GetHeightError(),
149 log(lIt->GetAirDensity()),
150 lIt->GetAirDensityError() / lIt->GetAirDensity());
156 if (nZonesCheck == 0) {
160 msg <<
"Radiosonde model requested data from database, "
161 <<
"but no data found for time "
162 << det::Detector::GetInstance().GetTime();
168 if (nZonesCheck != 1) {
173 const double groundHeight = 1. *
km;
174 const double minHeight = tabTemperatureVsHeight.
GetX(0);
175 const int nLayers = distance(tabTemperatureVsHeight.
Begin(),
176 tabTemperatureVsHeight.
End());
178 if (nLayers > 2 && minHeight > groundHeight) {
179 const double h1 = tabTemperatureVsHeight.
GetX(0);
180 const double h2 = tabTemperatureVsHeight.
GetX(1);
181 const double relH = (groundHeight-h1)/(h2-h1);
184 const double groundLogDepth = tabLogDepthVsHeight.
GetY(0) +
185 (tabLogDepthVsHeight.
GetY(1) - tabLogDepthVsHeight.
GetY(0)) * relH;
187 const double groundLogDensity = tabLogDensityVsHeight.
GetY(0) +
188 (tabLogDensityVsHeight.
GetY(1) - tabLogDensityVsHeight.
GetY(0)) * relH;
190 const double groundLogPressure = tabLogPressureVsHeight.
GetY(0) +
191 (tabLogPressureVsHeight.
GetY(1) - tabLogPressureVsHeight.
GetY(0)) * relH;
193 const double groundLogVaporPressure = tabLogVaporPressureVsHeight.
GetY(0) +
194 (tabLogVaporPressureVsHeight.
GetY(1) - tabLogVaporPressureVsHeight.
GetY(0)) * relH;
196 const double groundTemperature = tabTemperatureVsHeight.
GetY(0) +
197 (tabTemperatureVsHeight.
GetY(1) - tabTemperatureVsHeight.
GetY(0)) * relH;
199 const double groundRefIndex = tabRIVsHeight.
GetY(0) +
200 (tabRIVsHeight.
GetY(1) - tabRIVsHeight.
GetY(0)) * relH;
203 tabLogDepthVsHeight.
Insert(tabLogDepthVsHeight.
Begin(),
204 groundHeight, 0., groundLogDepth, minLog);
206 tabLogDensityVsHeight.
Insert(tabLogDensityVsHeight.
Begin(),
207 groundHeight, 0., groundLogDensity, minLog);
209 tabLogPressureVsHeight.
Insert(tabLogPressureVsHeight.
Begin(),
210 groundHeight, 0., groundLogPressure, minLog);
212 tabLogVaporPressureVsHeight.
Insert(tabLogVaporPressureVsHeight.
Begin(),
213 groundHeight, 0., groundLogVaporPressure, minLog);
215 tabTemperatureVsHeight.
Insert(tabTemperatureVsHeight.
Begin(),
216 groundHeight, 0., groundTemperature, 0.);
219 groundHeight, 0., groundRefIndex, 0.);
223 for (
int i = nLayers; i >= 0; --i)
225 tabLogDepthVsHeight.
GetY(i), tabLogDepthVsHeight.
GetYErr(i),
226 tabLogDepthVsHeight.
GetX(i), tabLogDepthVsHeight.
GetXErr(i));
boost::transform_iterator< InternalZoneFunctor, InternalZoneIterator, const MolecularZone & > ZoneIterator
ZoneIterator returns a pointer to a MolecularZone.
ProfileResult * fTabRIVsHeight
ProfileResult * fTabLogDepthVsHeight
ZoneIterator ZonesEnd() const
End of the collection of valid Zones.
Detector description interface for data in the Atm_Molecular database.
void CleanRIVsWavelength() const
Clean up refraction indices. Derived modules decide when to do this.
bool HasData() const
True if a data source is for the given model.
ProfileResult * fTabTemperatureVsHeight
const atm::ProfileResult & EvaluatePressureVsHeight() const
Table of air pressure as a function of height.
RadiosondeDBProfileModel()
const ProfileResult & EvaluateVaporPressureVsHeight() const
Table of vapor pressure as a function of height.
const double & GetYErr(const unsigned int idx) const
const atm::ProfileResult & EvaluateHeightVsDepth() const
Table of height as a function of depth.
void ExtendProfilesTo100km() const
Class describing the Atmospheric profile.
#define DEBUGLOG(message)
Macro for logging debugging messages.
ProfileResult * fTabLogVaporPressureVsHeight
bool CheckForUpdates() const
double SaturationVaporPressure(const double temperature)
Evaluate the saturation vapor pressure over ice or water.
ProfileResult * fTabLogDensityVsHeight
void PushBack(const double x, const double xErr, const double y, const double yErr)
const atm::ProfileResult & EvaluateTemperatureVsHeight() const
Table of temperature as a function of height.
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
IteratorErr Insert(const IteratorErr &pos, const double x, const double xErr, const double y, const double yErr)
const atm::ProfileResult & EvaluateDensityVsHeight() const
Table of density as a function of height.
const double & GetX(const unsigned int idx) const
const ProfileResult & EvaluateDepthVsHeight() const
Table of depth as a function of height.
ProfileResult * fTabHeightVsLogDepth
const atm::ProfileResult & EvaluateRefractionIndexVsHeight() const
Table of refraction index as a function of height.
utl::TimeStamp fCurrentTime
Base class for a Profile Model.