dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
worldmagmodel.h
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #ifndef WORLDMAGMODEL_H
29 #define WORLDMAGMODEL_H
30 
31 #include "utils_global.h"
32 
33 // ******************************
34 // internal structure definitions
35 
36 #define WMM_MAX_MODEL_DEGREES 12
37 #define WMM_MAX_SECULAR_VARIATION_MODEL_DEGREES 12
38 #define WMM_NUMTERMS 91 // ((WMM_MAX_MODEL_DEGREES + 1) * (WMM_MAX_MODEL_DEGREES + 2) / 2);
39 #define WMM_NUMPCUP 92 // NUMTERMS + 1
40 #define WMM_NUMPCUPS 13 // WMM_MAX_MODEL_DEGREES + 1
41 
42 typedef struct
43 {
44  double EditionDate;
45  double epoch; //Base time of Geomagnetic model epoch (yrs)
46  char ModelName[20];
47 // double Main_Field_Coeff_G[WMM_NUMTERMS]; // C - Gauss coefficients of main geomagnetic model (nT)
48 // double Main_Field_Coeff_H[WMM_NUMTERMS]; // C - Gauss coefficients of main geomagnetic model (nT)
49 // double Secular_Var_Coeff_G[WMM_NUMTERMS]; // CD - Gauss coefficients of secular geomagnetic model (nT/yr)
50 // double Secular_Var_Coeff_H[WMM_NUMTERMS]; // CD - Gauss coefficients of secular geomagnetic model (nT/yr)
51  int nMax; // Maximum degree of spherical harmonic model
52  int nMaxSecVar; // Maxumum degree of spherical harmonic secular model
53  int SecularVariationUsed; // Whether or not the magnetic secular variation vector will be needed by program
55 
56 typedef struct
57 {
58  double a; // semi-major axis of the ellipsoid
59  double b; // semi-minor axis of the ellipsoid
60  double fla; // flattening
61  double epssq; // first eccentricity squared
62  double eps; // first eccentricity
63  double re; // mean radius of ellipsoid
65 
66 typedef struct
67 {
68  double lambda; // longitude
69  double phi; // geodetic latitude
70  double HeightAboveEllipsoid; // height above the ellipsoid (HaE)
72 
73 typedef struct
74 {
75  double lambda; // longitude
76  double phig; // geocentric latitude
77  double r; // distance from the center of the ellipsoid
79 
80 typedef struct
81 {
82  int Year;
83  int Month;
84  int Day;
85  double DecimalYear;
86 } WMMtype_Date;
87 
88 typedef struct
89 {
90  double Pcup[WMM_NUMPCUP]; // Legendre Function
91  double dPcup[WMM_NUMPCUP]; // Derivative of Lagendre fn
93 
94 typedef struct
95 {
96  double Bx; // North
97  double By; // East
98  double Bz; // Down
100 
101 typedef struct
102 {
103  double RelativeRadiusPower[WMM_MAX_MODEL_DEGREES + 1]; // [earth_reference_radius_km / sph. radius ]^n
104  double cos_mlambda[WMM_MAX_MODEL_DEGREES + 1]; // cp(m) - cosine of (m*spherical coord. longitude
105  double sin_mlambda[WMM_MAX_MODEL_DEGREES + 1]; // sp(m) - sine of (m*spherical coord. longitude)
107 
108 typedef struct
109 {
110  double Decl; /*1. Angle between the magnetic field vector and true north, positive east */
111  double Incl; /*2. Angle between the magnetic field vector and the horizontal plane, positive down */
112  double F; /*3. Magnetic Field Strength */
113  double H; /*4. Horizontal Magnetic Field Strength */
114  double X; /*5. Northern component of the magnetic field vector */
115  double Y; /*6. Eastern component of the magnetic field vector */
116  double Z; /*7. Downward component of the magnetic field vector */
117  double GV; /*8. The Grid Variation */
118  double Decldot; /*9. Yearly Rate of change in declination */
119  double Incldot; /*10. Yearly Rate of change in inclination */
120  double Fdot; /*11. Yearly rate of change in Magnetic field strength */
121  double Hdot; /*12. Yearly rate of change in horizontal field strength */
122  double Xdot; /*13. Yearly rate of change in the northern component */
123  double Ydot; /*14. Yearly rate of change in the eastern component */
124  double Zdot; /*15. Yearly rate of change in the downward component */
125  double GVdot; /*16. Yearly rate of chnage in grid variation */
127 
128 // ******************************
129 
130 namespace Utils {
131 
132  class QTCREATOR_UTILS_EXPORT WorldMagModel
133  {
134  public:
135  WorldMagModel();
136 
137  int GetMagVector(double LLA[3], int Month, int Day, int Year, double Be[3]);
138 
139  private:
140  WMMtype_Ellipsoid Ellip;
141  WMMtype_MagneticModel MagneticModel;
142 
143  double decimal_date;
144 
145  void Initialize();
146  int Geomag(WMMtype_CoordSpherical *CoordSpherical, WMMtype_CoordGeodetic *CoordGeodetic, WMMtype_GeoMagneticElements *GeoMagneticElements);
147  void ComputeSphericalHarmonicVariables(WMMtype_CoordSpherical *CoordSpherical, int nMax, WMMtype_SphericalHarmonicVariables *SphVariables);
148  int AssociatedLegendreFunction(WMMtype_CoordSpherical *CoordSpherical, int nMax, WMMtype_LegendreFunction *LegendreFunction);
149  void Summation( WMMtype_LegendreFunction *LegendreFunction,
151  WMMtype_CoordSpherical *CoordSpherical,
152  WMMtype_MagneticResults *MagneticResults);
153  void SecVarSummation( WMMtype_LegendreFunction *LegendreFunction,
155  WMMtype_CoordSpherical *CoordSpherical,
156  WMMtype_MagneticResults *MagneticResults);
157  void RotateMagneticVector( WMMtype_CoordSpherical *CoordSpherical,
158  WMMtype_CoordGeodetic *CoordGeodetic,
159  WMMtype_MagneticResults *MagneticResultsSph,
160  WMMtype_MagneticResults *MagneticResultsGeo);
161  void CalculateGeoMagneticElements(WMMtype_MagneticResults *MagneticResultsGeo, WMMtype_GeoMagneticElements *GeoMagneticElements);
162  void CalculateSecularVariation(WMMtype_MagneticResults *MagneticVariation, WMMtype_GeoMagneticElements *MagneticElements);
163  int PcupHigh(double *Pcup, double *dPcup, double x, int nMax);
164  void PcupLow(double *Pcup, double *dPcup, double x, int nMax);
165  void SummationSpecial(WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults);
166  void SecVarSummationSpecial(WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults);
167  double get_main_field_coeff_g(int index);
168  double get_main_field_coeff_h(int index);
169  double get_secular_var_coeff_g(int index);
170  double get_secular_var_coeff_h(int index);
171  int DateToYear(int month, int day, int year);
172  void GeodeticToSpherical(WMMtype_CoordGeodetic *CoordGeodetic, WMMtype_CoordSpherical *CoordSpherical);
173  };
174 
175 }
176 
177 // ******************************
178 
179 #endif
double DecimalYear
Definition: worldmagmodel.h:85
LLA
Definition: OPPlots.m:34
x
Definition: OPPlots.m:100