casacore
MEarthMagnetic.h
Go to the documentation of this file.
1 //# MEarthMagnetic.h: A Measure: Magnetic field on Earth
2 //# Copyright (C) 1995-1999,2000,2002,2004
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_MEARTHMAGNETIC_H
30 #define MEASURES_MEARTHMAGNETIC_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/measures/Measures/MeasBase.h>
35 #include <casacore/measures/Measures/MeasRef.h>
36 #include <casacore/casa/Quanta/MVEarthMagnetic.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class MEarthMagnetic;
42 class MCEarthMagnetic;
43 template <class M> class MeasConvert;
44 template <class M> class ArrayMeasColumn;
45 template <class M> class ScalarMeasColumn;
46 
47 //# Typedefs
48 
49 // <summary> A Measure: Magnetic field on Earth </summary>
50 
51 // <use visibility=export>
52 
53 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
54 // </reviewed>
55 
56 // <prerequisite>
57 // <li> <linkto class=Measure>Measure</linkto> class
58 // </prerequisite>
59 //
60 // <etymology>
61 // Earth and Magnetic field
62 // </etymology>
63 //
64 // <synopsis>
65 // MEarthMagnetic forms derived Measure class for Earth' magnetic flux density.
66 // The field can be specified as a model, or as a 3D vector (see
67 // <linkto class=MVEarthMagnetic>MVEarthMagnetic</linkto>) with a specified
68 // reference frame code. If a model is specified, a possibly specified
69 // explicit field will be ignored, since the field will be calculated from
70 // the model if a conversion is asked for.<br>
71 // The class contains the following magnetic field models:
72 // <ul>
73 // <li> IGRF international reference field
74 // </ul>
75 // The reference frame type can be any of the types specified in the
76 // <linkto class=MDirection>MDirection</linkto> direction types (e.g. AZEL).
77 // <note role=warning>
78 // The IGRF needs a Table of coefficients (at 5-year interval) </note>
79 //
80 // Conversion between field models is not supported (but not relevant
81 // anyway with only one model supported). Conversion to an explicit direction
82 // is done by the standard <linkto class=MeasConvert>MeasConvert</linkto>
83 // class and rules (see example) using <em>MEarthMagnetic::Convert</em>,
84 // and the reference types (e.g. MEarthMagnetic::AZEL).
85 //
86 // An <linkto class=EarthMagneticMachine> EarthMagneticMachine</linkto> has
87 // been provided to get e.g. the field in a certain direction at a
88 // certain height.
89 //
90 // </synopsis>
91 //
92 // <example>
93 // <srcblock>
94 // // Where on Earth
95 // MPosition pos(MVPosition(Quantity(20,'m'), Quantity(5,'deg'),
96 // Quantity(52,'deg')), MPosition::WGS84);
97 // // Time we want it
98 // MEpoch epo(MVEpoch(50000));
99 // // Put in frame
100 // MeasFrame frame(pos, epo);
101 // // Magnetic field model
102 // MEarthMagnetic mf;
103 // // Show field strength in Gauss in AzEl system
104 // cout <<
105 // MEarthMagnetic::Convert(mf, MEarthMagnetic::AZEL)().
106 // getValue().getLength("G") << endl;
107 // </srcblock>
108 // </example>
109 //
110 // <motivation>
111 // To have the Earth' magnetic field in the standard Measure environment.
112 // </motivation>
113 //
114 // <todo asof="2000/06/15">
115 // <li> maybe add other field models if necessary (e.g. dipole)
116 // </todo>
117 
118 class MEarthMagnetic : public MeasBase<MVEarthMagnetic, MeasRef<MEarthMagnetic> > {
119 
120  public:
121  //# Friends
122  // Conversion of data
124 
125  //# Enumerations
126  // Types of known MEarthMagnetics
127  // <note role=tip> The order defines the order in the translation matrix
128  // FromTo
129  // in the getConvert routine in MCEarthMagnetic. Do not change the order
130  // without changing the array. Additions should be made before N_types, and
131  // an additional row and column should be coded in FromTo, and
132  // in showType().</note>
133  enum Types {
156  // Models. First one should be IGRF
157  IGRF = 32,
159  // All extra bits (for internal use only)
160  EXTRA = 32,
161  // Defaults
163  // Synonyms
166  };
167 
168  //# Typedefs
169  // Measure value container for this class (i.e. MEarthMagnetic::MVType)
171  // Measure conversion routines for this class (i.e. MEarthMagnetic::MCType)
173  // Measure reference (i.e. MEarthMagnetic::Ref)
175  // Measure Convert (i.e. MEarthMagnetic::Convert)
177  // Measure table Columns (e.g., MEarthMagnetic::ScalarColumn)
180  // Reference enum Types (included originally for gcc 2.95)
182 
183  //# Constructors
184  // <note> In the following constructors and other functions, all
185  // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
186  // where no offsets or frames are needed in the reference. </note>
187  // Default constructor; generates the default IGRF type
188  MEarthMagnetic();
189  // Create from data and reference
190  // <group>
191  MEarthMagnetic(const MVEarthMagnetic &dt);
192  MEarthMagnetic(const MVEarthMagnetic &dt, const MEarthMagnetic::Ref &rf);
194  MEarthMagnetic(const Measure *dt);
195  MEarthMagnetic(const MeasValue *dt);
197  // </group>
198 
199  // <group>
202  // </group>
203 
204  //# Destructor
205  virtual ~MEarthMagnetic();
206 
207  //# Operators
208 
209  //# General Member Functions
210  // Tell me your type
211  // <group>
212  virtual const String &tellMe() const;
213  static const String &showMe();
214  virtual uInt type() const;
215  static void assure(const Measure &in);
216  // </group>
217  // Translate reference code. The uInt version has a check for valid codes
218  // (i.e. it is a safe cast).
219  // <thrown>
220  // <li> AipsError in the uInt interface if illegal code given
221  // </thrown>
222  // <group>
224  static const String &showType(MEarthMagnetic::Types tp);
225  static const String &showType(uInt tp);
226  // </group>
227  // Translate string to reference code
228  // <group>
229  static Bool getType(MEarthMagnetic::Types &tp, const String &in);
230  Bool giveMe(MEarthMagnetic::Ref &mr, const String &in);
231  // </group>
232  // Set the offset in the reference (False if non-matching Measure)
233  virtual Bool setOffset(const Measure &in);
234  // Set the reference type to the specified String. False if illegal
235  // string, reference set to DEFAULT.
236  virtual Bool setRefString(const String &in);
237  // Get the default reference type
238  virtual const String &getDefaultType() const;
239  // Get a list of all known reference codes. nall returns the number in list,
240  // nextra the number of specials (like planets) that should be at
241  // end of list). typ returns the list of corresponding types.
242  // <group>
243  virtual const String* allTypes(Int &nall, Int &nextra,
244  const uInt *&typ) const;
245  static const String* allMyTypes(Int &nall, Int &nextra,
246  const uInt *&typ);
247  // </group>
248  // Check if all internal tables of types (both enum and String) are
249  // complete and correct. This function is called automatically if and when
250  // necessary.
251  // <thrown>
252  // <li> AipsError if a (programming) error in the types.
253  // </thrown>
254  // <group>
255  virtual void checkTypes() const;
256  static void checkMyTypes();
257  // </group>
258  // Get the reference type (for records, including codes like R_)
259  virtual String getRefString() const;
260  // Get my type (as Register)
261  static uInt myType();
262  // Tell me if you are a pure model (e.g. a planet)
263  virtual Bool isModel() const;
264 
265  // Get Measure data
266  // <group>
267  Quantum<Vector<Double> > get(const Unit &inunit) const;
269  Quantum<Vector<Double> > getAngle(const Unit &inunit) const;
270  // </group>
271 
272  // Make copy
273  virtual Measure *clone() const;
274 
275  private:
276  //# Enumerations
277 
278  //# Data
279 
280  //# Member functions
281 
282 };
283 
284 
285 } //# NAMESPACE CASACORE - END
286 
287 #endif
ArrayMeasColumn< MEarthMagnetic > ArrayColumn
virtual void checkTypes() const
Check if all internal tables of types (both enum and String) are complete and correct.
int Int
Definition: aipstype.h:50
Conversion of Measures.
Definition: MBaseline.h:44
virtual const String & tellMe() const
Tell me your type.
Quantum< Vector< Double > > getAngle() const
static void assure(const Measure &in)
MEarthMagnetic()
Note: In the following constructors and other functions, all MeasRef can be replaced with simple Mea...
virtual Measure * clone() const
Make copy.
static MEarthMagnetic::Types castType(uInt tp)
Translate reference code.
static uInt myType()
Get my type (as Register)
Physical quantities within reference frame.
Definition: Measure.h:235
MeasRef< MEarthMagnetic > Ref
Measure reference (i.e.
Base class for all measures.
Definition: MeasBase.h:75
Read only access to table array Measure columns.
Definition: MBaseline.h:45
static const String & showType(MEarthMagnetic::Types tp)
All extra bits (for internal use only)
Bool giveMe(MEarthMagnetic::Ref &mr, const String &in)
ScalarMeasColumn< MEarthMagnetic > ScalarColumn
Measure table Columns (e.g., MEarthMagnetic::ScalarColumn)
defines physical units
Definition: Unit.h:189
A Measure: Magnetic field on Earth.
Base class for values in a Measure.
Definition: MeasValue.h:107
MEarthMagnetic conversion routines.
virtual Bool setRefString(const String &in)
Set the reference type to the specified String.
virtual Bool setOffset(const Measure &in)
Set the offset in the reference (False if non-matching Measure)
MCEarthMagnetic MCType
Measure conversion routines for this class (i.e.
static void checkMyTypes()
MeasConvert< MEarthMagnetic > Convert
Measure Convert (i.e.
A 3D Earth magnetic field vector.
virtual uInt type() const
Get the type (== Register() of derived Measure (faster than Strings) All should have: static uInt myT...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Quantities (i.e. dimensioned values)
Definition: MeasValue.h:40
static const String & showMe()
virtual const String * allTypes(Int &nall, Int &nextra, const uInt *&typ) const
Get a list of all known reference codes.
static const String * allMyTypes(Int &nall, Int &nextra, const uInt *&typ)
MVEarthMagnetic MVType
Measure value container for this class (i.e.
static Bool getType(MEarthMagnetic::Types &tp, const String &in)
Translate string to reference code.
virtual Bool isModel() const
Tell me if you are a pure model (e.g.
typedef WHATEVER_SUN_TYPEDEF(MEarthMagnetic) Types Types
Reference enum Types (included originally for gcc 2.95)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Read only access to table scalar Measure columns.
Definition: MBaseline.h:46
Types
Types of known MEarthMagnetics Tip: The order defines the order in the translation matrix FromTo in ...
MEarthMagnetic & operator=(const MEarthMagnetic &)
virtual String getRefString() const
Get the reference type (for records, including codes like R_)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
virtual const String & getDefaultType() const
Get the default reference type.