casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ParAngleMachine.h
Go to the documentation of this file.
00001 //# ParAngleMachine.h: Converts a direction into parallactic angle
00002 //# Copyright (C) 2001,2002
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: ParAngleMachine.h 18093 2004-11-30 17:51:10Z ddebonis $
00027 #ifndef MEASURES_PARANGLEMACHINE_H
00028 #define MEASURES_PARANGLEMACHINE_H
00029 
00030 //# Includes
00031 #include <casa/aips.h>
00032 #include <measures/Measures.h>
00033 #include <measures/Measures/MCDirection.h>
00034 #include <measures/Measures/MDirection.h>
00035 #include <measures/Measures/MCEpoch.h>
00036 #include <measures/Measures/MEpoch.h>
00037 #include <casa/Quanta/Quantum.h>
00038 #include <casa/Quanta/MVDirection.h>
00039 #include <casa/Quanta/MVEpoch.h>
00040 #include <casa/Arrays/Vector.h>
00041 
00042 namespace casa { //# NAMESPACE CASA - BEGIN
00043 
00044 //# Forward Declarations
00045 class MeasFrame;
00046 
00047 // <summary> Converts a direction into parallactic angle
00048 // </summary>
00049 
00050 // <use visibility=export>
00051 
00052 // <reviewed reviewer="Mark Wieringa" date="2001/10/06" tests="tParAngleMachine.cc" demos="">
00053 // </reviewed>
00054 
00055 // <prerequisite>
00056 //   <li> <linkto class=MDirection>MDirection</linkto> class
00057 // </prerequisite>
00058 //
00059 // <etymology>
00060 // From Parallactic Angle and machinery
00061 // </etymology>
00062 //
00063 // <synopsis>
00064 // The construction of a ParAngleMachine class object creates a machine that
00065 // can create parallactic angles from a series of time epochs given.
00066 //
00067 // The machinery needs an input 
00068 // <linkto class=MDirection>MDirection</linkto>  to specify the input 
00069 // coordinates reference direction and coordinate system.
00070 // The parallactic (<em>vertical</em>)
00071 // angle will be calculated as the angle between the vertical in the
00072 // local coordinate system (<em>Az, El</em>) through the given direction and
00073 // the pole of the <em>J2000</em> coordinate system.
00074 // <note role=tip> To calculate the parallactic angle for another 
00075 // coordinate system pole, add the <src>positionAngle</src> between the
00076 // <em>J2000</em> system and the pole in the other coordinate system. </note>
00077 //
00078 // The machinery also needs a <linkto class=MeasFrame>MeasFrame</linkto>,
00079 // with a position on Earth and
00080 // a reference epoch. The reference time is necessary to have an epoch type.
00081 //
00082 // The actual calculation of the parallactic angles is done by the
00083 // <src>operator()</src> accepting a time or a list of times in various
00084 // formats.
00085 //
00086 // The machine calculates the paralaactic angle for the first time given to
00087 // the machine. For subsequent times that are within a check interval,
00088 // the angle is calculated assuming that only the hour angle changes within
00089 // that interval. For moving objects the test interval is always forced
00090 // to zero. Tests show that the machine with a zero interval is about
00091 // 8 times faster than using brute force. Having an interval of an
00092 // hour improves that by another factor of 4.
00093 // <note role=tip> If the parallactic angles for a series of directions have
00094 // to be calculated, it is best to have separate machines for each such
00095 // <em>field</em>. </note>
00096 // </synopsis>
00097 //
00098 // <example>
00099 // <srcblock>
00100 // </srcblock>
00101 // </example>
00102 //
00103 // <motivation>
00104 // To speed up parallactic angle calculations
00105 // </motivation>
00106 //
00107 // <todo asof="2001/09/15">
00108 //   <li>
00109 // </todo>
00110 
00111 class ParAngleMachine {
00112  public:
00113   //# Constructors
00114   // Create an empty machine. It can only be used after appropriate 'set'
00115   // methods
00116   ParAngleMachine();
00117   // Construct for the specified direction
00118   ParAngleMachine(const MDirection &in);
00119   // Copy constructor (deep copy)
00120   ParAngleMachine(const ParAngleMachine &other);
00121   // Copy assignments (deep copy)
00122   ParAngleMachine &operator=(const ParAngleMachine &other);
00123 
00124   //# Destructor
00125   ~ParAngleMachine();
00126 
00127   //# Operators
00128   // Return parallactic angles (epoch in days if given as Double)
00129   // <thrown>
00130   // <li> AipsError if no frame or a frame without an Epoch (for type) or       
00131   //    Position.
00132   // </thrown>
00133   // <group>
00134   Quantum<Vector<Double> >
00135     operator()(const Quantum<Vector<Double> > &ep) const;
00136   Quantum<Vector<Double> > operator()(const Vector<MVEpoch> &ep) const;
00137   Quantum<Vector<Double> > operator()(const Vector<MEpoch> &ep) const;
00138   Quantum<Double> operator()(const Quantum<Double> &ep) const;
00139   Quantum<Double> operator()(const MVEpoch &ep) const;
00140   Quantum<Double> operator()(const MEpoch &ep) const;
00141   Double operator()(const Double &ep) const;
00142   Vector<Double> operator()(const Vector<Double> &ep) const;
00143   // </group>
00144 
00145   //# Member functions
00146   // Will have a group of set methods (in direction; reference time; a frame;
00147   // a reference time valid period
00148   // <group>
00149   void set(const MDirection &in);
00150   void set(const MeasFrame &frame);
00151   // </group>
00152   // Set the test interval (in days) over which to use simple formula
00153   void setInterval(const Double ttime);
00154 
00155 private:
00156 
00157   //# Data
00158   // Input direction
00159   MDirection *indir_p;
00160   // Conversion engine
00161   mutable MDirection::Convert *convdir_p;
00162   // Measure frame
00163   MeasFrame *frame_p;
00164   // Converted zenith
00165   mutable MVDirection zenith_p;
00166   // Intermediate conversion result
00167   mutable MVDirection mvdir_p;
00168   // Time of last full solution (in days)
00169   mutable Double lastep_p;
00170   // Default time interval over which to do simple solution (days)
00171   mutable Double defintvl_p;
00172   // Time interval over which to do simple solution (days)
00173   mutable Double intvl_p;
00174   // Calculation cache
00175   // <group>
00176   mutable Double UTfactor_p;
00177   mutable Double longoff_p;
00178   mutable Double longdiff_p;
00179   mutable Double slat1_p;
00180   mutable Double clat1_p;
00181   mutable Double slat2_p;
00182   mutable Double clat2_p;
00183   // </group>
00184 
00185   //# Constructors
00186 
00187   //# Private Member Functions
00188   // Get position angle (Epoch is supposed to be in days if Double)
00189   // <thrown>
00190   // <li> AipsError if no frame or a frame without an Epoch (for type) or
00191   //    Position.
00192   // </thrown>
00193   // <group>
00194   Double posAngle(const Quantum<Double> &ep) const;
00195   Vector<Double> posAngle(const Quantum<Vector<Double> > &ep) const;
00196   Double posAngle(const Double &ep) const;
00197   Vector<Double> posAngle(const Vector<Double> &ep) const;
00198   // </group>
00199   // Initialise machinery
00200   void init();
00201   // Initialise conversion
00202   void initConv() const;
00203   // Calculate position angle
00204   Double calcAngle(const Double ep) const;
00205 };
00206 
00207 
00208 } //# NAMESPACE CASA - END
00209 
00210 #endif