casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MVEarthMagnetic.h
Go to the documentation of this file.
00001 //# MVEarthMagnetic.h: A 3D Earth magnetic field vector
00002 //# Copyright (C) 1996,1997,1998,2000
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: MVEarthMagnetic.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_MVEARTHMAGNETIC_H
00029 #define CASA_MVEARTHMAGNETIC_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <casa/Quanta/MVPosition.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward Declarations
00038 
00039 
00040 // <summary> A 3D Earth magnetic field vector </summary>
00041 
00042 // <use visibility=local>
00043 
00044 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
00045 // </reviewed>
00046 
00047 // <prerequisite>
00048 //   <li> <linkto class=MeasValue>MeasValue</linkto>
00049 //   <li> <linkto class=Vector>Vector</linkto>
00050 //   <li> <linkto class=Quantum>Quantum</linkto>
00051 // </prerequisite>
00052 //
00053 // <etymology>
00054 // From Measure, Value and Earth Magnetic field
00055 // </etymology>
00056 //
00057 // <synopsis>
00058 // A MVEarthMagnetic is a 3-vector of the Earth's magnetic flux density in a
00059 // rectangular frame with the z-axis to astronomical North pole, and x-axis
00060 // towards longitude zero, in internal Units of nano tesla (== 0.00001 G).<br>
00061 // It can be constructed with:
00062 // <ul>
00063 //   <li> MVEarthMagnetic() creates  (0,0,0)
00064 //   <li> MVEarthMagnetic(MVEarthMagnetic) creates a copy
00065 //   <li> MVEarthMagnetic(Double, Double, Double) creates (x,y,z) with
00066 //              specified values in tesla
00067 //   <li> MVEarthMagnetic(Quantity length,Double, Double) creates an
00068 //               MVEarthMagnetic assuming
00069 //              that the two values are (in radians) angle along 'equator' 
00070 //              and towards 'pole'.
00071 //   <li> MVEarthMagnetic(Quantity length, Quantity, Quantity) creates an
00072 //               MVEarthMagnetic 
00073 //              assuming angles as in previous, or (x,y,z) fields
00074 //   <li> <src>MVEarthMagnetic(Quantity, Quantum<Vector<Double> >)</src> creates a 
00075 //              MVEarthMagnetic from angle vector, using first two angles, and 
00076 //              assuming second as zero if not present, and pole if length 0.
00077 //   <li> <src>MVEarthMagnetic(Quantum<Vector<Double> ></src> creates from
00078 //              angles or fields, depending on the units in the
00079 //              quantum vector. In the angle case,
00080 //              the data derived can be scaled with the readjust() function. If
00081 //              the unit of the quantum vector is magnetic flux density,
00082 //              magnetic field components are assumed.
00083 //    <li> <src>MVEarthMagnetic(Vector<Double></src> creates from angles (less than
00084 //              or equal to two elements) or x,y,z (3 elements).
00085 //    <li> <src>MVEarthMagnetic(Vector<Quantity></src> creates from length+angles,
00086 //              angles, or x,y,z, depending on units.
00087 // </ul>
00088 // A void adjust(Double) function normalises the vector to a length of 1;
00089 // a get() returns as a
00090 // Double 3-vector the length and angles of the EarthMagnetic vector;
00091 // a getAngle() returns a Quantum 2-vector, (uInt) returns the indicated 
00092 // element, and getValue returns the vector.<br>
00093 // EarthMagnetics can be added and subtracted.<br>
00094 // The multiplication of two EarthMagnetics produces the in-product.<br>
00095 // </synopsis>
00096 //
00097 // <example>
00098 // See <linkto class=MEarthMagnetic>MEarthMagnetic</linkto> class.
00099 // </example>
00100 //
00101 // <motivation>
00102 // To use in ionospheric effect calculations
00103 // </motivation>
00104 //
00105 // <todo asof="1998/05/19">
00106 //      <li> nothing I know of
00107 // </todo>
00108 
00109 class MVEarthMagnetic : public MVPosition {     
00110 
00111 public:
00112 
00113   //# Friends
00114   
00115   //# Constructors
00116   // Default constructor generates a (0,0,0) EarthMagnetic
00117   MVEarthMagnetic();
00118   // Copy constructor
00119   MVEarthMagnetic(const MVPosition &other);
00120   // Creates a specified vector
00121   MVEarthMagnetic(Double in0, Double in1, Double in2);
00122   // Creates a vector with specified length towards pole
00123   // <group>
00124   explicit MVEarthMagnetic(Double in0);
00125   MVEarthMagnetic(const Quantity &l);
00126   // </group>
00127   // Creates the EarthMagnetic from specified (azimuth,elevation) angles and length
00128   MVEarthMagnetic(const Quantity &l, Double angle0, Double angle1);
00129   // Creates the EarthMagnetic from specified angles and length. or EarthMagnetics
00130   // <thrown>
00131   //    <li> AipsError if quantities not in angle format
00132   // </thrown>
00133   // <group>
00134   MVEarthMagnetic(const Quantity &l, const Quantity &angle0, 
00135                   const Quantity &angle1);
00136   // If not enough angles: pole assumed (if none), or elevation =0 (if 1)
00137   MVEarthMagnetic(const Quantum<Vector<Double> > &angle);
00138   MVEarthMagnetic(const Quantity &l, const Quantum<Vector<Double> > &angle);
00139   // </group>
00140   // Create from specified length and/or angles and/or EarthMagnetic
00141   // <group>
00142   MVEarthMagnetic(const Vector<Double> &other);
00143   MVEarthMagnetic(const Vector<Quantity> &other);
00144   // </group>
00145   // Copy assignment
00146   MVEarthMagnetic &operator=(const MVEarthMagnetic &other);
00147   
00148   // Destructor
00149   ~MVEarthMagnetic();
00150   
00151   //# Operators
00152   // Multiplication defined as in-product
00153   // <group>
00154   Double operator*(const MVEarthMagnetic &other) const;
00155   // </group>
00156   
00157   // Equality comparisons
00158   // <group>
00159   Bool operator== (const MVEarthMagnetic &other) const;
00160   Bool operator!= (const MVEarthMagnetic &other) const;
00161   Bool near(const MVEarthMagnetic &other, Double tol=1e-13) const;
00162   Bool near(const MVEarthMagnetic &other, Quantity tol) const;
00163   Bool nearAbs(const MVEarthMagnetic &other, Double tol=1e-13) const;
00164   // </group>
00165   
00166   // Addition and subtraction
00167   // <group>
00168   MVEarthMagnetic operator-() const;
00169   MVEarthMagnetic &operator+=(const MVEarthMagnetic &right);
00170   MVEarthMagnetic operator+(const MVEarthMagnetic &right) const;
00171   MVEarthMagnetic &operator-=(const MVEarthMagnetic &right);
00172   MVEarthMagnetic operator-(const MVEarthMagnetic &right) const;
00173   // </group>
00174   
00175   //# General Member Functions
00176   
00177   // Tell me your type
00178   // <group>
00179   virtual uInt type() const;
00180   static void assure(const MeasValue &in);
00181   // </group>
00182   
00183   // Normalise direction aspects by adjusting the length to 1
00184   // <group>
00185   virtual void adjust();
00186   virtual void adjust(Double &res);
00187   virtual void readjust(Double res);
00188   // </group>
00189   // Get modulus of EarthMagnetic
00190   virtual Double radius();
00191   // Generate a 3-vector of coordinates (length(T), angles(rad))
00192   Vector<Double> get() const;
00193   // Generate a 3-vector of x,y,z in tesla
00194   const Vector<Double> &getValue() const;
00195   // Generate angle 2-vector (in rad)
00196   Quantum<Vector<Double> > getAngle() const;
00197   // and with specified units
00198   Quantum<Vector<Double> > getAngle(const Unit &unit) const;
00199   // Generate the length
00200   Quantity getLength() const;
00201   // and generate it with the specified units
00202   Quantity getLength(const Unit &unit) const;
00203   // Get the EarthMagnetic angle between the directions. I.e. the angle between
00204   // the direction from one to the pole, and from one to the other.
00205   // <group>
00206   Double earthMagneticAngle(const MVEarthMagnetic &other) const;
00207   Quantity earthMagneticAngle(const MVEarthMagnetic &other, 
00208                               const Unit &unit) const;
00209   // </group>
00210   // Get the angular separation between two directions.
00211   // <group>
00212   Double separation(const MVEarthMagnetic &other) const;
00213   Quantity separation(const MVEarthMagnetic &other, 
00214                       const Unit &unit) const;
00215   // </group>
00216   // Produce the cross product
00217   MVEarthMagnetic crossProduct(const MVEarthMagnetic &other) const;
00218   
00219   // Print data
00220   virtual void print(ostream &os) const;
00221   // Clone
00222   virtual MeasValue *clone() const;
00223   // Get the value in internal units
00224   virtual Vector<Double> getVector() const;
00225   // Set the value from internal units (set 0 for empty vector)
00226   virtual void putVector(const Vector<Double> &in);
00227   // Get the internal value as a <src>Vector<Quantity></src>. Usable in
00228   // records. The getXRecordValue() gets additional information for records.
00229   // Note that the Vectors could be empty.
00230   // <group>
00231   virtual Vector<Quantum<Double> > getRecordValue() const;
00232   // </group>
00233   // Set the internal value if correct values and dimensions
00234   virtual Bool putValue(const Vector<Quantum<Double> > &in);
00235 
00236 };
00237 
00238 //# Global functions
00239 // Rotate a EarthMagnetic vector with rotation matrix and other multiplications
00240 // <group>
00241 MVEarthMagnetic operator*(const RotMatrix &left, const MVEarthMagnetic &right);
00242 MVEarthMagnetic operator*(const MVEarthMagnetic &left, const RotMatrix &right);
00243 MVEarthMagnetic operator*(Double left, const MVEarthMagnetic &right);
00244 MVEarthMagnetic operator*(const MVEarthMagnetic &left, Double right);
00245 Double operator*(const Vector<Double> &left, const MVEarthMagnetic &right);
00246 Double operator*(const MVEarthMagnetic &left, const Vector<Double> &right);
00247 Double operator*(const MVPosition &left, const MVEarthMagnetic &right);
00248 Double operator*(const MVEarthMagnetic &left, const MVPosition &right);
00249 // </group>
00250 
00251 
00252 } //# NAMESPACE CASA - END
00253 
00254 #endif