casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MeasComet.h
Go to the documentation of this file.
00001 //# MeasComet.h: To define position for comets and other solar system bodies
00002 //# Copyright (C) 1999,2000,2002,2007
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: MeasComet.h 21130 2011-10-18 07:39:05Z gervandiepen $
00028 
00029 #ifndef MEASURES_MEASCOMET_H
00030 #define MEASURES_MEASCOMET_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/Table.h>
00035 #include <tables/Tables/TableRow.h>
00036 #include <casa/Containers/RecordField.h>
00037 #include <casa/BasicSL/String.h>
00038 #include <casa/Quanta/MVPosition.h>
00039 #include <measures/Measures/MDirection.h>
00040 
00041 namespace casa { //# NAMESPACE CASA - BEGIN
00042 
00043 //# Forward Declarations
00044 class MVRadialVelocity;
00045 class MVDirection;
00046 template <class T> class Vector;
00047 
00048 // <summary>Position for comets and other solar system bodies</summary>
00049 
00050 // <use visibility=local>
00051 
00052 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasComet" demos="">
00053 // </reviewed>
00054 
00055 // <prerequisite>
00056 //   <li> <linkto class=MeasTable>MeasTable</linkto>
00057 // </prerequisite>
00058 //
00059 // <etymology>
00060 // From Measure and Comet
00061 // </etymology>
00062 //
00063 // <synopsis>
00064 // MeasComet is the interface class between generated Comet position
00065 // tables and the Direction conversion machinery.
00066 // Tables are found using the aipsrc 
00067 // (using <src>measures.<table>.directory</src>)
00068 // mechanism. If not provided they are assumed to reside in standard places
00069 // Tables are assumed to have the
00070 // VS_VERSION, VS_DATE, VS_CREATE, VS_TYPE,
00071 // MJD0 (first MJD in table - 1.0 * dMJD, >= 10000),
00072 // dMJD (increment between successive MJDs, in days, > 0),
00073 // and NAME
00074 // keywords, be gapless (constant dMJD), and be of type IERS,
00075 // or else an exception will be thrown.<br>
00076 // They are also assumed to have the MJD, RA, DEC, Rho, and RadVel columns.
00077 // The DiskLong and DiskLat columns can be used if they are present, but they
00078 // are no longer expected.
00079 // The <src>get()</src> method will obtain data from the cometary
00080 // tables. The data obtained will be in the specified frame.
00081 // Note that the normal usage of these tables is through the Measures system.
00082 // 
00083 // <note>
00084 //      A message is logged (once) if a date outside the range in
00085 //      the Tables is asked for. 
00086 // </note>
00087 // <thrown>
00088 //     <li> AipsError if table opened has wrong format or otherwise corrupted.
00089 // </thrown>
00090 // </synopsis>
00091 //
00092 // <example>
00093 // See test/tMeasComet.cc.
00094 // <srcblock>
00095 //   tbd
00096 // </srcblock>
00097 // </example>
00098 //
00099 // <motivation>
00100 // To use the JPL data for positions of solar system bodies
00101 // </motivation>
00102 //
00103 // <todo asof="2000/01/20">
00104 // </todo>
00105 
00106 class MeasComet {       
00107 
00108  public:
00109   //# Constants
00110   
00111   //# Enumerations
00112   // Types of known data
00113   enum Types {
00114     // MJD (must be first in list)
00115     MJD,
00116     // Columns with data
00117     RA, 
00118     DEC,
00119     RHO,
00120     RADVEL,
00121     DISKLONG,
00122     DISKLAT,
00123     // Number of columns
00124     N_Columns,
00125     N_Types };
00126   
00127   //# Constructors
00128   // Construct using the aipsrc value (measures.comet.file)
00129   MeasComet();
00130   // Construct a table from the named path.
00131   explicit MeasComet(const String &path);
00132   // Construct a table from the name and the input table
00133   MeasComet(const Table &tabin, const String &path);
00134   // Copy constructor
00135   MeasComet(const MeasComet &other);
00136   // Copy assign
00137   MeasComet &operator=(const MeasComet &other);
00138 
00139   //# Destructor
00140   ~MeasComet();
00141 
00142   //# General Member Functions
00143   // Is it a valid comet class (i.e. can it be used)
00144   Bool ok() const {return measured_p;} ;
00145   // Get the name of the comet
00146   const String &getName() const;
00147   // Get the topo position
00148   const MVPosition &getTopo() const;
00149   // Get the direction type
00150   MDirection::Types getType() const;
00151   // Get the start of the table (in MJD)
00152   Double getStart() const;
00153   // Get the end of the table (in MJD)
00154   Double getEnd() const;
00155   // Get number of entries
00156   Int nelements() const;
00157   // Get a comet position
00158   Bool get(MVPosition &returnValue, Double date) const;
00159   // Get the local on-disk direction.  Returns False if the time or sub-observer
00160   // longitude and latitude are unavailable, True on success.
00161   Bool getDisk(MVDirection &returnValue, Double date) const;
00162   // Get the velocity from a comet table, interpolated for date(in MJD(TDB)).
00163   Bool getRadVel(MVRadialVelocity &returnValue, Double date) const;
00164 
00165   // Return the temperature in K, or -1 if the table does not have it.
00166   // If squawk is true an error message will also be posted.
00167   Double getTemperature(const Bool squawk);
00168 
00169   // Return the mean radius in AU, or -1 if the table does not have it.
00170   // If squawk is true an error message will also be posted.
00171   Double getMeanRad(const Bool squawk);  
00172 
00173   // Create a clone
00174   MeasComet *clone() const;
00175 
00176   // Close the Comet tabls only
00177   void closeMeas();
00178 
00179   // Convenience function that returns ks[kw] in units of unit, setting
00180   // success.
00181   static Double get_Quantity_keyword(const TableRecord& ks, const String& kw,
00182                                      const Unit& unit, Bool& success);
00183 
00184   // Convenience function that returns the absolute path to the ephemeris table
00185   // connected to the MeasComet object
00186   String getTablePath();
00187 
00188  private:
00189   
00190   //# General member functions
00191   // Initialise table from the name given
00192   Bool initMeas(const String &which, const Table *tabin=0);
00193   // Fill Table lines
00194   Bool fillMeas(Double utf) const;
00195 
00196   // Helper functions for accessing ldat_p.  index should be either 0 or 1, but
00197   // that isn't checked!
00198   MVPosition getRelPosition(const uInt index) const;
00199   MVDirection getDiskLongLat(const uInt index) const;  // Must not be called if !haveDiskLongLat_p
00200 
00201   // Try to read mean_rad_p and temperature_p, returning whether or not it was
00202   // successful.  (but the real mark of success is whether or not they are
00203   // positive.)
00204   // It sets haveTriedExtras_p to true and will return right away if it is
00205   // already true.
00206   Bool getExtras();
00207 
00208   //# Data members
00209 
00210   // Initialized in the "initialization list" of the c'tors, so maintain order:
00211 
00212   // Actual table
00213   Table tab_p;
00214   // Measured data readable
00215   Bool measFlag_p;
00216   // Measured data present
00217   Bool measured_p;
00218   // Row descriptions
00219   ROTableRow row_p;
00220   // First MJD in list - 1.0 * dmjd_p
00221   Double mjd0_p;
00222   // Last MJD in list
00223   Double mjdl_p;
00224   // Increment in rows
00225   Double dmjd_p;
00226   // Number of rows
00227   Int nrow_p;
00228   // Name of comet
00229   String name_p;
00230   // Position on Earth
00231   MVPosition topo_p;
00232   // Type of coordinates
00233   MDirection::Types mtype_p;
00234   // Message given
00235   Bool msgDone_p;
00236   // File names
00237   String tp_p;
00238 
00239   // Whether or not the sub-observer longitude and latitude are available.
00240   Bool haveDiskLongLat_p;
00241 
00242   uInt ncols_p; // # of columns.
00243 
00244   // These may be initialized _inside_ the c'tors, but the order here is
00245   // unimportant:
00246 
00247   // Field pointers
00248   Vector<RORecordFieldPtr<Double> > rfp_p;
00249   // Lines in memory
00250   mutable Int lnr_p[2];                     // Why are these mutables here?
00251   // Last read data (measlow - meashigh)
00252   mutable Vector<Double> ldat_p[2];         // They allow declaring a const
00253                                             // which isn't.
00254   Bool haveTriedExtras_p;
00255   Double temperature_p;
00256   Double mean_rad_p;
00257 };
00258 
00259 //# Inline Implementations
00260 
00261 
00262 } //# NAMESPACE CASA - END
00263 
00264 #endif