casa
$Rev:20696$
|
00001 //# MEarthMagnetic.h: A Measure: Magnetic field on Earth 00002 //# Copyright (C) 1995-1999,2000,2002,2004 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 //# 00027 //# $Id: MEarthMagnetic.h 21298 2012-12-07 14:53:03Z gervandiepen $ 00028 00029 #ifndef MEASURES_MEARTHMAGNETIC_H 00030 #define MEASURES_MEARTHMAGNETIC_H 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <measures/Measures/MeasBase.h> 00035 #include <measures/Measures/MeasRef.h> 00036 #include <casa/Quanta/MVEarthMagnetic.h> 00037 00038 namespace casa { //# NAMESPACE CASA - BEGIN 00039 00040 //# Forward Declarations 00041 class MEarthMagnetic; 00042 class MCEarthMagnetic; 00043 template <class M> class MeasConvert; 00044 template <class M> class ArrayMeasColumn; 00045 template <class M> class ScalarMeasColumn; 00046 00047 //# Typedefs 00048 00049 // <summary> A Measure: Magnetic field on Earth </summary> 00050 00051 // <use visibility=export> 00052 00053 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos=""> 00054 // </reviewed> 00055 00056 // <prerequisite> 00057 // <li> <linkto class=Measure>Measure</linkto> class 00058 // </prerequisite> 00059 // 00060 // <etymology> 00061 // Earth and Magnetic field 00062 // </etymology> 00063 // 00064 // <synopsis> 00065 // MEarthMagnetic forms derived Measure class for Earth' magnetic flux density. 00066 // The field can be specified as a model, or as a 3D vector (see 00067 // <linkto class=MVEarthMagnetic>MVEarthMagnetic</linkto>) with a specified 00068 // reference frame code. If a model is specified, a possibly specified 00069 // explicit field will be ignored, since the field will be calculated from 00070 // the model if a conversion is asked for.<br> 00071 // The class contains the following magnetic field models: 00072 // <ul> 00073 // <li> IGRF international reference field 00074 // </ul> 00075 // The reference frame type can be any of the types specified in the 00076 // <linkto class=MDirection>MDirection</linkto> direction types (e.g. AZEL). 00077 // <note role=warning> 00078 // The IGRF needs a Table of coefficients (at 5-year interval) </note> 00079 // 00080 // Conversion between field models is not supported (but not relevant 00081 // anyway with only one model supported). Conversion to an explicit direction 00082 // is done by the standard <linkto class=MeasConvert>MeasConvert</linkto> 00083 // class and rules (see example) using <em>MEarthMagnetic::Convert</em>, 00084 // and the reference types (e.g. MEarthMagnetic::AZEL). 00085 // 00086 // An <linkto class=EarthMagneticMachine> EarthMagneticMachine</linkto> has 00087 // been provided to get e.g. the field in a certain direction at a 00088 // certain height. 00089 // 00090 // </synopsis> 00091 // 00092 // <example> 00093 // <srcblock> 00094 // // Where on Earth 00095 // MPosition pos(MVPosition(Quantity(20,'m'), Quantity(5,'deg'), 00096 // Quantity(52,'deg')), MPosition::WGS84); 00097 // // Time we want it 00098 // MEpoch epo(MVEpoch(50000)); 00099 // // Put in frame 00100 // MeasFrame frame(pos, epo); 00101 // // Magnetic field model 00102 // MEarthMagnetic mf; 00103 // // Show field strength in Gauss in AzEl system 00104 // cout << 00105 // MEarthMagnetic::Convert(mf, MEarthMagnetic::AZEL)(). 00106 // getValue().getLength("G") << endl; 00107 // </srcblock> 00108 // </example> 00109 // 00110 // <motivation> 00111 // To have the Earth' magnetic field in the standard Measure environment. 00112 // </motivation> 00113 // 00114 // <todo asof="2000/06/15"> 00115 // <li> maybe add other field models if necessary (e.g. dipole) 00116 // </todo> 00117 00118 class MEarthMagnetic : public MeasBase<MVEarthMagnetic, MeasRef<MEarthMagnetic> > { 00119 00120 public: 00121 //# Friends 00122 // Conversion of data 00123 friend class MeasConvert<MEarthMagnetic>; 00124 00125 //# Enumerations 00126 // Types of known MEarthMagnetics 00127 // <note role=tip> The order defines the order in the translation matrix 00128 // FromTo 00129 // in the getConvert routine in MCEarthMagnetic. Do not change the order 00130 // without changing the array. Additions should be made before N_types, and 00131 // an additional row and column should be coded in FromTo, and 00132 // in showType().</note> 00133 enum Types { 00134 J2000, 00135 JMEAN, 00136 JTRUE, 00137 APP, 00138 B1950, 00139 BMEAN, 00140 BTRUE, 00141 GALACTIC, 00142 HADEC, 00143 AZEL, 00144 AZELSW, 00145 AZELGEO, 00146 AZELSWGEO, 00147 JNAT, 00148 ECLIPTIC, 00149 MECLIPTIC, 00150 TECLIPTIC, 00151 SUPERGAL, 00152 ITRF, 00153 TOPO, 00154 ICRS, 00155 N_Types, 00156 // Models. First one should be IGRF 00157 IGRF = 32, 00158 N_Models, 00159 // All extra bits (for internal use only) 00160 EXTRA = 32, 00161 // Defaults 00162 DEFAULT=IGRF, 00163 // Synonyms 00164 AZELNE=AZEL, 00165 AZELNEGEO=AZELGEO 00166 }; 00167 00168 //# Typedefs 00169 // Measure value container for this class (i.e. MEarthMagnetic::MVType) 00170 typedef MVEarthMagnetic MVType; 00171 // Measure conversion routines for this class (i.e. MEarthMagnetic::MCType) 00172 typedef MCEarthMagnetic MCType; 00173 // Measure reference (i.e. MEarthMagnetic::Ref) 00174 typedef MeasRef<MEarthMagnetic> Ref; 00175 // Measure Convert (i.e. MEarthMagnetic::Convert) 00176 typedef MeasConvert<MEarthMagnetic> Convert; 00177 // Measure table Columns (e.g., MEarthMagnetic::ScalarColumn) 00178 typedef ScalarMeasColumn<MEarthMagnetic> ScalarColumn; 00179 typedef ArrayMeasColumn<MEarthMagnetic> ArrayColumn; 00180 // Reference enum Types (included originally for gcc 2.95) 00181 typedef WHATEVER_SUN_TYPEDEF(MEarthMagnetic) Types Types; 00182 00183 //# Constructors 00184 // <note> In the following constructors and other functions, all 00185 // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src> 00186 // where no offsets or frames are needed in the reference. </note> 00187 // Default constructor; generates the default IGRF type 00188 MEarthMagnetic(); 00189 // Create from data and reference 00190 // <group> 00191 MEarthMagnetic(const MVEarthMagnetic &dt); 00192 MEarthMagnetic(const MVEarthMagnetic &dt, const MEarthMagnetic::Ref &rf); 00193 MEarthMagnetic(const MVEarthMagnetic &dt, MEarthMagnetic::Types rf); 00194 MEarthMagnetic(const Measure *dt); 00195 MEarthMagnetic(const MeasValue *dt); 00196 MEarthMagnetic(const MEarthMagnetic::Ref &rf); 00197 // </group> 00198 00199 // <group> 00200 MEarthMagnetic(const MEarthMagnetic &); 00201 MEarthMagnetic &operator=(const MEarthMagnetic &); 00202 // </group> 00203 00204 //# Destructor 00205 virtual ~MEarthMagnetic(); 00206 00207 //# Operators 00208 00209 //# General Member Functions 00210 // Tell me your type 00211 // <group> 00212 virtual const String &tellMe() const; 00213 static const String &showMe(); 00214 virtual uInt type() const; 00215 static void assure(const Measure &in); 00216 // </group> 00217 // Translate reference code. The uInt version has a check for valid codes 00218 // (i.e. it is a safe cast). 00219 // <thrown> 00220 // <li> AipsError in the uInt interface if illegal code given 00221 // </thrown> 00222 // <group> 00223 static MEarthMagnetic::Types castType(uInt tp); 00224 static const String &showType(MEarthMagnetic::Types tp); 00225 static const String &showType(uInt tp); 00226 // </group> 00227 // Translate string to reference code 00228 // <group> 00229 static Bool getType(MEarthMagnetic::Types &tp, const String &in); 00230 Bool giveMe(MEarthMagnetic::Ref &mr, const String &in); 00231 // </group> 00232 // Set the offset in the reference (False if non-matching Measure) 00233 virtual Bool setOffset(const Measure &in); 00234 // Set the reference type to the specified String. False if illegal 00235 // string, reference set to DEFAULT. 00236 virtual Bool setRefString(const String &in); 00237 // Get the default reference type 00238 virtual const String &getDefaultType() const; 00239 // Get a list of all known reference codes. nall returns the number in list, 00240 // nextra the number of specials (like planets) that should be at 00241 // end of list). typ returns the list of corresponding types. 00242 // <group> 00243 virtual const String* allTypes(Int &nall, Int &nextra, 00244 const uInt *&typ) const; 00245 static const String* allMyTypes(Int &nall, Int &nextra, 00246 const uInt *&typ); 00247 // </group> 00248 // Check if all internal tables of types (both enum and String) are 00249 // complete and correct. This function is called automatically if and when 00250 // necessary. 00251 // <thrown> 00252 // <li> AipsError if a (programming) error in the types. 00253 // </thrown> 00254 // <group> 00255 virtual void checkTypes() const; 00256 static void checkMyTypes(); 00257 // </group> 00258 // Get the reference type (for records, including codes like R_) 00259 virtual String getRefString() const; 00260 // Get my type (as Register) 00261 static uInt myType(); 00262 // Tell me if you are a pure model (e.g. a planet) 00263 virtual Bool isModel() const; 00264 00265 // Get Measure data 00266 // <group> 00267 Quantum<Vector<Double> > get(const Unit &inunit) const; 00268 Quantum<Vector<Double> > getAngle() const; 00269 Quantum<Vector<Double> > getAngle(const Unit &inunit) const; 00270 // </group> 00271 00272 // Make copy 00273 virtual Measure *clone() const; 00274 00275 private: 00276 //# Enumerations 00277 00278 //# Data 00279 00280 //# Member functions 00281 00282 }; 00283 00284 00285 } //# NAMESPACE CASA - END 00286 00287 #endif