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 <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/Vector.h>
32#include <casacore/casa/Quanta/MVPosition.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37
38//# Constants
39// Length of P and Q arrays, half length of CL/SL arrays in IGRF model
40const Int PQ_LEN = 104;
41// Interval (m) for derivatives in IGRF model
42const Double DER_INTV = 10000;
43
44// <summary> EarthField class model calculations </summary>
45
46// <use visibility=local>
47
48// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tEarthField" demos="">
49// </reviewed>
50
51// <prerequisite>
52// <li> <linkto class=Measure>Measure</linkto> class for use
53// <li> <linkto class=MeasTable>MeasTable</linkto> class for data
54// </prerequisite>
55//
56// <etymology>
57// Earth magnetic Field model
58// </etymology>
59//
60// <synopsis>
61// EarthField forms the class for Earth magnetic field calculations. It is a
62// simple container with the selected model, and the mean epoch.<br>
63// The method is selected from one of the following:
64// <ul>
65// <li> EarthField::STANDARD (at 1998/05/18 the IGRF definition)
66// <li> EarthField::IGRF (IGRF reference field model)
67// </ul>
68// Epochs can be specified as the MJD (with defined constants
69// MeasData::MJD2000 and MeasData::MJD1950 or the actual MJD),
70// leading to the following constructors:
71// <ul>
72// <li> EarthField() default; assuming IGRF and MJD2000
73// <li> EarthField(method); assuming J2000 as epoch
74// <li> EarthField(method, epoch) with epoch Double(MJD)
75// </ul>
76// Actual EarthField for a certain position on Earth is calculated by the ()
77// operator. Arguments can be:
78// <ul>
79// <li> MVPosition: a position on Earth (in the ITRF frame)
80// </ul>
81// The returned value is a 3D vector of the field (in nT) in ITRF coordinates.
82// The derivative (d<sup>-1</sup>) can be obtained as well by
83// derivative(MVPosition). <br>
84// An EarthField can be re-initialised with a different method and/or other
85// epoch with the <src>init()</src> functions (same format as constructors).
86//
87// To bypass the full, lengthy calculation actual returned values are calculated
88// using the derivative if within about 50 km (error less than about
89// 10<sup>-2</sup> G). A call to refresh() will re-initiate calculations
90// from scratch.<br>
91// The following details can be set with the
92// <linkto class=Aipsrc>Aipsrc</linkto> mechanism:
93// <ul>
94// <li> measures.earthfield.d_interval: approximation radius
95// (km is default unit) over which a linear approximation
96// is used
97// </ul>
98// The field model is assumed to be constant over the time-span the class
99// is used.
100//
101// The calculations are based on a routine provided by the IGRF community. See
102// ftp.ngdc.noaa.gov/Solid_Earth/Mainfld_Mag/Models/IAGA, routine IGRFLIB.FOR.
103// The values are in nT (10uG).
104// </synopsis>
105//
106// <example>
107// <srcblock>
108// EarthField mine(EarthField::STANDARD,
109// 45837.0); // define EarthField type
110// // for 84/05/17
111// MPosition pos;
112// MeasTable::Observatory(pos, "WSRT"); // Obervatory position
113// // Make sure correct position frame used
114// MVPosition x(MPosition::Convert(pos, MPosition::ITRF)().getValue());
115// MVEarthMagnetic now = mine(x); // get EarthField
116// </srcblock>
117// </example>
118//
119// <motivation>
120// To have a container (with history) for field calculations
121// </motivation>
122//
123// <todo asof="1998/05/18">
124// <li> nothing I know off
125// </todo>
126
128
129public:
130
131 //# Constants
132 // Default interval to be used for linear approximation (in m)
133 static const Double INTV;
134
135 //# Enumerations
136 // Known EarthField calculation models
138 // Standard IGRF model
140 // Make the field equal to zero
142 // Standard default model if none specified
143 STANDARD = IGRF
144 };
145
146 //# Constructors
147 // Default constructor, generates default J2000 EarthField identification
149 // Copy constructor
150 EarthField(const EarthField &other);
151 // Constructor with epoch in MJulian days (default is J2000)
152 explicit EarthField(EarthFieldTypes model, Double catepoch=51544.5);
153 // Copy assignment
155
156 //# Destructor
158
159 //# Operators
160 // Return the EarthField components. Note that the value returned has only
161 // a lifetime as long as the EarthField container exists, and no new
162 // derivative is asked for.
164
165 //# General Member Functions
166 // Return derivatives of field (to X, Y, Z). Note that the value returned
167 // has only a lifetime as long as the EarthField container exists, and
168 // no new components or derivative is calculated. The returned value should
169 // not be deleted.
171 // Re-initialise EarthField object with specified model and epoch, or
172 // defaults STANDARD and J2000.
173 // <group>
174 void init();
175 void init(EarthFieldTypes model, Double catepoch=51544.5);
176 // </group>
177 // Refresh calculations
178 void refresh();
179
180 private:
181 //# Data members
182 // Method to be used
184 // Fixed epoch to be used (MJD)
186 // List of spherical components
188 // Work arrays for calculations
189 // <group>
194 // </group>
195 // Check position
197 // Cached calculated field components
199 // Cached derivatives
201 // To reference results, and use a few in interim calculations, results are
202 // calculated in a circular buffer.
203 // Current result pointer
205 // Last calculation
207 // Interpolation interval
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 // Calculate EarthField for longitude and latitude and altitude (m)
216 void calcField(const MVPosition &pos);
217
218};
219
220
221} //# NAMESPACE CASACORE - END
222
223#endif
224
225
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 uInt interval_reg_p
Interpolation interval.
Definition EarthField.h:208
Double dval_p[3][3]
Cached derivatives.
Definition EarthField.h:200
Vector< Double > p_p
Work arrays for calculations.
Definition EarthField.h:190
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:183
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:193
Vector< Double > agh_p
List of spherical components.
Definition EarthField.h:187
const Vector< Double > & operator()(const MVPosition &pos)
Return the EarthField components.
static const Double INTV
Default interval to be used for linear approximation (in m)
Definition EarthField.h:133
Int lres_p
To reference results, and use a few in interim calculations, results are calculated in a circular buf...
Definition EarthField.h:204
Vector< Double > q_p
Definition EarthField.h:191
MVPosition checkPos_p
Check position.
Definition EarthField.h:196
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:206
void init(EarthFieldTypes model, Double catepoch=51544.5)
Double fixedEpoch_p
Fixed epoch to be used (MJD)
Definition EarthField.h:185
Vector< Double > cl_p
Definition EarthField.h:192
EarthFieldTypes
Known EarthField calculation models.
Definition EarthField.h:137
@ IGRF
Standard IGRF model.
Definition EarthField.h:139
@ STANDARD
Standard default model if none specified.
Definition EarthField.h:143
@ NONE
Make the field equal to zero.
Definition EarthField.h:141
Double pval_p[3]
Cached calculated field components.
Definition EarthField.h:198
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:42
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:40
int Int
Definition aipstype.h:48
double Double
Definition aipstype.h:53