casacore
Loading...
Searching...
No Matches
EarthField.h
Go to the documentation of this file.
1// # EarthField.h: EarthField class model claculations
2// # Copyright (C) 1998
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef MEASURES_EARTHFIELD_H
27#define MEASURES_EARTHFIELD_H
28
29// # Includes
30#include <mutex>
31#include <casacore/casa/aips.h>
32#include <casacore/casa/Arrays/Vector.h>
33#include <casacore/casa/Quanta/MVPosition.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Forward Declarations
38
39// # Constants
40// Length of P and Q arrays, half length of CL/SL arrays in IGRF model
41const Int PQ_LEN = 104;
42// Interval (m) for derivatives in IGRF model
43const Double DER_INTV = 10000;
44
45// <summary> EarthField class model calculations </summary>
46
47// <use visibility=local>
48
49// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tEarthField" demos="">
50// </reviewed>
51
52// <prerequisite>
53// <li> <linkto class=Measure>Measure</linkto> class for use
54// <li> <linkto class=MeasTable>MeasTable</linkto> class for data
55// </prerequisite>
56//
57// <etymology>
58// Earth magnetic Field model
59// </etymology>
60//
61// <synopsis>
62// EarthField forms the class for Earth magnetic field calculations. It is a
63// simple container with the selected model, and the mean epoch.<br>
64// The method is selected from one of the following:
65// <ul>
66// <li> EarthField::STANDARD (at 1998/05/18 the IGRF definition)
67// <li> EarthField::IGRF (IGRF reference field model)
68// </ul>
69// Epochs can be specified as the MJD (with defined constants
70// MeasData::MJD2000 and MeasData::MJD1950 or the actual MJD),
71// leading to the following constructors:
72// <ul>
73// <li> EarthField() default; assuming IGRF and MJD2000
74// <li> EarthField(method); assuming J2000 as epoch
75// <li> EarthField(method, epoch) with epoch Double(MJD)
76// </ul>
77// Actual EarthField for a certain position on Earth is calculated by the ()
78// operator. Arguments can be:
79// <ul>
80// <li> MVPosition: a position on Earth (in the ITRF frame)
81// </ul>
82// The returned value is a 3D vector of the field (in nT) in ITRF coordinates.
83// The derivative (d<sup>-1</sup>) can be obtained as well by
84// derivative(MVPosition). <br>
85// An EarthField can be re-initialised with a different method and/or other
86// epoch with the <src>init()</src> functions (same format as constructors).
87//
88// To bypass the full, lengthy calculation actual returned values are calculated
89// using the derivative if within about 50 km (error less than about
90// 10<sup>-2</sup> G). A call to refresh() will re-initiate calculations
91// from scratch.<br>
92// The following details can be set with the
93// <linkto class=Aipsrc>Aipsrc</linkto> mechanism:
94// <ul>
95// <li> measures.earthfield.d_interval: approximation radius
96// (km is default unit) over which a linear approximation
97// is used
98// </ul>
99// The field model is assumed to be constant over the time-span the class
100// is used.
101//
102// The calculations are based on a routine provided by the IGRF community. See
103// ftp.ngdc.noaa.gov/Solid_Earth/Mainfld_Mag/Models/IAGA, routine IGRFLIB.FOR.
104// The values are in nT (10uG).
105// </synopsis>
106//
107// <example>
108// <srcblock>
109// EarthField mine(EarthField::STANDARD,
110// 45837.0); // define EarthField type
111// // for 84/05/17
112// MPosition pos;
113// MeasTable::Observatory(pos, "WSRT"); // Obervatory position
114// // Make sure correct position frame used
115// MVPosition x(MPosition::Convert(pos, MPosition::ITRF)().getValue());
116// MVEarthMagnetic now = mine(x); // get EarthField
117// </srcblock>
118// </example>
119//
120// <motivation>
121// To have a container (with history) for field calculations
122// </motivation>
123//
124// <todo asof="1998/05/18">
125// <li> nothing I know off
126// </todo>
127
129 public:
130 // # Constants
131 // Default interval to be used for linear approximation (in m)
132 static constexpr Double INTV = 50000;
133
134 // # Enumerations
135 // Known EarthField calculation models
137 // Standard IGRF model
139 // Make the field equal to zero
141 // Standard default model if none specified
143 };
144
145 // # Constructors
146 // Default constructor, generates default J2000 EarthField identification
148 // Copy constructor
149 EarthField(const EarthField &other);
150 // Constructor with epoch in MJulian days (default is J2000)
151 explicit EarthField(EarthFieldTypes model, Double catepoch = 51544.5);
152 // Copy assignment
154
155 // # Destructor
157
158 // # Operators
159 // Return the EarthField components. Note that the value returned has only
160 // a lifetime as long as the EarthField container exists, and no new
161 // derivative is asked for.
163
164 // # General Member Functions
165 // Return derivatives of field (to X, Y, Z). Note that the value returned
166 // has only a lifetime as long as the EarthField container exists, and
167 // no new components or derivative is calculated. The returned value should
168 // not be deleted.
170 // Re-initialise EarthField object with specified model and epoch, or
171 // defaults STANDARD and J2000.
172 // <group>
173 void init();
174 void init(EarthFieldTypes model, Double catepoch = 51544.5);
175 // </group>
176 // Refresh calculations
177 void refresh();
178
179 private:
180 // # Data members
181 // Method to be used
183 // Fixed epoch to be used (MJD)
185 // List of spherical components
187 // Work arrays for calculations
188 // <group>
193 // </group>
194 // Check position
196 // Cached calculated field components
198 // Cached derivatives
200 // To reference results, and use a few in interim calculations, results are
201 // calculated in a circular buffer.
202 // Current result pointer
204 // Last calculation
206 // Interpolation interval
207 inline static uInt interval_reg_p = 0;
208 inline static std::once_flag initialization_once_flag;
209
210 // # Member functions
211 // Make a copy
212 void copy(const EarthField &other);
213 // Create correct default fixedEpoch and catalogue field data
214 void fillField();
215 static void initializeRcValue();
216 // Calculate EarthField for longitude and latitude and altitude (m)
217 void calcField(const MVPosition &pos);
218};
219
220} // namespace casacore
221
222#endif
const Vector< Double > * derivative(const MVPosition &pos)
Return derivatives of field (to X, Y, Z).
EarthField()
Default constructor, generates default J2000 EarthField identification.
EarthField(const EarthField &other)
Copy constructor.
static constexpr Double INTV
Default interval to be used for linear approximation (in m).
Definition EarthField.h:132
static std::once_flag initialization_once_flag
Definition EarthField.h:208
static uInt interval_reg_p
Interpolation interval.
Definition EarthField.h:207
Double dval_p[3][3]
Cached derivatives.
Definition EarthField.h:199
static void initializeRcValue()
Vector< Double > p_p
Work arrays for calculations.
Definition EarthField.h:189
void init()
Re-initialise EarthField object with specified model and epoch, or defaults STANDARD and J2000.
EarthFieldTypes method_p
Method to be used.
Definition EarthField.h:182
EarthField(EarthFieldTypes model, Double catepoch=51544.5)
Constructor with epoch in MJulian days (default is J2000).
void refresh()
Refresh calculations.
void fillField()
Create correct default fixedEpoch and catalogue field data.
Vector< Double > sl_p
Definition EarthField.h:192
Vector< Double > agh_p
List of spherical components.
Definition EarthField.h:186
const Vector< Double > & operator()(const MVPosition &pos)
Return the EarthField components.
Int lres_p
To reference results, and use a few in interim calculations, results are calculated in a circular buf...
Definition EarthField.h:203
Vector< Double > q_p
Definition EarthField.h:190
MVPosition checkPos_p
Check position.
Definition EarthField.h:195
void copy(const EarthField &other)
Make a copy.
void calcField(const MVPosition &pos)
Calculate EarthField for longitude and latitude and altitude (m).
EarthField & operator=(const EarthField &other)
Copy assignment.
Vector< Double > result_p[4]
Last calculation.
Definition EarthField.h:205
void init(EarthFieldTypes model, Double catepoch=51544.5)
Double fixedEpoch_p
Fixed epoch to be used (MJD).
Definition EarthField.h:184
Vector< Double > cl_p
Definition EarthField.h:191
EarthFieldTypes
Known EarthField calculation models.
Definition EarthField.h:136
@ IGRF
Standard IGRF model.
Definition EarthField.h:138
@ STANDARD
Standard default model if none specified.
Definition EarthField.h:142
@ NONE
Make the field equal to zero.
Definition EarthField.h:140
Double pval_p[3]
Cached calculated field components.
Definition EarthField.h:197
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Double DER_INTV
Interval (m) for derivatives in IGRF model.
Definition EarthField.h:43
unsigned int uInt
Definition aipstype.h:49
const Int PQ_LEN
Length of P and Q arrays, half length of CL/SL arrays in IGRF model.
Definition EarthField.h:41
int Int
Definition aipstype.h:48
double Double
Definition aipstype.h:53