testMagneticFieldModel.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 
10 #include <tst/Verify.h>
11 
12 #include <fwk/MagneticFieldModel.h>
13 #include <utl/AugerException.h>
14 #include <utl/AugerUnits.h>
15 #include <utl/CoordinateSystemPtr.h>
16 #include <utl/Point.h>
17 #include <utl/UTMPoint.h>
18 #include <utl/UTCDateTime.h>
19 #include <fwk/CentralConfig.h>
20 
21 #include <det/Detector.h>
22 
23 
24 #include <cppunit/extensions/HelperMacros.h>
25 
26 using namespace utl;
27 using namespace tst;
28 
32 class testMagneticFieldModel : public CppUnit::TestFixture {
33 
34  CPPUNIT_TEST_SUITE(testMagneticFieldModel);
35  CPPUNIT_TEST(testIGRFValues);
36 //CPPUNIT_TEST(testEqualAndCopyCtor);
37 //CPPUNIT_TEST_EXCEPTION(testBinException, InvalidTraceBoundException);
38  CPPUNIT_TEST_SUITE_END();
39 
40 private:
41 
42 public:
43  void
45  {
46 
47  // CentralConfig must be created first.
48  //
49  /*CentralConfig* fCentralConfig =*/
50  fwk::CentralConfig::GetInstance(BOOTSTRAPFILE);
51 
52  // create a detector, needed for access to reference ellipsoid
53  det::Detector::GetInstance();
54 
55  }
56 
57  void
59  {
60  }
61 
62 /*
63  void
64  testEqualAndCopyCtor()
65  {
66  ChannelMagneticFieldModel copyMagneticFieldModel(ourChannelContainer);
67  CPPUNIT_ASSERT(copyMagneticFieldModel == ourChannelContainer);
68  CPPUNIT_ASSERT(!(copyMagneticFieldModel != ourChannelContainer));
69  }
70 */
71 
72  void
74  {
75  // ask the magnetic field model for data at a given time and compare it with values determined from the NOAA webpage
76 
77  //~ these are the data delivered by the webpage
78  //~ Latitude: 35° 28' 32" S
79  //~ Longitude: 69° 35' 12" W
80  //~ Elevation: 1.5 K
81  //~ Date Declination(+E|-W) Inclination (+D|-U) HorizontalIntensity NorthComp(+N|-S) EastComp(+E|-W) VerticalComp(+D|-U) TotalField
82  //~ 2014-07-03 2° 26' 10" -36° 17' 27" 19,506.4 nT 19,488.8 nT 829.2 nT -14,324.0 nT 24,200.7 nT
83  //~ Change/year -8.7' -6.1' -73.6 nT -71.5 nT -52.4 nT 0.6 nT -59.7 nT
84 
85  // configure location (Malargue, 1500m asl)
86  const double Lat = -(35. + 28./60. + 32./3600.) * degree;
87  const double Long = -(69. + 35./60. + 12./3600.) * degree;
88  const double Height = 1500. * meter;
89 
90 // const UTMPoint utmPosition(Lat,Long,Height,ReferenceEllipsoid::eWGS84);
91 // const utl::Point localPosition = utmPosition.GetPoint();
92 
94 
95  // configure time (2014-07-03 at noon)
96  const TimeStamp theTime = UTCDateTime(2014, 7, 3, 12, 0, 0).GetTimeStamp();
97 
98  // get vector and compare components with NOAA web calculator
99  const utl::Vector theMagneticFieldVector = fwk::MagneticFieldModel::instance().GetMagneticFieldVector(localPosition, theTime);
100  const utl::CoordinateSystemPtr localCS = fwk::LocalCoordinateSystem::Create(localPosition);
101 
102  CPPUNIT_ASSERT(Verify<CloseTo>(theMagneticFieldVector.GetX(localCS),829.2*nano*tesla,0.005)); // test East component within 0.5%
103  CPPUNIT_ASSERT(Verify<CloseTo>(theMagneticFieldVector.GetY(localCS),19488.8*nano*tesla,0.005)); // test North component within 0.5%
104  CPPUNIT_ASSERT(Verify<CloseTo>(theMagneticFieldVector.GetZ(localCS),14324.0*nano*tesla,0.005)); // test Up component within 0.5%
105 
106  // get declination and compare
107  CPPUNIT_ASSERT(Verify<CloseTo>(fwk::MagneticFieldModel::instance().GetDeclination(localPosition, theTime),(2+26./60.+10./3600.)*degree,0.005)); // test Declination within 0.5%
108 
109  // get inclination and compare
110  CPPUNIT_ASSERT(Verify<CloseTo>(fwk::MagneticFieldModel::instance().GetInclination(localPosition, theTime),-(36+17./60.+27./3600.)*degree,0.005)); // test Inclination within 0.5%
111 
112  // get strength and compare
113  CPPUNIT_ASSERT(Verify<CloseTo>(fwk::MagneticFieldModel::instance().GetStrength(localPosition, theTime),24200.7*nano*tesla,0.005)); // test field strength within 0.5%
114 
115  }
116 
117 
118 };
119 
121 
122 // Configure (x)emacs for this file ...
123 // Local Variables:
124 // mode: c++
125 // End:
Point object.
Definition: Point.h:32
Point LatitudeLongitudeHeightToPoint(double const latitude, double const longitude, double const height) const
Convert Lat/Long/Height to Point.
static const ReferenceEllipsoid & Get(const EllipsoidID theID)
Get known ellipsoid by registered ID.
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
static MagneticFieldModel & instance()
constexpr double tesla
Definition: AugerUnits.h:249
constexpr double meter
Definition: AugerUnits.h:81
static utl::Vector GetMagneticFieldVector(const utl::Point &position, const utl::TimeStamp &time)
returns the magnetic field at a specific place at a specific time
constexpr double degree
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
Vector object.
Definition: Vector.h:30
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
constexpr double nano
Definition: AugerUnits.h:64
TimeStamp GetTimeStamp() const
Definition: UTCDateTime.cc:115

, generated on Tue Sep 26 2023.