casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Precession.h
Go to the documentation of this file.
00001 //# Precession.h: Precession class
00002 //# Copyright (C) 1995,1996,1997,1998,1999,2002,2003
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: Precession.h 18093 2004-11-30 17:51:10Z ddebonis $
00028 
00029 #ifndef MEASURES_PRECESSION_H
00030 #define MEASURES_PRECESSION_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/Quanta/Euler.h>
00035 #include <scimath/Functionals/Polynomial.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 //# Forward Declarations
00040 
00041 // <summary> Precession class and calculations </summary>
00042 
00043 // <use visibility=export>
00044 
00045 // <reviewed reviewer="Tim Cornwell" date="1996/07/01" tests="tMeasMath"
00046 //       demos="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //   <li> <linkto class=Measure>Measure</linkto> class for use
00051 //   <li> <linkto class=Euler>Euler</linkto> class for format
00052 //   <li> <linkto class=MeasData>MeasData</linkto> class for constants
00053 //   <li> <linkto class=MeasTable>MeasTable</linkto> class for other data
00054 // </prerequisite>
00055 //
00056 // <etymology>
00057 // Precession
00058 // </etymology>
00059 //
00060 // <synopsis>
00061 // Precession forms the class for precession calculations. It is a simple
00062 // container with the selected method, and the mean epoch. It acts as a cache
00063 // for values and their derivatives, to enable fast calculations for time
00064 // epochs close together (see the <em>aipsrc</em> variable
00065 // <em>measures.precession.d_interval</em>. <br>
00066 // The calculation method is selected from one of the following:
00067 // <ul>
00068 //   <li> Precession::STANDARD  (at 1995/09/04 the IAU1976 definition,
00069 //                      at 2004/01/01 the IAU2000 defeinition))
00070 //   <li> Precession::NONE      (precession of zero returned
00071 //   <li> Precession::IAU1976
00072 //   <li> Precession::B1950
00073 //   <li> Precession::IAU2000
00074 // </ul>
00075 // Epochs can be specified as the MJD (with defined constants
00076 // MeasData::MJD2000 and MeasData::MJD1950 or the actual MJD),
00077 // leading to the following constructors:
00078 // <ul>
00079 //   <li> Precession() default; assuming JD2000, STANDARD
00080 //   <li> Precession(method) assuming the correct default epoch of 
00081 //              JD2000 or JD1950 depending on method
00082 //   <li> Precession(method,epoch) with epoch Double(MJD) (Note: not
00083 //              valid for IAU2000: in that case always JD2000 assumed)
00084 // </ul>
00085 // Actual precession for a certain Epoch (TT for IAU2000) is calculated by
00086 // the () operator
00087 // as Precession(epoch), with epoch Double MJD. Values returned  as an 
00088 // <linkto class=Euler>Euler</linkto>.
00089 // The derivative (d<sup>-1</sup>) can be obtained as well by 
00090 // derivative(epoch). <br>
00091 // A Precession can be re-initialed with a different method and/or zero
00092 // epoch with the <src>init()</src> functions (same format as constructors).
00093 // To bypass the full calculation actual returned values are calculated
00094 // using the derivative if within about 2 hours (error less than about
00095 // 10<sup>-5</sup> mas). A call to refresh() will re-initiate calculations
00096 // from scratch.<br>
00097 // The following details can be set with the 
00098 // <linkto class=Aipsrc>Aipsrc</linkto> mechanism:
00099 // <ul>
00100 //  <li> measures.precession.d_interval: approximation interval as time 
00101 //      (fraction of days is default unit) over which linear approximation
00102 //      is used (default is 0.1 day).
00103 // </ul>
00104 // </synopsis>
00105 //
00106 // <example>
00107 //  <srcblock>
00108 // #include <measures/Measures.h>
00109 //      MVDirection pos(Quantity(10,"degree"),Quantity(-10.5,"degree"));
00110 //                                              // direction RA=10; DEC=-10.5
00111 //      Precession mine(Precession::IAU1976);   // define precession type
00112 //      RotMatrix rotat(mine(45837.0));         // rotation matrix for 84/05/17
00113 //      MVDirection new = rotat*pos;            // apply precession
00114 //      rotat = RotMatrix(mine(45839.0));       // interpolate new precession
00115 //                                              // assuming d_interval set large
00116 //  </srcblock>
00117 // </example>
00118 //
00119 // <motivation>
00120 // To calculate the precession angles. An alternate route could have been
00121 // a global function, but having a simple container allows caching of some
00122 // calculations for speed.<br>
00123 // Using MJD (JD-2400000.5) rather than JD is for precision reasons.
00124 // </motivation>
00125 //
00126 // <todo asof="2003/09/18">
00127 //   <li> Adjust on 2004/01/01
00128 // </todo>
00129 
00130 class Precession {
00131  public:
00132   //# Constants
00133   // Default interval to be used for linear approximation (in days)
00134   static const Double INTV;
00135   
00136   //# Enumerations
00137   // Types of known precession calculations (at 1995/09/04 STANDARD ==
00138   //     IAU1976), from 2004/01/01 will be IAU2000)
00139 
00140   enum PrecessionTypes {
00141     NONE, IAU1976, B1950, IAU2000,
00142     IAU2000A = IAU2000, IAU2000B = IAU2000,
00143     STANDARD = IAU1976 };
00144   
00145   //# Constructors
00146   // Default constructor, generates default J2000 precession identification
00147   Precession();
00148   // Copy constructor (deep copy)
00149   Precession(const Precession &other);
00150   // Constructor with epoch in Julian days
00151   explicit Precession(PrecessionTypes type, Double catepoch=0);
00152   // Copy assignment (deep copy)
00153   Precession &operator=(const Precession &other);
00154   
00155   //# Destructor
00156   ~Precession();
00157   
00158   //# Operators
00159   // Return the precession angles (for IAU2000 including
00160   // the IAU 2000 corrections) at the specified epoch (in MJD; TT for IAU2000).
00161   const Euler &operator()(Double epoch);
00162   
00163   //# General Member Functions
00164   // Return derivative of precession (d<sup>-1</sup>)
00165   const Euler &derivative(Double epoch);
00166   // Re-initialise Precession object
00167   // <group>
00168   void init();
00169   void init(PrecessionTypes type, Double catepoch=0);
00170   // </group>
00171   // Refresh calculations
00172   void refresh();
00173 
00174  private:
00175   //# Data members
00176   // Method to be used
00177   PrecessionTypes method_p;
00178   // Fixed epoch to be used (MJD)
00179   Double fixedEpoch_p;
00180   // Fixed epoch in centuries from base epoch
00181   Double T_p;
00182   // Length of century (depending on Bessel or Julian days)
00183   Double cent_p;
00184   // Reference epoch;
00185   Double refEpoch_p;
00186   // Check epoch
00187   Double checkEpoch_p;
00188   // Polynomial coefficients for zeta,z,theta
00189   Polynomial<Double> zeta_p[3];
00190   // Cached calculated angles
00191   Double pval_p[3];
00192   // Cached derivatives
00193   Double dval_p[3];
00194   // To reference results, and use a few in interim calculations, results are
00195   // saced in a circular buffer.
00196   // Current result pointer
00197   Int lres_p;
00198   // Last calculation
00199   Euler result_p[4];
00200   // Interpolation interval aipsrc registration
00201   static uInt myInterval_reg;
00202 
00203   //# Member functions
00204   // Make a copy
00205   void copy(const Precession &other);
00206   // Create correct default fixedEpoch and catalogue epoch data
00207   void fillEpoch();
00208   // Calculate precession angles for time t
00209   void calcPrec(Double t);
00210 };
00211 
00212 
00213 } //# NAMESPACE CASA - END
00214 
00215 #endif