ARTS
2.2.66
test_geomag_calc.cc
Go to the documentation of this file.
1
/* Copyright (C) 2003-2012 Nikolay Koulev <nkoulev@uni-bremen.de>
2
3
This program is free software; you can redistribute it and/or
4
modify it under the terms of the GNU General Public License as
5
published by the Free Software Foundation; either version 2 of the
6
License, or (at your option) any later version.
7
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
16
USA. *
17
27
#include <cmath>
28
#include <iostream>
29
#include <sstream>
30
#include "exceptions.h"
31
#include "messages.h"
32
#include "math_funcs.h"
33
#include "matpackIII.h"
34
#include "geomag_calc.h"
35
#include "xml_io.h"
36
37
extern const Numeric EARTH_RADIUS;
38
39
int main(void)
40
{// Output
41
42
Numeric B_r; // radial component of the geomagnetic field in [nT].
43
Numeric B_th; // latitudinal component of the geomagnetic field in [nT].
44
Numeric B_ph; // longitudinal component of the geomagnetic field in [nT].
45
Numeric B_tot; // Absolute value of the magnetic field in [nT].
46
47
// Input
48
Numeric z; // altitutde in [km]
49
Numeric theta; // geocentric colatitude of the point
50
Numeric phi; // longitude of the point
51
// All coordinates - geocentric!
52
53
Index Ny; // number of elapsed years after an epoch year, J - [0,4]
54
55
56
57
// extern Index messages;
58
59
// messages.resize(1);
60
61
// // Set reporting level. (Only the important stuff to the screen,
62
// // everything to the file.)
63
// messages[0].screen = 1;
64
// messages[0].file = 3;
65
66
67
// Feed in altitutde above the mean radius of the Earth in [km].
68
cout << "Altitude in km" << endl;
69
cin >> z;
70
71
// Feed in latitute in degrees.
72
cout << "Latitude in degrees" << endl;
73
cin >> theta;
74
75
// Feed in longitude in degrees.
76
cout << "Longitude in degrees" << endl;
77
cin >> phi ;
78
79
// Feed in number of elapsed years after the epoch year.
80
cout << "Ny" << endl;
81
cin >> Ny;
82
83
84
// Defining the geocetric radius to the point.
85
const Numeric r = EARTH_RADIUS + z;
86
87
try
88
{
89
magfield_nk(B_r, B_th, B_ph, r, theta, phi, Ny);
90
91
// Calculating of the total field.
92
B_tot = sqrt(B_r * B_r + B_th * B_th + B_ph * B_ph);
93
94
}
95
catch (runtime_error e)
96
{
97
cerr << e.what ();
98
exit(1);
99
}
100
101
// Output of the radial component of the geomagnetic field in [nT].
102
cout << "B_r = " << B_r << " nT" << endl;
103
104
// Output of the latitudinal component of the geomagnetic field in [nT].
105
cout << "B_th = " << B_th << " nT" << endl;
106
107
// Output of the longitudinal component of the geomagnetic field in [nT].
108
cout << "B_ph = " << B_ph << " nT" << endl;
109
110
// Output of the total geomagnetic field in [nT].
111
cout << "B_tot = " << B_tot << " nT" << endl;
112
113
114
115
116
117
118
119
120
121
}
arts-2.2
src
test_geomag_calc.cc
Generated on Wed Mar 18 2020 07:04:11 for ARTS by
1.8.13