-
Notifications
You must be signed in to change notification settings - Fork 1
/
wmm_grid.c
79 lines (55 loc) · 2.82 KB
/
wmm_grid.c
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
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include "GeomagnetismHeader.h"
#include "EGM9615.h"
//#include "GeomagnetismLibrary.c"
/*
WMM grid program.
The Geomagnetism Library is used to make a command prompt program. The program prompts
the user to enter a location, performs the computations and prints the results to the
standard output. The program expects the files GeomagnetismLibrary.c, GeomagnetismHeader.h,
WMM2010SHDF.COF and EGM9615.h to be in the same directory.
April 21, 2011
* Revision Number: $Revision: 843 $
* Last changed by: $Author: awoods $
* Last changed on: $Date: 2012-04-25 16:23:56 -0600 (Wed, 25 Apr 2012) $
*/
int main()
{
MAGtype_MagneticModel * MagneticModels[1];
MAGtype_Ellipsoid Ellip;
MAGtype_CoordGeodetic minimum, maximum;
MAGtype_Geoid Geoid;
MAGtype_Date startdate, enddate;
int ElementOption, PrintOption, i, epochs = 1;
double cord_step_size, altitude_step_size, time_step_size;
char filename[] = "WMM.COF";
char OutputFilename[32];
char VersionDate_Large[] = "$Date: 2012-04-25 16:23:56 -0600 (Wed, 25 Apr 2012) $";
char VersionDate[12];
MAG_robustReadMagModels(filename, &MagneticModels, 1);
strncpy(VersionDate, VersionDate_Large + 39, 11);
VersionDate[11] = '\0';
MAG_SetDefaults(&Ellip, &Geoid);
//MAG_InitializeGeoid(&Geoid);
/* Set EGM96 Geoid parameters */
Geoid.GeoidHeightBuffer = GeoidHeightBuffer;
Geoid.Geoid_Initialized = 1;
/* Set EGM96 Geoid parameters END */
//MAG_GeomagIntroduction_WMM(MagneticModels[0]); /* Print out the WMM introduction */
printf("\n\n Welcome to the World Magnetic Model (WMM) C-Program\nof the US National Geophysical Data Center\n\t\t--- Grid Calculation Program ----\n\t --- Model Release Date: 15 Dec 2009 ---\n\t --- Software Release Date: %s ---\n", VersionDate);
printf("This program may be used to generate a grid/volume of magnetic field values\n");
printf("over latitude, longitude, altitude and time axes. To skip an axis,\n");
printf("keep the start and end values the same and enter zero for the step size.\n");
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 */
MAG_GetUserGrid(&minimum, &maximum, &cord_step_size, &altitude_step_size, &time_step_size, &startdate, &enddate, &ElementOption, &PrintOption, OutputFilename, &Geoid);
MAG_Grid(minimum, maximum, cord_step_size, altitude_step_size, time_step_size, MagneticModels[0], &Geoid, Ellip, startdate, enddate, ElementOption, PrintOption, OutputFilename);
for(i = 0; i < epochs; i++) MAG_FreeMagneticModelMemory(MagneticModels[i]);
printf("\nPress any key to exit...\n");
getchar();
return 0;
}