]> git.mxchange.org Git - simgear.git/blob - simgear/magvar/testmagvar.cxx
Return result in radians.
[simgear.git] / simgear / magvar / testmagvar.cxx
1 /* 2/14/00 fixed help message- dip angle (down positive), variation (E positive) */
2
3 #include        <stdio.h>
4 #include        <stdlib.h>
5 #include        <math.h>
6
7 #include "magvar.hxx"
8
9
10 int main(int argc, char *argv[])
11 {
12   /* args are double lat_deg, double lon_deg, double h, 
13                    int mm, int dd, int yy,int model */
14   /* output N, E, down components of B (nTesla)
15      dip angle (down positive), variation (E positive) */
16 double lat_deg,lon_deg,h,var;
17 int model,yy,mm,dd;
18 double field[6];
19
20 if ((argc != 8) && (argc !=7)) {
21 fprintf(stdout,"Usage: mag lat_deg lon_deg h mm dd yy [model]\n");
22 fprintf(stdout,"N latitudes, E longitudes positive degrees, h in km, mm dd yy is date\n");
23 fprintf(stdout,"model 1,2,3,4,5,6,7 <=> IGRF90,WMM85,WMM90,WMM95,IGRF95,WMM2000,IGRF2000\n");
24 fprintf(stdout,"Default model is IGRF2000, valid 1/1/00 - 12/31/05\n");
25 fprintf(stdout,"Output Bx (N) By (E) Bz (down) (in nTesla) dip (degrees down positive)\n");
26 fprintf(stdout,"variation (degrees E positive)\n");
27 exit(1);
28 }
29
30 lat_deg=strtod(argv[1],NULL);
31 lon_deg=strtod(argv[2],NULL);
32 h=      strtod(argv[3],NULL);
33 mm=     (int)strtol(argv[4],NULL,10);
34 dd=     (int)strtol(argv[5],NULL,10);
35 yy=     (int)strtol(argv[6],NULL,10);
36 if (argc == 8){
37   model=  (int)strtol(argv[7],NULL,10);
38 }else{
39   model=7;
40 }
41
42
43 var = SGMagVar( deg_to_rad(lat_deg), deg_to_rad(lon_deg), h,
44                 yymmdd_to_julian_days(yy,mm,dd), field );
45
46 fprintf(stdout,"%6.0lf %6.0lf %6.0lf\n", field[0], field[1], field[2] );
47 fprintf(stdout,"%6.0lf %6.0lf %6.0lf\n", field[3], field[4], field[5] );
48 fprintf(stdout,"%6.0lf %6.0lf %6.0lf %4.2lf %4.2lf \n",
49   field[3],field[4],field[5],
50   rad_to_deg(atan(field[5]/pow(field[3]*field[3]+field[4]*field[4],0.5))),
51   rad_to_deg(var));
52 exit(0);
53 }
54   
55   
56