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
130public:
131
132 //# Constants
133 // Default interval to be used for linear approximation (in m)
134 static constexpr Double INTV = 50000;
135
136 //# Enumerations
137 // Known EarthField calculation models
139 // Standard IGRF model
141 // Make the field equal to zero
143 // Standard default model if none specified
145 };
146
147 //# Constructors
148 // Default constructor, generates default J2000 EarthField identification
150 // Copy constructor
151 EarthField(const EarthField &other);
152 // Constructor with epoch in MJulian days (default is J2000)
153 explicit EarthField(EarthFieldTypes model, Double catepoch=51544.5);
154 // Copy assignment
156
157 //# Destructor
159
160 //# Operators
161 // Return the EarthField components. Note that the value returned has only
162 // a lifetime as long as the EarthField container exists, and no new
163 // derivative is asked for.
165
166 //# General Member Functions
167 // Return derivatives of field (to X, Y, Z). Note that the value returned
168 // has only a lifetime as long as the EarthField container exists, and
169 // no new components or derivative is calculated. The returned value should
170 // not be deleted.
172 // Re-initialise EarthField object with specified model and epoch, or
173 // defaults STANDARD and J2000.
174 // <group>
175 void init();
176 void init(EarthFieldTypes model, Double catepoch=51544.5);
177 // </group>
178 // Refresh calculations
179 void refresh();
180
181 private:
182 //# Data members
183 // Method to be used
185 // Fixed epoch to be used (MJD)
187 // List of spherical components
189 // Work arrays for calculations
190 // <group>
195 // </group>
196 // Check position
198 // Cached calculated field components
200 // Cached derivatives
202 // To reference results, and use a few in interim calculations, results are
203 // calculated in a circular buffer.
204 // Current result pointer
206 // Last calculation
208 // Interpolation interval
209 inline static uInt interval_reg_p = 0;
210 inline static std::once_flag initialization_once_flag;
211
212 //# Member functions
213 // Make a copy
214 void copy(const EarthField &other);
215 // Create correct default fixedEpoch and catalogue field data
216 void fillField();
217 static void initializeRcValue();
218 // Calculate EarthField for longitude and latitude and altitude (m)
219 void calcField(const MVPosition &pos);
220
221};
222
223
224} //# NAMESPACE CASACORE - END
225
226#endif
227
228
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:134
static std::once_flag initialization_once_flag
Definition EarthField.h:210
static uInt interval_reg_p
Interpolation interval.
Definition EarthField.h:209
Double dval_p[3][3]
Cached derivatives.
Definition EarthField.h:201
static void initializeRcValue()
Vector< Double > p_p
Work arrays for calculations.
Definition EarthField.h:191
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:184
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:194
Vector< Double > agh_p
List of spherical components.
Definition EarthField.h:188
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:205
Vector< Double > q_p
Definition EarthField.h:192
MVPosition checkPos_p
Check position.
Definition EarthField.h:197
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:207
void init(EarthFieldTypes model, Double catepoch=51544.5)
Double fixedEpoch_p
Fixed epoch to be used (MJD).
Definition EarthField.h:186
Vector< Double > cl_p
Definition EarthField.h:193
EarthFieldTypes
Known EarthField calculation models.
Definition EarthField.h:138
@ IGRF
Standard IGRF model.
Definition EarthField.h:140
@ STANDARD
Standard default model if none specified.
Definition EarthField.h:144
@ NONE
Make the field equal to zero.
Definition EarthField.h:142
Double pval_p[3]
Cached calculated field components.
Definition EarthField.h:199
this file contains all the compiler specific defines
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