00001
00002
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include <math.h>
00006
00007 #include <simgear/constants.h>
00008
00009 #include "coremag.hxx"
00010
00011
00012 int main(int argc, char *argv[])
00013 {
00014
00015
00016
00017
00018 double lat_deg,lon_deg,h,var;
00019 int model,yy,mm,dd;
00020 double field[6];
00021
00022 if ((argc != 8) && (argc !=7)) {
00023 fprintf(stdout,"Usage: mag lat_deg lon_deg h mm dd yy [model]\n");
00024 fprintf(stdout,"N latitudes, E longitudes positive degrees, h in km, mm dd yy is date\n");
00025 fprintf(stdout,"model 1,2,3,4,5,6,7 <=> IGRF90,WMM85,WMM90,WMM95,IGRF95,WMM2000,IGRF2000\n");
00026 fprintf(stdout,"Default model is IGRF2000, valid 1/1/00 - 12/31/05\n");
00027 fprintf(stdout,"Output Bx (N) By (E) Bz (down) (in nTesla) dip (degrees down positive)\n");
00028 fprintf(stdout,"variation (degrees E positive)\n");
00029 exit(1);
00030 }
00031
00032 lat_deg=strtod(argv[1],NULL);
00033 lon_deg=strtod(argv[2],NULL);
00034 h= strtod(argv[3],NULL);
00035 mm= (int)strtol(argv[4],NULL,10);
00036 dd= (int)strtol(argv[5],NULL,10);
00037 yy= (int)strtol(argv[6],NULL,10);
00038 if (argc == 8){
00039 model= (int)strtol(argv[7],NULL,10);
00040 }else{
00041 model=7;
00042 }
00043
00044
00045 var = calc_magvar( SGD_DEGREES_TO_RADIANS * lat_deg, SGD_DEGREES_TO_RADIANS * lon_deg, h,
00046 yymmdd_to_julian_days(yy,mm,dd), field );
00047
00048 fprintf(stdout,"%6.0f %6.0f %6.0f\n", field[0], field[1], field[2] );
00049 fprintf(stdout,"%6.0f %6.0f %6.0f\n", field[3], field[4], field[5] );
00050 fprintf(stdout,"%6.0f %6.0f %6.0f %4.2f %4.2f \n",
00051 field[3],field[4],field[5],
00052 SGD_RADIANS_TO_DEGREES * (atan(field[5]/pow(field[3]*field[3]+field[4]*field[4],0.5))),
00053 SGD_RADIANS_TO_DEGREES * var);
00054 exit(0);
00055 }
00056
00057
00058