00001 /* Copyright (C) 2003-2008 Nikolay Koulev <nkoulev@uni-bremen.de> 00002 00003 This program is free software; you can redistribute it and/or 00004 modify it under the terms of the GNU General Public License as 00005 published by the Free Software Foundation; either version 2 of the 00006 License, or (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00016 USA. * 00017 00027 #include <cmath> 00028 #include <iostream> 00029 #include <sstream> 00030 #include "exceptions.h" 00031 #include "messages.h" 00032 #include "math_funcs.h" 00033 #include "matpackIII.h" 00034 #include "geomag_calc.h" 00035 #include "xml_io.h" 00036 00037 extern const Numeric EARTH_RADIUS; 00038 00039 int main(void) 00040 {// Output 00041 00042 Numeric B_r; // radial component of the geomagnetic field in [nT]. 00043 Numeric B_th; // latitudinal component of the geomagnetic field in [nT]. 00044 Numeric B_ph; // longitudinal component of the geomagnetic field in [nT]. 00045 Numeric B_tot; // Absolute value of the magnetic field in [nT]. 00046 00047 // Input 00048 Numeric z; // altitutde in [km] 00049 Numeric theta; // geocentric colatitude of the point 00050 Numeric phi; // longitude of the point 00051 // All coordinates - geocentric! 00052 00053 Index Ny; // number of elapsed years after an epoch year, J - [0,4] 00054 00055 00056 00057 // extern Index messages; 00058 00059 // messages.resize(1); 00060 00061 // // Set reporting level. (Only the important stuff to the screen, 00062 // // everything to the file.) 00063 // messages[0].screen = 1; 00064 // messages[0].file = 3; 00065 00066 00067 // Feed in altitutde above the mean radius of the Earth in [km]. 00068 cout << "Altitude in km" << endl; 00069 cin >> z; 00070 00071 // Feed in latitute in degrees. 00072 cout << "Latitude in degrees" << endl; 00073 cin >> theta; 00074 00075 // Feed in longitude in degrees. 00076 cout << "Longitude in degrees" << endl; 00077 cin >> phi ; 00078 00079 // Feed in number of elapsed years after the epoch year. 00080 cout << "Ny" << endl; 00081 cin >> Ny; 00082 00083 00084 // Defining the geocetric radius to the point. 00085 const Numeric r = EARTH_RADIUS + z; 00086 00087 try 00088 { 00089 magfield_nk(B_r, B_th, B_ph, r, theta, phi, Ny); 00090 00091 // Calculating of the total field. 00092 B_tot = sqrt(B_r * B_r + B_th * B_th + B_ph * B_ph); 00093 00094 } 00095 catch (runtime_error e) 00096 { 00097 cerr << e.what (); 00098 exit(1); 00099 } 00100 00101 // Output of the radial component of the geomagnetic field in [nT]. 00102 cout << "B_r = " << B_r << " nT" << endl; 00103 00104 // Output of the latitudinal component of the geomagnetic field in [nT]. 00105 cout << "B_th = " << B_th << " nT" << endl; 00106 00107 // Output of the longitudinal component of the geomagnetic field in [nT]. 00108 cout << "B_ph = " << B_ph << " nT" << endl; 00109 00110 // Output of the total geomagnetic field in [nT]. 00111 cout << "B_tot = " << B_tot << " nT" << endl; 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 }