casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MVEarthMagnetic.h
Go to the documentation of this file.
1 //# MVEarthMagnetic.h: A 3D Earth magnetic field vector
2 //# Copyright (C) 1996,1997,1998,2000
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 //# $Id$
27 
28 #ifndef CASA_MVEARTHMAGNETIC_H
29 #define CASA_MVEARTHMAGNETIC_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 
39 
40 // <summary> A 3D Earth magnetic field vector </summary>
41 
42 // <use visibility=local>
43 
44 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
45 // </reviewed>
46 
47 // <prerequisite>
48 // <li> <linkto class=MeasValue>MeasValue</linkto>
49 // <li> <linkto class=Vector>Vector</linkto>
50 // <li> <linkto class=Quantum>Quantum</linkto>
51 // </prerequisite>
52 //
53 // <etymology>
54 // From Measure, Value and Earth Magnetic field
55 // </etymology>
56 //
57 // <synopsis>
58 // A MVEarthMagnetic is a 3-vector of the Earth's magnetic flux density in a
59 // rectangular frame with the z-axis to astronomical North pole, and x-axis
60 // towards longitude zero, in internal Units of nano tesla (== 0.00001 G).<br>
61 // It can be constructed with:
62 // <ul>
63 // <li> MVEarthMagnetic() creates (0,0,0)
64 // <li> MVEarthMagnetic(MVEarthMagnetic) creates a copy
65 // <li> MVEarthMagnetic(MVPosition) creates (x,y,z) from the given position
66 // <li> MVEarthMagnetic(Double, Double, Double) creates (x,y,z) with
67 // specified values in tesla
68 // <li> MVEarthMagnetic(Quantity length,Double, Double) creates an
69 // MVEarthMagnetic assuming
70 // that the two values are (in radians) angle along 'equator'
71 // and towards 'pole'.
72 // <li> MVEarthMagnetic(Quantity length, Quantity, Quantity) creates an
73 // MVEarthMagnetic
74 // assuming angles as in previous, or (x,y,z) fields
75 // <li> <src>MVEarthMagnetic(Quantity, Quantum<Vector<Double> >)</src> creates a
76 // MVEarthMagnetic from angle vector, using first two angles, and
77 // assuming second as zero if not present, and pole if length 0.
78 // <li> <src>MVEarthMagnetic(Quantum<Vector<Double> ></src> creates from
79 // angles or fields, depending on the units in the
80 // quantum vector. In the angle case,
81 // the data derived can be scaled with the readjust() function. If
82 // the unit of the quantum vector is magnetic flux density,
83 // magnetic field components are assumed.
84 // <li> <src>MVEarthMagnetic(Vector<Double></src> creates from angles (less than
85 // or equal to two elements) or x,y,z (3 elements).
86 // <li> <src>MVEarthMagnetic(Vector<Quantity></src> creates from length+angles,
87 // angles, or x,y,z, depending on units.
88 // </ul>
89 // A void adjust(Double) function normalises the vector to a length of 1;
90 // a get() returns as a
91 // Double 3-vector the length and angles of the EarthMagnetic vector;
92 // a getAngle() returns a Quantum 2-vector, (uInt) returns the indicated
93 // element, and getValue returns the vector.<br>
94 // EarthMagnetics can be added and subtracted.<br>
95 // The multiplication of two EarthMagnetics produces the in-product.<br>
96 // </synopsis>
97 //
98 // <example>
99 // See <linkto class=MEarthMagnetic>MEarthMagnetic</linkto> class.
100 // </example>
101 //
102 // <motivation>
103 // To use in ionospheric effect calculations
104 // </motivation>
105 //
106 // <todo asof="1998/05/19">
107 // <li> nothing I know of
108 // </todo>
109 
110 class MVEarthMagnetic : public MVPosition {
111 
112 public:
113 
114  //# Friends
115 
116  //# Constructors
117  // Default constructor generates a (0,0,0) EarthMagnetic
118  MVEarthMagnetic();
119  // Creates from an MVPosition
120  MVEarthMagnetic(const MVPosition &other);
121  // Creates a specified vector
122  MVEarthMagnetic(Double in0, Double in1, Double in2);
123  // Creates a vector with specified length towards pole
124  // <group>
125  explicit MVEarthMagnetic(Double in0);
126  MVEarthMagnetic(const Quantity &l);
127  // </group>
128  // Creates the EarthMagnetic from specified (azimuth,elevation) angles and length
129  MVEarthMagnetic(const Quantity &l, Double angle0, Double angle1);
130  // Creates the EarthMagnetic from specified angles and length. or EarthMagnetics
131  // <thrown>
132  // <li> AipsError if quantities not in angle format
133  // </thrown>
134  // <group>
135  MVEarthMagnetic(const Quantity &l, const Quantity &angle0,
136  const Quantity &angle1);
137  // If not enough angles: pole assumed (if none), or elevation =0 (if 1)
138  MVEarthMagnetic(const Quantum<Vector<Double> > &angle);
139  MVEarthMagnetic(const Quantity &l, const Quantum<Vector<Double> > &angle);
140  // </group>
141  // Create from specified length and/or angles and/or EarthMagnetic
142  // <group>
143  MVEarthMagnetic(const Vector<Double> &other);
144  MVEarthMagnetic(const Vector<Quantity> &other);
145  // </group>
146 
147  //# Operators
148  // Multiplication defined as in-product
149  // <group>
150  Double operator*(const MVEarthMagnetic &other) const;
151  // </group>
152 
153  // Equality comparisons
154  // <group>
155  Bool operator== (const MVEarthMagnetic &other) const;
156  Bool operator!= (const MVEarthMagnetic &other) const;
157  Bool near(const MVEarthMagnetic &other, Double tol=1e-13) const;
158  Bool near(const MVEarthMagnetic &other, Quantity tol) const;
159  Bool nearAbs(const MVEarthMagnetic &other, Double tol=1e-13) const;
160  // </group>
161 
162  // Addition and subtraction
163  // <group>
164  MVEarthMagnetic operator-() const;
166  MVEarthMagnetic operator+(const MVEarthMagnetic &right) const;
168  MVEarthMagnetic operator-(const MVEarthMagnetic &right) const;
169  // </group>
170 
171  //# General Member Functions
172 
173  // Tell me your type
174  // <group>
175  static void assure(const MeasValue &in);
176  // </group>
177 
178  // Normalise direction aspects by adjusting the length to 1
179  // <group>
180  virtual void adjust();
181  virtual void adjust(Double &res);
182  virtual void readjust(Double res);
183  // </group>
184  // Get modulus of EarthMagnetic
185  virtual Double radius();
186  // Generate a 3-vector of coordinates (length(T), angles(rad))
187  Vector<Double> get() const;
188  // Generate a 3-vector of x,y,z in tesla
189  const Vector<Double> &getValue() const;
190  // Generate angle 2-vector (in rad)
192  // and with specified units
193  Quantum<Vector<Double> > getAngle(const Unit &unit) const;
194  // Generate the length
195  Quantity getLength() const;
196  // and generate it with the specified units
197  Quantity getLength(const Unit &unit) const;
198  // Get the EarthMagnetic angle between the directions. I.e. the angle between
199  // the direction from one to the pole, and from one to the other.
200  // <group>
201  Double earthMagneticAngle(const MVEarthMagnetic &other) const;
203  const Unit &unit) const;
204  // </group>
205  // Get the angular separation between two directions.
206  // <group>
207  Double separation(const MVEarthMagnetic &other) const;
208  Quantity separation(const MVEarthMagnetic &other,
209  const Unit &unit) const;
210  // </group>
211  // Produce the cross product
212  MVEarthMagnetic crossProduct(const MVEarthMagnetic &other) const;
213 
214  // Print data
215  virtual void print(ostream &os) const;
216  // Clone
217  virtual MeasValue *clone() const;
218  // Get the value in internal units
219  virtual Vector<Double> getVector() const;
220  // Set the value from internal units (set 0 for empty vector)
221  virtual void putVector(const Vector<Double> &in);
222  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
223  // records. The getXRecordValue() gets additional information for records.
224  // Note that the Vectors could be empty.
225  // <group>
226  virtual Vector<Quantum<Double> > getRecordValue() const;
227  // </group>
228  // Set the internal value if correct values and dimensions
229  virtual Bool putValue(const Vector<Quantum<Double> > &in);
230 
231 };
232 
233 //# Global functions
234 // Rotate a EarthMagnetic vector with rotation matrix and other multiplications
235 // <group>
236 MVEarthMagnetic operator*(const RotMatrix &left, const MVEarthMagnetic &right);
237 MVEarthMagnetic operator*(const MVEarthMagnetic &left, const RotMatrix &right);
238 MVEarthMagnetic operator*(Double left, const MVEarthMagnetic &right);
239 MVEarthMagnetic operator*(const MVEarthMagnetic &left, Double right);
240 Double operator*(const Vector<Double> &left, const MVEarthMagnetic &right);
241 Double operator*(const MVEarthMagnetic &left, const Vector<Double> &right);
242 Double operator*(const MVPosition &left, const MVEarthMagnetic &right);
243 Double operator*(const MVEarthMagnetic &left, const MVPosition &right);
244 // </group>
245 
246 
247 } //# NAMESPACE CASACORE - END
248 
249 #endif
virtual void print(ostream &os) const
Print data.
MVEarthMagnetic operator-() const
Addition and subtraction.
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
Double earthMagneticAngle(const MVEarthMagnetic &other) const
Get the EarthMagnetic angle between the directions.
virtual MeasValue * clone() const
Clone.
Bool operator!=(const MVEarthMagnetic &other) const
static void assure(const MeasValue &in)
Tell me your type.
A 3x3 rotation matrix.
Definition: RotMatrix.h:85
const Vector< Double > & getValue() const
Generate a 3-vector of x,y,z in tesla.
Bool nearAbs(const MVEarthMagnetic &other, Double tol=1e-13) const
defines physical units
Definition: Unit.h:189
MVEarthMagnetic crossProduct(const MVEarthMagnetic &other) const
Produce the cross product.
MVEarthMagnetic operator+(const MVEarthMagnetic &right) const
Base class for values in a Measure.
Definition: MeasValue.h:107
Quantity getLength() const
Generate the length.
MVEarthMagnetic & operator+=(const MVEarthMagnetic &right)
virtual void adjust()
Normalise direction aspects by adjusting the length to 1.
double Double
Definition: aipstype.h:55
MVEarthMagnetic & operator-=(const MVEarthMagnetic &right)
A 3D Earth magnetic field vector.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A 3D vector in space.
Definition: MVPosition.h:113
virtual void putVector(const Vector< Double > &in)
Set the value from internal units (set 0 for empty vector)
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector&lt;Quantity&gt;.
Double separation(const MVEarthMagnetic &other) const
Get the angular separation between two directions.
Bool near(const MVEarthMagnetic &other, Double tol=1e-13) const
Quantum< Vector< Double > > getAngle() const
Generate angle 2-vector (in rad)
virtual Vector< Double > getVector() const
Get the value in internal units.
const Double e
e and functions thereof:
Bool operator==(const MVEarthMagnetic &other) const
Equality comparisons.
virtual void readjust(Double res)
Re-adjust using factor given.
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
virtual Double radius()
Get modulus of EarthMagnetic.
MVEarthMagnetic()
Default constructor generates a (0,0,0) EarthMagnetic.
Double operator*(const MVEarthMagnetic &other) const
Multiplication defined as in-product.