9 #include <atm/Atmosphere.h>
11 #include <atm/VRayleighModel.h>
12 #include <atm/VProfileModel.h>
13 #include <atm/VMieModel.h>
14 #include <atm/VFluorescenceModel.h>
15 #include <atm/VCherenkovModel.h>
16 #include <atm/VCloudModel.h>
18 #include <atm/ScatteringResult.h>
19 #include <atm/AttenuationResult.h>
20 #include <atm/ProfileResult.h>
21 #include <atm/CloudResult.h>
22 #include <atm/InclinedAtmosphericProfile.h>
24 #include <atm/ModelRegister.h>
26 #include <det/Detector.h>
27 #include <fdet/Pixel.h>
28 #include <fdet/Telescope.h>
30 #include <fevt/Pixel.h>
32 #include <fwk/CentralConfig.h>
34 #include <utl/Reader.h>
35 #include <utl/ErrorLogger.h>
37 #include <atm/AerosolDB.h>
38 #include <atm/MolecularDB.h>
39 #include <atm/OverallQualityDB.h>
40 #include <atm/LidarDB.h>
41 #include <atm/GOESDB.h>
52 template<
class Factory>
53 typename Factory::ObjectPtrType
56 typename Factory::ObjectPtrType model =
nullptr;
60 msg <<
"Could not find branch " << modelType <<
". "
61 "This model will not be available";
64 const auto modelName = branch.
Get<
string>();
65 model = Factory::Create(modelName);
70 msg <<
"Failed loading model " << modelName <<
". "
71 "Available models are: ";
72 for (
typename Factory::Iterator it = Factory::Begin();
73 it != Factory::End(); ++it) {
74 msg << it->first <<
", ";
84 Atmosphere::EvaluateRayleighAttenuation(
const Point& xInit,
86 const vector<double>& wLength)
89 if (!HasModel(fRayleighModel))
92 if (!fRayleighModel->HasData())
95 return fRayleighModel->EvaluateRayleighAttenuation(xInit, xFinal, wLength);
100 Atmosphere::EvaluateRayleighAttenuation(
const Point& xInit,
102 const double wLength)
105 if (!HasModel(fRayleighModel))
108 if (!fRayleighModel->HasData())
111 return fRayleighModel->EvaluateRayleighAttenuation(xInit, xFinal, wLength);
116 Atmosphere::EvaluateMieAttenuation(
const Point& xInit,
118 const vector<double>& wLength)
121 if (!HasModel(fMieModel))
124 if (!fMieModel->HasData())
127 return fMieModel->EvaluateMieAttenuation(xInit, xFinal, wLength);
132 Atmosphere::EvaluateMieAttenuation(
const Point& xInit,
134 const double wLength)
137 if (!HasModel(fMieModel))
140 if (!fMieModel->HasData())
143 return fMieModel->EvaluateMieAttenuation(xInit, xFinal, wLength);
148 Atmosphere::GetMieAttenuationLength(
const Point& xA,
149 const double wLength)
152 if (!HasModel(fMieModel))
155 if (!fMieModel->HasData())
158 return fMieModel->GetAttenuationLength(xA, wLength);
163 Atmosphere::GetVerticalAerosolOpticalDepth(
const unsigned int eyeId,
164 const double altitude)
167 if (!HasModel(fMieModel))
170 if (!fMieModel->HasData())
173 return fMieModel->GetVerticalAerosolOpticalDepth(eyeId, altitude);
182 if (!HasModel(fCloudModel))
185 if (!fCloudModel->HasData())
188 return fCloudModel->EvaluateCloudCoverage(pixel, x);
197 if (!HasModel(fCloudModel))
200 if (!fCloudModel->HasData())
203 return fCloudModel->EvaluateCloudCoverage(pixel, x);
208 Atmosphere::EvaluateCloudCoverage(
const unsigned int eyeId,
209 const unsigned int telId,
210 const unsigned int pixId,
214 if (!HasModel(fCloudModel))
217 if (!fCloudModel->HasData())
220 return fCloudModel->EvaluateCloudCoverage(eyeId, telId, pixId, x);
225 Atmosphere::EvaluateDepthVsHeight()
228 if (!HasModel(fProfileModel))
231 if (!fProfileModel->HasData())
234 return fProfileModel->EvaluateDepthVsHeight();
239 Atmosphere::EvaluateHeightVsDepth()
242 if (!HasModel(fProfileModel))
245 if (!fProfileModel->HasData())
248 return fProfileModel->EvaluateHeightVsDepth();
253 Atmosphere::EvaluatePressureVsHeight()
256 if (!HasModel(fProfileModel))
259 if (!fProfileModel->HasData())
262 return fProfileModel->EvaluatePressureVsHeight();
267 Atmosphere::EvaluateTemperatureVsHeight()
270 if (!HasModel(fProfileModel))
273 if (!fProfileModel->HasData())
276 return fProfileModel->EvaluateTemperatureVsHeight();
281 Atmosphere::EvaluateVaporPressureVsHeight()
284 if (!HasModel(fProfileModel))
287 if (!fProfileModel->HasData())
290 return fProfileModel->EvaluateVaporPressureVsHeight();
295 Atmosphere::EvaluateDensityVsHeight()
298 if (!HasModel(fProfileModel))
301 if (!fProfileModel->HasData())
304 return fProfileModel->EvaluateDensityVsHeight();
309 Atmosphere::EvaluateRefractionIndexVsHeight()
312 if (!HasModel(fProfileModel))
315 if (!fProfileModel->HasData())
318 return fProfileModel->EvaluateRefractionIndexVsHeight();
323 Atmosphere::EvaluateRefractionIndexVsHeight(
const double wavelength)
326 if (!HasModel(fProfileModel))
329 if (!fProfileModel->HasData())
332 return fProfileModel->EvaluateRefractionIndexVsHeight(wavelength);
337 Atmosphere::InitSlantProfileModel(
const Point& core,
342 delete fInclinedProfileModel;
346 fInclinedProfileModel =
nullptr;
353 Atmosphere::IntegratedGrammage(
const Point& pStart,
358 return InclinedAtmosphericProfile::IntegratedGrammage(pStart, pStop, delta);
363 Atmosphere::EvaluateSlantDepthVsDistance()
366 if (!fInclinedProfileModel)
369 return fInclinedProfileModel->EvaluateSlantDepthVsDistance();
374 Atmosphere::EvaluateDistanceVsSlantDepth()
377 if (!fInclinedProfileModel)
380 return fInclinedProfileModel->EvaluateDistanceVsSlantDepth();
385 Atmosphere::EvaluateHeightVsSlantDepth()
388 if (!fInclinedProfileModel)
391 return fInclinedProfileModel->EvaluateHeightVsSlantDepth();
396 Atmosphere::EvaluateHeightVsDistance()
399 if (!fInclinedProfileModel)
402 return fInclinedProfileModel->EvaluateHeightVsDistance();
407 Atmosphere::EvaluateRayleighScattering(
const Point& x1,
410 const double distance,
411 const vector<double>& wLength)
414 if (!HasModel(fRayleighModel))
417 if (!fRayleighModel->HasData())
420 return fRayleighModel->EvaluateRayleighScattering(x1, x2, angle, distance, wLength);
425 Atmosphere::EvaluateRayleighScattering(
const Point& x1,
428 const double distance,
432 if (!HasModel(fRayleighModel))
435 if (!fRayleighModel->HasData())
438 return fRayleighModel->EvaluateRayleighScattering(x1, x2, angle, distance, rayleighAttenuation);
443 Atmosphere::EvaluateRayleighScattering(
const Point& x1,
446 const double distance,
447 const double wLength)
450 if (!HasModel(fRayleighModel))
453 if (!fRayleighModel->HasData())
456 return fRayleighModel->EvaluateRayleighScattering(x1, x2, angle, distance, wLength);
461 Atmosphere::EvaluateRayleighScattering(
const Point& x1,
464 const double distance,
465 const double wLength,
466 const double rayleighAttenuation)
469 if (!HasModel(fRayleighModel))
472 if (!fRayleighModel->HasData())
475 return fRayleighModel->EvaluateRayleighScattering(x1, x2, angle, distance, wLength, rayleighAttenuation);
480 Atmosphere::GetRayleighAttenuationLength(
const Point& xA,
481 const double wLength)
484 if (!HasModel(fRayleighModel))
487 if (!fRayleighModel->HasData())
490 return fRayleighModel->GetAttenuationLength(xA, wLength);
495 Atmosphere::EvaluateMieScattering(
const Point& x1,
498 const double distance,
499 const vector<double>& wLength)
502 if (!HasModel(fMieModel))
505 if (!fMieModel->HasData())
508 return fMieModel->EvaluateMieScattering(x1, x2, angle, distance, wLength);
513 Atmosphere::EvaluateMieScattering(
const Point& x1,
516 const double distance,
517 const double wLength)
520 if (!HasModel(fMieModel))
523 if (!fMieModel->HasData())
526 return fMieModel->EvaluateMieScattering(x1, x2, angle, distance, wLength);
531 Atmosphere::EvaluateMieScattering(
const Point& x1,
534 const double distance,
538 if (!HasModel(fMieModel))
541 if (!fMieModel->HasData())
544 return fMieModel->EvaluateMieScattering(x1, x2, angle, distance, mieAttenuation);
549 Atmosphere::EvaluateMieScattering(
const Point& x1,
552 const double distance,
553 const double wLength,
554 const double mieAttenuation)
557 if (!HasModel(fMieModel))
560 if (!fMieModel->HasData())
563 return fMieModel->EvaluateMieScattering(x1, x2, angle, distance, wLength, mieAttenuation);
568 Atmosphere::EvaluateFluorescenceYield(
const double heightAboveSeaLevel)
571 if (!HasModel(fFluorescenceModel))
574 return fFluorescenceModel->EvaluateFluorescenceYield(heightAboveSeaLevel);
578 const vector<double>&
584 if (!HasModel(fFluorescenceModel))
586 return fFluorescenceModel->GetWavelengths();
588 if (!HasModel(fCherenkovModel))
590 return fCherenkovModel->GetWavelengths();
598 Atmosphere::GetdEdX0()
601 if (!HasModel(fFluorescenceModel))
604 return fFluorescenceModel->GetdEdX0();
609 Atmosphere::GetDeExcitationTime(
const double height)
612 if (!HasModel(fFluorescenceModel))
615 return fFluorescenceModel->GetDeExcitationTime(height);
620 Atmosphere::GetVerticalTimeOfFlight(
const double height1,
621 const double height2)
624 if (!HasModel(fProfileModel))
627 if (!fProfileModel->HasData())
630 return fProfileModel->GetVerticalTimeOfFlight(height1, height2);
635 Atmosphere::SetCherenkovEnergyCutoff(
const double eCut)
638 if (!HasModel(fCherenkovModel))
641 return fCherenkovModel->SetEnergyCutoff(eCut);
646 Atmosphere::EvaluateCherenkovPhotons(
const Point& xA,
648 const double meanShowerAge)
651 if (!HasModel(fCherenkovModel))
654 return fCherenkovModel->EvaluateCherenkovPhotons(xA, xB,
660 Atmosphere::EvaluateCherenkovDirect(
const Point& xA,
663 const double meanShowerAge)
666 if (!HasModel(fCherenkovModel))
669 return fCherenkovModel->EvaluateCherenkovDirect(xA, xB, xEye,
675 Atmosphere::EvaluateDirectCherenkovProbability(
const Point& xA,
678 const double meanShowerAge)
681 if (!HasModel(fCherenkovModel))
684 return fCherenkovModel->EvaluateDirectCherenkovProbability(xA, xB, xEye,
689 Atmosphere::EvaluateDirectCherenkovProbability(
const Point& xA,
692 const double meanShowerAge,
693 const double wavelength)
696 if (!HasModel(fCherenkovModel))
699 return fCherenkovModel->EvaluateDirectCherenkovProbability(xA, xB, xEye,
700 meanShowerAge, wavelength);
704 Atmosphere::GetAerosolDB()
714 Atmosphere::GetOverallQualityDB()
717 if (!fOverallQualityDB)
719 return *fOverallQualityDB;
724 Atmosphere::GetLidarDB()
733 Atmosphere::GetGOESDB()
750 MolecularDBMap::iterator it = fMolecularDBMap.find(
id);
751 if (it != fMolecularDBMap.end())
755 fMolecularDBMap.insert(make_pair(
id,
m));
762 Atmosphere::HasModel(
VModel*
const model)
765 ERROR(
"Call to a not registered or not configured model");
778 DEBUGLOG(
"Could not find branch Atmosphere; "
779 "Atmosphere will not be available");
783 delete fProfileModel;
784 fProfileModel = CreateAndInit<VProfileModelFactory>(topB,
"ProfileModel");
786 delete fRayleighModel;
787 fRayleighModel = CreateAndInit<VRayleighModelFactory>(topB,
"RayleighModel");
790 fMieModel = CreateAndInit<VMieModelFactory>(topB,
"MieModel");
792 delete fFluorescenceModel;
793 fFluorescenceModel = CreateAndInit<VFluorescenceModelFactory>(topB,
"FluorescenceModel");
795 delete fCherenkovModel;
796 fCherenkovModel = CreateAndInit<VCherenkovModelFactory>(topB,
"CherenkovModel");
799 fCloudModel = CreateAndInit<VCloudModelFactory>(topB,
"CloudModel");
806 delete fOverallQualityDB;
807 fOverallQualityDB =
nullptr;
813 fAerosolDB =
nullptr;
815 for (MolecularDBMap::iterator it = fMolecularDBMap.begin();
816 it != fMolecularDBMap.end(); ++it)
819 fMolecularDBMap.clear();
821 delete fInclinedProfileModel;
822 fInclinedProfileModel =
nullptr;
836 fMieModel->SetUncertaintyBound(nSigma);
839 ERROR(
" SetUncertaintyBound not implemented ...");
845 Atmosphere::AngularCherenkovCDF(
const double theta,
846 const double verticalDepth,
847 const double showerAge)
850 if (!HasModel(fCherenkovModel))
853 return fCherenkovModel->AngularCDF(theta, verticalDepth, showerAge);
858 Atmosphere::AngularCherenkovPDF(
const double theta,
859 const double verticalDepth,
860 const double showerAge)
863 if (!HasModel(fCherenkovModel))
866 return fCherenkovModel->AngularPDF(theta, verticalDepth, showerAge);
Branch GetTopBranch() const
Detector description interface for GOES cloud data.
Class to hold collection (x,y) points and provide interpolation between them.
Detector description interface for data in the Atm_Molecular database.
void Init()
Initialise the registry.
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.
Class holding the output of the ScatteringResult function.
Base class of atmospheric functions.
Class representing a document branch.
Class for loading and storing a collection of aerosol data.
Fluorescence Detector Pixel event.
Class describing the Atmospheric profile.
ProfileId
Monitoring profiles:
#define DEBUGLOG(message)
Macro for logging debugging messages.
#define WARNING(message)
Macro for logging warning messages.
Provides translational services for inclined profile.
Store the obscuration of an FD pixel by a cloud in the field of view.
Detector description interface for LidarDB-realted data.
execption handling for calculation/access for inclined atmosphere model
Access to database describing overall atmospheric quality.
#define ERROR(message)
Macro for logging error messages.
Class describing the Atmospheric attenuation.
Factory::ObjectPtrType CreateAndInit(const Branch &topB, const string &modelType)