dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
WMMInternal.h
Go to the documentation of this file.
1 
14 /*
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  * for more details.
24  *
25  * You should have received a copy of the GNU General Public License along
26  * with this program; if not, see <http://www.gnu.org/licenses/>
27  */
28 
29 #ifndef WMMINTERNAL_H_
30 #define WMMINTERNAL_H_
31 
32  // internal constants
33 #if !defined(TRUE)
34 #define TRUE ((uint16_t)1)
35 #endif
36 #if !defined(FALSE)
37 #define FALSE ((uint16_t)0)
38 #endif
39 #define WMM_MAX_MODEL_DEGREES 12
40 #define WMM_MAX_SECULAR_VARIATION_MODEL_DEGREES 12
41 #define NUMTERMS 91 // ((WMM_MAX_MODEL_DEGREES+1)*(WMM_MAX_MODEL_DEGREES+2)/2);
42 #define NUMPCUP 92 // NUMTERMS +1
43 #define NUMPCUPS 13 // WMM_MAX_MODEL_DEGREES +1
44 
45  // internal structure definitions
46 typedef struct {
47  float epoch; //Base time of Geomagnetic model epoch (yrs)
48 // float Main_Field_Coeff_G[NUMTERMS]; // C - Gauss coefficients of main geomagnetic model (nT)
49 // float Main_Field_Coeff_H[NUMTERMS]; // C - Gauss coefficients of main geomagnetic model (nT)
50 // float Secular_Var_Coeff_G[NUMTERMS]; // CD - Gauss coefficients of secular geomagnetic model (nT/yr)
51 // float Secular_Var_Coeff_H[NUMTERMS]; // CD - Gauss coefficients of secular geomagnetic model (nT/yr)
52  uint16_t nMax; // Maximum degree of spherical harmonic model
53  uint16_t nMaxSecVar; // Maxumum degree of spherical harmonic secular model
54  uint16_t SecularVariationUsed; // Whether or not the magnetic secular variation vector will be needed by program
56 
57 typedef struct {
58  float a; // semi-major axis of the ellipsoid
59  float b; // semi-minor axis of the ellipsoid
60  float fla; // flattening
61  float epssq; // first eccentricity squared
62  float eps; // first eccentricity
63  float re; // mean radius of ellipsoid
65 
66 typedef struct {
67  float lambda; // longitude
68  float phi; // geodetic latitude
69  float HeightAboveEllipsoid; // height above the ellipsoid (HaE)
71 
72 typedef struct {
73  float lambda; // longitude
74  float phig; // geocentric latitude
75  float r; // distance from the center of the ellipsoid
77 
78 typedef struct {
79  uint16_t Year;
80  uint16_t Month;
81  uint16_t Day;
82  float DecimalYear;
83 } WMMtype_Date;
84 
85 typedef struct {
86  float Pcup[NUMPCUP]; // Legendre Function
87  float dPcup[NUMPCUP]; // Derivative of Lagendre fn
89 
90 typedef struct {
91  float Bx; // North
92  float By; // East
93  float Bz; // Down
95 
96 typedef struct {
97 
98  float RelativeRadiusPower[WMM_MAX_MODEL_DEGREES + 1]; // [earth_reference_radius_km / sph. radius ]^n
99  float cos_mlambda[WMM_MAX_MODEL_DEGREES + 1]; // cp(m) - cosine of (m*spherical coord. longitude
100  float sin_mlambda[WMM_MAX_MODEL_DEGREES + 1]; // sp(m) - sine of (m*spherical coord. longitude)
102 
103 typedef struct {
104  float Decl; /* 1. Angle between the magnetic field vector and true north, positive east */
105  float Incl; /*2. Angle between the magnetic field vector and the horizontal plane, positive down */
106  float F; /*3. Magnetic Field Strength */
107  float H; /*4. Horizontal Magnetic Field Strength */
108  float X; /*5. Northern component of the magnetic field vector */
109  float Y; /*6. Eastern component of the magnetic field vector */
110  float Z; /*7. Downward component of the magnetic field vector */
111  float GV; /*8. The Grid Variation */
112  float Decldot; /*9. Yearly Rate of change in declination */
113  float Incldot; /*10. Yearly Rate of change in inclination */
114  float Fdot; /*11. Yearly rate of change in Magnetic field strength */
115  float Hdot; /*12. Yearly rate of change in horizontal field strength */
116  float Xdot; /*13. Yearly rate of change in the northern component */
117  float Ydot; /*14. Yearly rate of change in the eastern component */
118  float Zdot; /*15. Yearly rate of change in the downward component */
119  float GVdot; /*16. Yearly rate of chnage in grid variation */
121 
122  // Internal Function Prototypes
123 void WMM_Set_Coeff_Array();
124 int WMM_GeodeticToSpherical(WMMtype_CoordGeodetic * CoordGeodetic, WMMtype_CoordSpherical * CoordSpherical);
125 int WMM_DateToYear(uint16_t month, uint16_t day, uint16_t year);
126 int WMM_Geomag(WMMtype_CoordSpherical * CoordSpherical,
127  WMMtype_CoordGeodetic * CoordGeodetic, WMMtype_GeoMagneticElements * GeoMagneticElements);
128 
129 int WMM_AssociatedLegendreFunction(WMMtype_CoordSpherical * CoordSpherical, uint16_t nMax, WMMtype_LegendreFunction * LegendreFunction);
130 
131 int WMM_CalculateGeoMagneticElements(WMMtype_MagneticResults * MagneticResultsGeo, WMMtype_GeoMagneticElements * GeoMagneticElements);
132 
133 int WMM_CalculateSecularVariation(WMMtype_MagneticResults * MagneticVariation, WMMtype_GeoMagneticElements * MagneticElements);
134 
136  CoordSpherical, uint16_t nMax, WMMtype_SphericalHarmonicVariables * SphVariables);
137 
138 int WMM_PcupLow(float *Pcup, float *dPcup, float x, uint16_t nMax);
139 
140 int WMM_PcupHigh(float *Pcup, float *dPcup, float x, uint16_t nMax);
141 
143  WMMtype_CoordGeodetic * CoordGeodetic,
144  WMMtype_MagneticResults * MagneticResultsSph, WMMtype_MagneticResults * MagneticResultsGeo);
145 
146 int WMM_SecVarSummation(WMMtype_LegendreFunction * LegendreFunction,
148  SphVariables, WMMtype_CoordSpherical * CoordSpherical, WMMtype_MagneticResults * MagneticResults);
149 
151  SphVariables, WMMtype_CoordSpherical * CoordSpherical, WMMtype_MagneticResults * MagneticResults);
152 
153 int WMM_Summation(WMMtype_LegendreFunction * LegendreFunction,
154  WMMtype_SphericalHarmonicVariables * SphVariables,
155  WMMtype_CoordSpherical * CoordSpherical, WMMtype_MagneticResults * MagneticResults);
156 
158  SphVariables, WMMtype_CoordSpherical * CoordSpherical, WMMtype_MagneticResults * MagneticResults);
159 
160 float WMM_get_main_field_coeff_g(uint16_t index);
161 float WMM_get_main_field_coeff_h(uint16_t index);
162 float WMM_get_secular_var_coeff_g(uint16_t index);
163 float WMM_get_secular_var_coeff_h(uint16_t index);
164 
165 #endif /* WMMINTERNAL_H_ */
166 
#define WMM_MAX_MODEL_DEGREES
Definition: WMMInternal.h:39
int WMM_SecVarSummation(WMMtype_LegendreFunction *LegendreFunction, WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults)
void WMM_Set_Coeff_Array()
int WMM_PcupLow(float *Pcup, float *dPcup, float x, uint16_t nMax)
int WMM_SummationSpecial(WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults)
int WMM_SecVarSummationSpecial(WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults)
float DecimalYear
Definition: WMMInternal.h:82
int WMM_ComputeSphericalHarmonicVariables(WMMtype_CoordSpherical *CoordSpherical, uint16_t nMax, WMMtype_SphericalHarmonicVariables *SphVariables)
int WMM_PcupHigh(float *Pcup, float *dPcup, float x, uint16_t nMax)
uint16_t Month
Definition: WMMInternal.h:80
float WMM_get_main_field_coeff_h(uint16_t index)
uint16_t Day
Definition: WMMInternal.h:81
float WMM_get_secular_var_coeff_h(uint16_t index)
#define NUMPCUP
Definition: WMMInternal.h:42
int WMM_CalculateGeoMagneticElements(WMMtype_MagneticResults *MagneticResultsGeo, WMMtype_GeoMagneticElements *GeoMagneticElements)
int WMM_AssociatedLegendreFunction(WMMtype_CoordSpherical *CoordSpherical, uint16_t nMax, WMMtype_LegendreFunction *LegendreFunction)
int WMM_Geomag(WMMtype_CoordSpherical *CoordSpherical, WMMtype_CoordGeodetic *CoordGeodetic, WMMtype_GeoMagneticElements *GeoMagneticElements)
float WMM_get_secular_var_coeff_g(uint16_t index)
uint16_t Year
Definition: WMMInternal.h:79
float WMM_get_main_field_coeff_g(uint16_t index)
Comput the MainFieldCoeffH accounting for the date.
int WMM_GeodeticToSpherical(WMMtype_CoordGeodetic *CoordGeodetic, WMMtype_CoordSpherical *CoordSpherical)
int WMM_RotateMagneticVector(WMMtype_CoordSpherical *, WMMtype_CoordGeodetic *CoordGeodetic, WMMtype_MagneticResults *MagneticResultsSph, WMMtype_MagneticResults *MagneticResultsGeo)
int WMM_DateToYear(uint16_t month, uint16_t day, uint16_t year)
uint16_t SecularVariationUsed
Definition: WMMInternal.h:54
int WMM_CalculateSecularVariation(WMMtype_MagneticResults *MagneticVariation, WMMtype_GeoMagneticElements *MagneticElements)
int WMM_Summation(WMMtype_LegendreFunction *LegendreFunction, WMMtype_SphericalHarmonicVariables *SphVariables, WMMtype_CoordSpherical *CoordSpherical, WMMtype_MagneticResults *MagneticResults)