casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTLO1File.h
Go to the documentation of this file.
00001 //# GBTLO1File.h: Digests the LO1 FITS file.
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 //#
00027 //# $Id$
00028 
00029 #ifndef NRAO_GBTLO1FILE_H
00030 #define NRAO_GBTLO1FILE_H
00031 
00032 //#! Includes go here
00033 
00034 #include <casa/Arrays/Vector.h>
00035 #include <nrao/FITS/GBTFITSBase.h>
00036 #include <nrao/FITS/GBTStateTable.h>
00037 #include <measures/Measures/MDirection.h>
00038 #include <measures/Measures/MDoppler.h>
00039 #include <measures/Measures/MFrequency.h>
00040 #include <measures/Measures/MPosition.h>
00041 #include <casa/Quanta/MVDirection.h>
00042 #include <casa/Quanta/MVFrequency.h>
00043 #include <tables/Tables/ScalarColumn.h>
00044 #include <casa/BasicSL/String.h>
00045 
00046 //# Forward Declarations
00047 namespace casa { //# NAMESPACE CASA - BEGIN
00048 class Table;
00049 class FITSTable;
00050 } //# NAMESPACE CASA - END
00051 
00052 
00053 // <summary>
00054 // Digests the LO1 FITS file.
00055 // </summary>
00056 
00057 // <use visibility=export>
00058 
00059 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00060 // </reviewed>
00061 
00062 // <prerequisite>
00063 // </prerequisite>
00064 //
00065 // <etymology>
00066 // </etymology>
00067 //
00068 // <synopsis>
00069 // </synopsis>
00070 //
00071 // <example>
00072 // </example>
00073 //
00074 // <motivation>
00075 // </motivation>
00076 //
00077 //
00078 // <thrown>
00079 //#! A list of exceptions thrown if errors are discovered in the function.
00080 //#! This tag will appear in the body of the header file, preceding the
00081 //#! declaration of each function which throws an exception.
00082 //    <li>
00083 //    <li>
00084 // </thrown>
00085 //
00086 // <todo asof="yyyy/mm/dd">
00087 // </todo>
00088 
00089 class GBTLO1File : public GBTFITSBase
00090 {
00091 public:
00092     // This constructs a GBTLO1File that has no primary keywords.
00093     // or associated tables
00094     GBTLO1File();
00095 
00096     virtual ~GBTLO1File();
00097 
00098     // attach this object to a new FITS file.  If there are problems with the
00099     // file, the return value is False and appropriate warnings are sent to the
00100     // logger.  The resulting object is not attached to any file.
00101     virtual Bool attach(const String &fitsFile);
00102 
00103     // Is this object attached to a FITS file.  This base class is never
00104     // attached to a file.
00105     virtual Bool isAttached() const {return itsAttached;}
00106 
00107     // The name of the attached FITS file.  Returns an empty string if
00108     // it is not attached.
00109     virtual const String &file() const {return itsName;}
00110 
00111     // The position of the antenna.
00112     const MPosition &position() const {return itsPosition;}
00113 
00114     // The requested rest frequency
00115     const MVFrequency &restfrq() const {return itsRestfrq;}
00116 
00117     // The requested doppler tolerance in Hz
00118     const Double reqdptol() const {return itsReqdptol;}
00119 
00120     // Get values from the LO1TABLE at the specified time (UTC) - or
00121     // the first row before that time if there is not a row near that time.
00122     // <group>
00123     // Telescope pointing direction.
00124     const MDirection &dir(const MVEpoch &time) const;
00125     // lo1freq, this also requires a state. The appropriate offset for
00126     // that state is from the LO1STATE table and is added to the frequency
00127     // from the LO1TABLE.  If that state isn't found, an offset of 0.0 is used.
00128     const MVFrequency &lo1freq(const MVEpoch &time, uInt state) const ;
00129     // radial velocity of the reference frame wrt the observer
00130     const Double vframe(const MVEpoch &time) const;
00131     // radial velociy of the source wrt the observer
00132     const Double rvsys(const MVEpoch &time) const;
00133     // </group>
00134 
00135     // the SOUVEL binary table
00136     const Table &souvel() const {return *itsSouvel;}
00137 
00138     // the STATE table used here
00139     const GBTStateTable &state() const {return itsState;}
00140 
00141     // The DMJD column
00142     const ROScalarColumn<Double> &dmjd() const {return itsDMJDCol;}
00143 
00144     // Are there non-zero offsets (implies frequency switching)
00145     Bool isFreqSwitched() const;
00146 
00147     // Return the first LO1 setting found here plus any state offset from STATE
00148     // table, one value per state.  Also set is the factor which, when multiplied
00149     // by the TOPO centric frequencies gives the reference frame frequencies 
00150     // corresponding to the the VELOCITY at the same time as the returned LO1 setting.
00151     // The desired reference frame, velocity definition,
00152     // and source velocity in the reference frame and definition
00153     // are set.
00154     Vector<Double> firstLO1(Double &factor, MFrequency::Types &refframe,
00155                     MDoppler::Types &doptype, Double &vsource) const;
00156 
00157 private:
00158     Bool itsAttached;
00159     String itsName;
00160 
00161     MPosition itsPosition;
00162     MVFrequency itsRestfrq;
00163     Double itsReqdptol;
00164 
00165     //# freqoff column from LO1STATE
00166     Vector<Double> itsFreqoff;
00167 
00168     mutable MDirection itsCurrentDir;
00169     mutable MVEpoch itsCurrentTime;
00170     mutable Int itslo1Row;
00171     mutable MVFrequency itsLo1freq;
00172 
00173     ROScalarColumn<Double> itsDMJDCol, itsRACol, itsDECCol,
00174         itsLO1FREQCol, itsVFRAMECol, itsRVSYSCol;
00175 
00176     Double itsEquinox;
00177     MDirection::Types itsDirType;
00178 
00179     Table *itsSouvel, *itsLO1Table;
00180     GBTStateTable itsState;
00181 
00182     // initialize with default, unattached values
00183     void init();
00184 
00185     // these functions do the appropriate thing, but do not verify that
00186     // FITSTable is set to the appropriate extension.
00187     // <group>
00188     void setLO1Table(FITSTable &lo1Tab);
00189     void setLO1State(FITSTable &stateTab);
00190     void setSouvel(FITSTable &souvelTab);
00191     // </group>
00192 
00193     // sets itslo1Row to the appropriate row in the lo1 table where the 
00194     // DMJD value is near or just prior to the requested time.
00195     void lo1Row(const MVEpoch &time) const;
00196 
00197     // undefined and unavailable
00198     GBTLO1File(const GBTLO1File &other);
00199     GBTLO1File &operator=(const GBTLO1File &other);
00200 };
00201 
00202 #endif