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