casa
$Rev:20696$
|
00001 //# MeasTable.h: MeasTable provides Measure computing database data 00002 //# Copyright (C) 1995-1999,2000-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: MeasTable.h 21130 2011-10-18 07:39:05Z gervandiepen $ 00028 00029 #ifndef MEASURES_MEASTABLE_H 00030 #define MEASURES_MEASTABLE_H 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <measures/Measures/MeasData.h> 00035 #include <measures/Measures/MPosition.h> 00036 #include <measures/Measures/MDirection.h> 00037 #include <measures/Measures/MFrequency.h> 00038 #include <scimath/Functionals/Polynomial.h> 00039 #include <casa/OS/Mutex.h> 00040 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 00043 //# Forward Declarations 00044 class RotMatrix; 00045 class Euler; 00046 00047 // <summary> 00048 // MeasTable provides Measure computing database data 00049 // </summary> 00050 00051 // <use visibility=local> 00052 00053 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasMath" demos=""> 00054 // </reviewed> 00055 00056 // <prerequisite> 00057 // <li> <linkto class=Measure>Measure</linkto> class 00058 // <li> <linkto class=MeasData>MeasData</linkto> class for constant data 00059 // <li> <linkto class=Aipsrc>Aipsrc</linkto> class for data placement 00060 // </prerequisite> 00061 // 00062 // <etymology> 00063 // MeasTable from Measure and Table 00064 // </etymology> 00065 // 00066 // <synopsis> 00067 // MeasTable contains the database interface for all 00068 // data necessary for precession, nutation and other 00069 // <linkto class=Measure>Measure</linkto> related calculations.<br> 00070 // All data are obtained by calls to a method. E.g. 00071 // <src> fundArg(1) </src> will provide the first fundamental argument for 00072 // nutation calculations, i.e. 'l'. <br> 00073 // This class contains no constructors or destructors, only static 00074 // methods and (static) constants. 00075 // <br> References:<br> Explanatory supplements to the Astronomical Almanac 00076 // <br> C. Ron and J. Vondrak, Bull. Astron. Inst. Czechosl. 37, p96, 1986 00077 // <br> M. Soma, Th. Hirayama and H. Kinoshita, Celest. Mech. 41, p389, 1988 00078 // <br> V.S. Gubanov, Astron. Zh. 49, p1112, 1972 00079 // 00080 // Where strings are passed in as arguments (observatory names, sources), they 00081 // will be case insensitive, and minimum match. 00082 // </synopsis> 00083 // 00084 // <example> 00085 // Usage examples can be found in <linkto class=Precession>Precession</linkto> 00086 // </example> 00087 // 00088 // <motivation> 00089 // To create a clean interface between the actual calculations and the 00090 // methods to obtain the parameters for these calculations. Note that the 00091 // tables are in general in the format and units found in the literature. This 00092 // is to be able to easy check and change them. However, in the future 00093 // re-arrangement could produce faster and more compact code. 00094 // </motivation> 00095 // 00096 // <todo asof="1997/09/02"> 00097 // <li> more database interfaces, rather than constants 00098 // </todo> 00099 00100 class MeasTable { 00101 00102 public: 00103 00104 //# Enumerations 00105 // Types to be used in different calls 00106 enum Types { 00107 // Planetary information 00108 MERCURY = 1, 00109 VENUS = 2, 00110 EARTH = 3, 00111 MARS = 4, 00112 JUPITER = 5, 00113 SATURN = 6, 00114 URANUS = 7, 00115 NEPTUNE = 8, 00116 PLUTO = 9, 00117 MOON = 10, 00118 SUN = 11, 00119 // Solar system barycentre 00120 BARYSOLAR = 12, 00121 // Earth-Moon system barycentre 00122 BARYEARTH = 13, 00123 // Nutations 00124 NUTATION = 14, 00125 // Librations 00126 LIBRATION = 15, 00127 // Number of types 00128 N_Types }; 00129 00130 // Codes for JPL constants: order should be same as in MeasJPL, length less 00131 // than or equal 00132 enum JPLconst { 00133 // Light velocity used in AU/d 00134 CAU, 00135 // Solar mass (GM0)/c<sup>2</sup> in AU 00136 GMS, 00137 // AU in km 00138 AU, 00139 // Solar radius in AU 00140 RADS, 00141 // # of codes 00142 N_JPLconst }; 00143 00144 //# General Member Functions 00145 // Selection related data 00146 // <group> 00147 // Are the IAU2000 precession/nutation to be used or not (IAU1984) 00148 static Bool useIAU2000(); 00149 // If IAU2000 model, do we use the high precision 2000A model? 00150 static Bool useIAU2000A(); 00151 // </group> 00152 00153 // Precession related data 00154 // <group> 00155 // Get the precession-rate part of the IAU2000 precession-nutation models 00156 // (which 0=dpsi (long) and 1=deps (obliquity) and 2 =0) 00157 static Double precRate00(const uInt which); 00158 00159 // Get the frame bias matrix for IAU2000 model. 00160 static RotMatrix frameBias00(); 00161 00162 // Generate the precession calculation polynomials for a fixed Epoch T 00163 // in the result area specified. 00164 // T is given in Julian centuries since J2000.0. 00165 static void 00166 precessionCoef(Double T, Polynomial<Double> result[3]); 00167 00168 // Generate the precession polynomials for IAU2000 system. 00169 static void 00170 precessionCoef2000(Polynomial<Double> result[3]); 00171 00172 // Generate the precession polynomials for 1950 system for a fixed Epoch T 00173 // in the area specified. T is given in Tropical centuries since B1850.0 00174 static void 00175 precessionCoef1950(Double T, Polynomial<Double> result[3]); 00176 // </group> 00177 00178 // Nutation related data 00179 // <group> 00180 // Generate the polynomial for the fundamental arguments (eps, l, l', 00181 // F, D, omega) as a function of Julian centuries 00182 // <group> 00183 static const Polynomial<Double> &fundArg(uInt which); 00184 static const Polynomial<Double> &fundArg1950(uInt which); 00185 static const Polynomial<Double> &fundArg2000(uInt which); 00186 // </group> 00187 00188 // Get the planetary arguments (L, L', F, D, Om, Me, Ve, E, Ma, Ju Sa, 00189 // Ur, Ne, pre) 00190 static const Polynomial<Double> &planetaryArg2000(uInt which); 00191 00192 // Generate the which' vector of the nutation series arguments 00193 // <group> 00194 static const Vector<Char> &mulArg(uInt which); 00195 static const Vector<Char> &mulArg1950(uInt which); 00196 static const Vector<Char> &mulArg2000A(uInt which); 00197 static const Vector<Char> &mulArg2000B(uInt which); 00198 static const Vector<Char> &mulPlanArg2000A(uInt which); 00199 // </group> 00200 00201 // Generate the which' vector of the equation of equinoxes (IAU2000) 00202 // complementary terms series arguments 00203 static const Vector<Char> &mulArgEqEqCT2000(uInt which); 00204 00205 // Generate the which' vector of the nutation series multipliers 00206 // at T, measured in Julian centuries since J2000.0, respectively B1900.0 00207 // <group> 00208 static const Vector<Double> &mulSC(uInt which, Double T); 00209 static const Vector<Double> &mulSC1950(uInt which, Double T); 00210 static const Vector<Double> &mulSC2000A(uInt which, Double T); 00211 static const Vector<Double> &mulSC2000B(uInt which, Double T); 00212 static const Vector<Double> &mulPlanSC2000A(uInt which); 00213 // </group> 00214 00215 // Generate the which' vector of the equation of equinoxes (IAU2000) 00216 // complementary terms series multipliers 00217 // at T, measured in Julian centuries since J2000.0, respectively B1900.0 00218 static const Vector<Double> &mulSCEqEqCT2000(uInt which); 00219 00220 // Get nutation angles corrections for UTC T in rad. 00221 // which = 0 : dPsi as given by IERS for IAU nutation theory; 00222 // = 1: dEps as same. 00223 static Double dPsiEps(uInt which, Double T); 00224 // </group> 00225 00226 // Planetary (JPL DE) related data 00227 // <group> 00228 // Get the position (AU or rad) and velocity (AU/d or rad/d) for specified 00229 // code at TDB T. The ephemeris to use (now DE200 or DE405) can be selected 00230 // with the 'measures.jpl.ephemeris' aipsrc resource (default DE200). 00231 static const Vector<Double> &Planetary(MeasTable::Types which, 00232 Double T); 00233 // Get the JPL DE constant indicated 00234 static const Double &Planetary(MeasTable::JPLconst what); 00235 // </group> 00236 00237 // Observatory positions 00238 // <group> 00239 // Initialise list of all observatories from Observatories table 00240 static void initObservatories(); 00241 // Get list of all observatories 00242 static const Vector<String> &Observatories(); 00243 // Get position of observatory nam (False if not present) 00244 static Bool Observatory(MPosition &obs, const String &nam); 00245 // Get _absolute_ path to AntennaResponses table of observatory nam (False if no _valid_ path 00246 // can be found or the observatory is unknown; if the observatory is known, antRespPath will 00247 // be set to the entry in the AntennaResponses column of the Observatories table even 00248 // if it doesn't describe a valid path; if the entry is not an absolute path, the 00249 // data directory name will be prepended and validity verified) 00250 static Bool AntennaResponsesPath(String &antRespPath, const String &nam); 00251 // </group> 00252 00253 // Source list positions 00254 // <group> 00255 // Initialise list of all source from Sources table 00256 static void initSources(); 00257 // Get list of all sources 00258 static const Vector<String> &Sources(); 00259 // get position of source nam (False if not present) 00260 static Bool Source(MDirection &obs, const String &nam); 00261 // </group> 00262 00263 // Rest frequencies 00264 // <group> 00265 // Initialise list from internal Table for now 00266 static void initLines(); 00267 // Get list of all frequencies 00268 static const Vector<String> &Lines(); 00269 // Get frequency of line name (False if not present) 00270 static Bool Line(MFrequency &obs, const String &nam); 00271 // </group> 00272 00273 // Earth magnetic field (IGRF) data 00274 // <group> 00275 // Get the harmonic terms for specified time (mjd) 00276 static const Vector<Double> &IGRF(Double t); 00277 // </group> 00278 00279 // Aberration related data 00280 // <group> 00281 // Generate the polynomial for the fundamental arguments (l1-l8, w, D, l, 00282 // l', F) for the Ron/Vondrak aberration calculations as a function of 00283 // Julian centuries(J2000), or the comparable ones for the Gubanov expansion 00284 // (B1950). 00285 // <group> 00286 static const Polynomial<Double> &aberArg(uInt which); 00287 static const Polynomial<Double> &aber1950Arg(uInt which); 00288 // </group> 00289 00290 // Generate the 'which' vector of the aberration series arguments 00291 // <group> 00292 static const Vector<Char> &mulAberArg(uInt which); 00293 static const Vector<Char> &mulAber1950Arg(uInt which); 00294 static const Vector<Char> &mulAberSunArg(uInt which); 00295 static const Vector<Char> &mulAberEarthArg(uInt which); 00296 // </group> 00297 00298 // Generate the 'which' vector of the aberration series multipliers 00299 // at T, measured in Julian centuries since J2000.0 (or J1900.0, yes, 00300 // J1900.0, for B1950). 00301 // <group> 00302 static const Vector<Double> &mulAber(uInt which, Double T); 00303 static const Vector<Double> &mulAber1950(uInt which, Double T); 00304 static const Vector<Double> &mulSunAber(uInt which); 00305 static const Vector<Double> &mulEarthAber(uInt which); 00306 // </group> 00307 00308 // Get the E-terms of Aberration correction (0 for position, 1 for velocity) 00309 // <group> 00310 static const Vector<Double> &AberETerm(uInt which); 00311 // </group> 00312 00313 // </group> 00314 00315 // Diurnal aberration factor 00316 static Double diurnalAber(Double radius, Double T); 00317 00318 // LSR (kinematical) velocity conversion: 0 gives J2000; 1 gives B1950. 00319 // In both cases a velocity of 20.0 km/s is assumed, and a B1900 RA/Dec 00320 // direction of (270,30) degrees. This value has been defined between 00321 // the groups doing HI radio work in the mid 1950s. 00322 static const Vector<Double> &velocityLSRK(uInt which); 00323 // LSR (dynamical, IAU definition). Velocity (9,12,7) km/s in galactic 00324 // coordinates. Or 16.552945 towards l,b = 53.13, +25.02 deg. 00325 // 0 gives J2000, 1 gives B1950 velocities. 00326 static const Vector<Double> &velocityLSR(uInt which); 00327 // Velocity of LSR with respect to galactic centre. 220 km/s in direction 00328 // l,b = 270, +0 deg. 0 returns J2000, 1 B1950 00329 static const Vector<Double> &velocityLSRGal(uInt which); 00330 // Velocity of Local Group wrt bary center (F.Ghigo): 308km/s towards 00331 // l,b = 105,-7. 0 for J2000, 1 for B1950 00332 static const Vector<Double> &velocityCMB(uInt which); 00333 // Velocity of CMB wrt bary center (F.Ghigo): 369.5km/s towards 00334 // l,b = 264.4,48.4. 0 for J2000, 1 for B1950 00335 00336 static const Vector<Double> &velocityLGROUP(uInt which); 00337 // Earth and Sun position related data 00338 // <group> 00339 // Fundamental arguments for Soma et al. methods 00340 // <group> 00341 static const Polynomial<Double> &posArg(uInt which); 00342 // </group> 00343 // Generate the which' vector of the position series arguments 00344 // <group> 00345 static const Vector<Char> &mulPosEarthXYArg(uInt which); 00346 static const Vector<Char> &mulPosEarthZArg(uInt which); 00347 static const Vector<Char> &mulPosSunXYArg(uInt which); 00348 static const Vector<Char> &mulPosSunZArg(uInt which); 00349 // </group> 00350 00351 // Generate the which' vector of the position series multipliers 00352 // at T, measured in Julian centuries since J2000.0 00353 // <group> 00354 static const Vector<Double> &mulPosEarthXY(uInt which, Double T); 00355 static const Vector<Double> &mulPosEarthZ(uInt which, Double T); 00356 static const Vector<Double> &mulPosSunXY(uInt which, Double T); 00357 static const Vector<Double> &mulPosSunZ(uInt which, Double T); 00358 // </group> 00359 // Get the rotation matrix to change position from ecliptic to rectangular 00360 // for Soma et al. analytical expression 00361 static const RotMatrix &posToRect(); 00362 // Get the rotation matrix to change position from rectangular to ecliptic 00363 // for Soma et al. analytical expression 00364 static const RotMatrix &rectToPos(); 00365 // Get the rotation matrix from galactic to supergalactic. 00366 // Based on De Vaucouleurs 1976: Pole at 47.37/6.32 deg; 137.37 l0 00367 // Euler angles: 90, 83.68, 47.37 degrees 00368 static const RotMatrix &galToSupergal(); 00369 // Get the rotation matrix from ICRS to J2000/FK5. 00370 // Based on the IAU 2000 resolutions (the bias matrix) 00371 static const RotMatrix &ICRSToJ2000(); 00372 // </group> 00373 00374 // Position related routines 00375 // <group> 00376 // Equatorial radius (0) and flattening(1) of geodetic reference spheroids 00377 static Double WGS84(uInt which); 00378 // </group> 00379 00380 // Polar motion related routines 00381 // <group> 00382 // Get the polar motion (-x,-y,0)(2,1,3) angles 00383 static const Euler &polarMotion(Double ut); 00384 // </group> 00385 00386 // Time related routines 00387 // <note> 00388 // WARNING given if correction not obtainable 00389 // </note> 00390 // <thrown> 00391 // <li> AipsError if table seems to be corrupted 00392 // </thrown> 00393 // <group> 00394 // Give TAI-UTC (in s) for MJD utc UTC 00395 static Double dUTC(Double utc); 00396 // UT1-UTC (in s) for MJD tai TAI 00397 static Double dUT1(Double utc); 00398 // TDT-TAI (in s) for MJD tai TAI. Note this is equal to TT2000-TAI 00399 static Double dTAI(Double tai=0.0); 00400 // TDB-TDT (in s) for MJD ut1 UT1 00401 static Double dTDT(Double ut1); 00402 // TCB-TDB (in s) for MJD tai TAI 00403 static Double dTDB(Double tai); 00404 // TCG-TT (in s) for MJD tai TAI 00405 static Double dTCG(Double tai); 00406 // GMST1 at MJD ut1 UT1 00407 static Double GMST0(Double ut1); 00408 // GMST (IAU2000) including the ERA (IAU2000 Earth Rotation Angle) in rad 00409 static Double GMST00(Double ut1, Double tt); 00410 // Earth Rotation Angle (IAU2000) in rad 00411 static Double ERA00(Double ut1); 00412 // s' (IAU2000) in rad (approximate value) 00413 static Double sprime00(Double tt); 00414 // UT1 at GMSD gmst1 GMST1 00415 static Double GMUT0(Double gmst1); 00416 // Ratio UT1/MST at MJD ut1 UT1 00417 static Double UTtoST(Double ut1); 00418 // </group> 00419 00420 private: 00421 00422 // Copy assign, NOT defined 00423 MeasTable &operator=(const MeasTable &other); 00424 00425 //# General member functions 00426 00427 static void doInitObservatories (void*); 00428 static void doInitLines (void*); 00429 static void doInitSources (void*); 00430 00431 // Calculate precessionCoef 00432 // <group> 00433 static void calcPrecesCoef(Double T, Polynomial<Double> result[3], 00434 const Double coeff[3][6]); 00435 static void calcPrecesCoef2000(Polynomial<Double> result[3], 00436 const Double coeff[3][6]); 00437 // </group> 00438 00439 // Calculate fundArg 00440 // <group> 00441 static void calcFundArg(volatile Bool &need, Polynomial<Double> result[6], 00442 const Double coeff[6][4]); 00443 static void calcFundArg00(volatile Bool &need, Polynomial<Double> result[6], 00444 const Double coeff[6][5]); 00445 static void calcPlanArg00(volatile Bool &need, 00446 Polynomial<Double> result[14], 00447 const Double coeff[8][2]); 00448 // </group> 00449 00450 // Calculate mulArg 00451 // <group> 00452 static void calcMulArg(volatile Bool &need, Vector<Char> result[], 00453 const Char coeff[][5], Int row); 00454 static void calcMulPlanArg(volatile Bool &need, Vector<Char> result[], 00455 const Char coeff[][14], Int row); 00456 // </group> 00457 00458 // Calculate mulSC 00459 // <group> 00460 static void calcMulSC(volatile Bool &need, Double &check, Double T, 00461 Vector<Double> result[], Int resrow, 00462 Polynomial<Double> poly[], 00463 const Long coeffTD[][5], Int TDrow, 00464 const Short coeffSC[][2]); 00465 static void calcMulSC2000(volatile Bool &need, Double &check, Double T, 00466 Vector<Double> result[], uInt resrow, 00467 Polynomial<Double> poly[], 00468 const Long coeffSC[][6]); 00469 static void calcMulSCPlan(volatile Bool &need, 00470 Vector<Double> result[], uInt resrow, 00471 const Short coeffSC[][4]); 00472 static void calcMulSCPlan(volatile Bool &need, 00473 Vector<Double> result[], uInt resrow, 00474 const Double coeffSC[][2]); 00475 // </group> 00476 //# Data 00477 // Observatories table data 00478 // <group> 00479 static MutexedInit obsMutexedInit; 00480 static Vector<String> obsNams; 00481 static Vector<MPosition> obsPos; 00482 static Vector<String> antResponsesPath; 00483 // </group> 00484 // Spectral line table data 00485 // <group> 00486 static MutexedInit lineMutexedInit; 00487 static Vector<String> lineNams; 00488 static Vector<MFrequency> linePos; 00489 // </group> 00490 // Sources table data 00491 // <group> 00492 static MutexedInit srcMutexedInit; 00493 static Vector<String> srcNams; 00494 static Vector<MDirection> srcPos; 00495 // </group> 00496 // IGRF data 00497 // <group> 00498 static Double timeIGRF; 00499 static Double dtimeIGRF; 00500 static Double time0IGRF; 00501 static Double firstIGRF; 00502 static Double lastIGRF; 00503 static Vector<Double> coefIGRF; 00504 static Vector<Double> dIGRF; 00505 static Vector<Double> resIGRF; 00506 // </group> 00507 // Aipsrc registration (for speed) of use of iau2000 and if so 00508 // the 2000a version 00509 // <group> 00510 static uInt iau2000_reg; 00511 static uInt iau2000a_reg; 00512 // </group> 00513 // Mutex for thread-safety. 00514 static Mutex theirMutex; 00515 }; 00516 00517 00518 } //# NAMESPACE CASA - END 00519 00520 #endif