-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwmm_grid.c
More file actions
162 lines (120 loc) · 5.25 KB
/
wmm_grid.c
File metadata and controls
162 lines (120 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include "WMMHeader.h"
#include "WMM_SubLibrary.c"
/*
*
* MODIFICATIONS
*
* Date Version
* ---- -----------
* Jul 15, 2009 0.1
* Nov 15, 2009 0.2
* Jan 28, 2010 1.0
*/
int main()
{
WMMtype_MagneticModel *MagneticModel;
WMMtype_Ellipsoid Ellip;
WMMtype_CoordGeodetic minimum, maximum;
WMMtype_Geoid Geoid;
WMMtype_Date startdate, enddate;
int NumTerms, ElementOption, PrintOption, swabtype;
double cord_step_size, altitude_step_size, time_step_size;
char filename[] = "WMM.COF";
char OutputFilename[20];
NumTerms = ( ( WMM_MAX_MODEL_DEGREES + 1 ) * ( WMM_MAX_MODEL_DEGREES + 2) / 2 );
MagneticModel = WMM_AllocateModelMemory(NumTerms);
if(MagneticModel == NULL )
{
WMM_Error(2);
}
swabtype = WMM_swab_type();
WMM_SetDefaults(&Ellip, MagneticModel, &Geoid);
WMM_readMagneticModel(filename, MagneticModel);
WMM_InitializeGeoid(&Geoid);
WMM_GeomagIntroduction(MagneticModel); /* Print out the WMM introduction */
printf("\n\n This program may be used to generate a grid / volume of magnetic field values over\nlatitude, longitude, altitude and time axes. To skip an axis, keep the start and end values the same\nand enter zero for the step size.\n");
// This program
printf("\n\n Enter grid parameters \n\n");
/* Get the Lat/Long, Altitude, Time limits from a user interface and print the grid to screen */
WMM_GetUserGrid(&minimum, &maximum, &cord_step_size, &altitude_step_size, &time_step_size, &startdate, &enddate,&ElementOption, &PrintOption, OutputFilename, &Geoid);
WMM_Grid(minimum, maximum, cord_step_size, altitude_step_size, time_step_size, MagneticModel, &Geoid, Ellip, startdate, enddate, ElementOption, PrintOption, OutputFilename);
/* Examples */
// ElementOption = 4 ; /* Declination */
// PrintOption = 1; /*Print to File */
/* Define the step sizes and run WMM Grid function */
//WMM_Comparison(MagneticModel, Ellip, LegendreFunction, &Geoid);
// minimum.lambda = 0; /* Minimum Longitude in degrees */
// maximum.lambda = 359.0; /* Maximum Longitude in degrees */
// minimum.phi = -89.0; /* Minimum Latitude in degrees */
// maximum.phi = 89.0; /* Maximum Latitude in degrees */
// cord_step_size = 1; /* Lat/Long interval in degrees */
// minimum.HeightAboveGeoid = 0; /* Minimum height above MSL in kilometers */
// maximum.HeightAboveGeoid = 0; /* Maximum height above MSL in kilometers */
// altitude_step_size = 100; /* Height interval in kilometers */
// startdate.DecimalYear = 2009.9; /* Start date in decimal Years */
// enddate.DecimalYear = 2009.9; /* End date in decimal Years */
// time_step_size = 0.0; /* Time interval in decimal Years */
// WMM_Grid(minimum, maximum, cord_step_size, altitude_step_size, time_step_size, MagneticModel, &Geoid, Ellip, startdate, enddate, ElementOption, PrintOption);
// /* Make a profile of geoMagnetic field elements along a longitude */
//
// minimum.lambda = 10; /* Minimum Longitude in degrees */
// maximum.lambda = 10; /* Maximum Longitude in degrees */
//
// minimum.phi = -20; /* Minimum Latitude in degrees */
// maximum.phi = 40; /* Maximum Latitude in degrees */
//
// cord_step_size = 0.5; /* Lat/Long interval in degrees */
//
// minimum.HeightAboveGeoid = 10; /* Minimum height above MSL in kilometers */
// maximum.HeightAboveGeoid = 10; /* Maximum height above MSL in kilometers */
//
// altitude_step_size = 0; /* Height interval in kilometers */
//
//
// startdate.DecimalYear = 2007.0; /* Start date in decimal Years */
// enddate.DecimalYear = 2007.0; /* End date in decimal Years */
//
// time_step_size = 0; /* Time interval in decimal Years */
//
// WMM_Grid(minimum, maximum, cord_step_size, altitude_step_size, time_step_size, &output, MagneticModel, &Geoid, Ellip, startdate, enddate, ElementOption, PrintOption);
//
//
//
//
//
// /* Print a time series of geoMagnetic field elements at a location */
//
// minimum.lambda = 10; /* Minimum Longitude in degrees */
// maximum.lambda = 20; /* Maximum Longitude in degrees */
//
// minimum.phi = 10; /* Minimum Latitude in degrees */
// maximum.phi = 20; /* Maximum Latitude in degrees */
//
// cord_step_size = 0; /* Lat/Long interval in degrees */
//
// minimum.HeightAboveGeoid = 0; /* Minimum height above MSL in kilometers */
// maximum.HeightAboveGeoid = 0; /* Maximum height above MSL in kilometers */
//
// altitude_step_size = 0; /* Height interval in kilometers */
//
//
// startdate.DecimalYear = 2005.0; /* Start date in decimal Years */
// enddate.DecimalYear = 2007.0; /* End date in decimal Years */
//
// time_step_size = 0.1; /* Time interval in decimal Years */
//
// WMM_Grid(minimum, maximum, cord_step_size, altitude_step_size, time_step_size, &output, MagneticModel, &Geoid, Ellip, startdate, enddate, ElementOption, PrintOption);
//
WMM_FreeMagneticModelMemory(MagneticModel);
if (Geoid.GeoidHeightBuffer)
{
free(Geoid.GeoidHeightBuffer);
Geoid.GeoidHeightBuffer = NULL;
}
return TRUE;
}