casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SDPointingHandler.h
Go to the documentation of this file.
00001 //# SDPointingFiller.h: fills the POINTING table for the SDFITS filler
00002 //# Copyright (C) 2000
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: SDPointingHandler.h 18700 2005-05-23 07:45:13Z cvsmgr $
00028 
00029 #ifndef MS_SDPOINTINGHANDLER_H
00030 #define MS_SDPOINTINGHANDLER_H
00031 
00032 #include <casa/Containers/RecordField.h>
00033 #include <measures/Measures/MDirection.h>
00034 #include <casa/Arrays/Matrix.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 class MeasurementSet;
00040 class MSPointing;
00041 class MSPointingColumns;
00042 class Record;
00043 
00044 template <class T> class Vector;
00045 
00046 // <summary>
00047 // </summary>
00048 
00049 // <use visibility=local>   or   <use visibility=export>
00050 
00051 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00052 // </reviewed>
00053 
00054 // <prerequisite>
00055 //   <li> SomeClass
00056 //   <li> SomeOtherClass
00057 //   <li> some concept
00058 // </prerequisite>
00059 //
00060 // <etymology>
00061 // </etymology>
00062 //
00063 // <synopsis>
00064 // </synopsis>
00065 //
00066 // <example>
00067 // </example>
00068 //
00069 // <motivation>
00070 // </motivation>
00071 //
00072 // <templating arg=T>
00073 //    <li>
00074 //    <li>
00075 // </templating>
00076 //
00077 // <thrown>
00078 //    <li>
00079 //    <li>
00080 // </thrown>
00081 //
00082 // <todo asof="yyyy/mm/dd">
00083 //   <li> add this feature
00084 //   <li> fix this bug
00085 //   <li> start discussion of this possible extension
00086 // </todo>
00087 
00088 class SDPointingHandler
00089 {
00090 public:
00091     // default ctor is not attached to a MS and hence is useless until attached
00092     SDPointingHandler();
00093 
00094     // attach this to a MS, mark fields row which are handled here
00095     SDPointingHandler(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00096 
00097     // copy ctor
00098     SDPointingHandler(const SDPointingHandler &other);
00099 
00100     ~SDPointingHandler() {clearAll();}
00101 
00102     // assignment operator, uses copy semantics
00103     SDPointingHandler &operator=(const SDPointingHandler &other);
00104 
00105     // attach to a MS, mark fields in row which are handled here
00106     void attach(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00107 
00108     // reset internals given indicated row, use the same MS
00109     void resetRow(const Record &);
00110     
00111     // fill - a new row is added when 
00112     //      a) the name changes
00113     //      b) the time changes such that it would be outside of the new interval when
00114     //         added to the old interval (i.e. intervals do not overlap)
00115     //      c) the direction changes
00116     //      d) the antennaId changes
00117     //  There is no look-back to see if a previous row could be re-used
00118     void fill(const Record &row, Int antennaId, Double time, const Vector<Double> &timeRange,
00119               const MDirection &direction, const MeasFrame &frame);
00120 
00121     // convenience functions for use when filling the FIELD table, which is mostly
00122     // just a clone of this table for SD data
00123     Int nrow() {return rownr_p+1;}
00124     const String &name() {return name_p;}
00125     Int directionRefType() {return dirColRef_p.getType();}
00126     const Matrix<Double> &directionPoly() {return directionPoly_p;}
00127     Double time() {return time_p;}
00128 private:
00129     MSPointing *msPointing_p;
00130     MSPointingColumns *msPointingCols_p;
00131 
00132     Double time_p;
00133 
00134     Int antId_p;
00135     MDirection direction_p;
00136     Matrix<Double> directionPoly_p;
00137     Vector<Double> directionRate_p;
00138     String name_p;
00139 
00140     Int rownr_p;
00141 
00142     MDirection::Ref dirColRef_p;
00143 
00144     RORecordFieldPtr<String> objectField_p;
00145 
00146     // these might come from an MS table
00147     // this can just come from an MS v1 table
00148     RORecordFieldPtr<Array<Double> > pointingDirRateField_p;
00149     RORecordFieldPtr<Double> intervalField_p, timeField_p;
00150     RORecordFieldPtr<String> nameField_p;
00151     RORecordFieldPtr<Bool> trackingField_p;
00152 
00153     // cleanup everything
00154     void clearAll();
00155 
00156     // cleanup things which depend on the row
00157     void clearRow();
00158 
00159     // initialize everything
00160     void initAll(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00161 
00162     // initialize everythign which depends on row
00163     void initRow(Vector<Bool> &handledCols, const Record &row);
00164 };
00165 
00166 
00167 } //# NAMESPACE CASA - END
00168 
00169 #endif
00170 
00171