casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTMSFeedFiller.h
Go to the documentation of this file.
00001 //# GBTMSFeedFiller.h: GBTMSFeedFiller fills the MSFeed table for GBT fillers
00002 //# Copyright (C) 2000,2001,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$
00028 
00029 #ifndef NRAO_GBTMSFEEDFILLER_H
00030 #define NRAO_GBTMSFEEDFILLER_H
00031 
00032 #include <casa/aips.h>
00033 
00034 #include <casa/Arrays/Vector.h>
00035 #include <casa/Containers/SimOrdMap.h>
00036 #include <tables/Tables/ScalarColumn.h>
00037 #include <tables/Tables/ArrayColumn.h>
00038 #include <ms/MeasurementSets/MSFeed.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 class MSFeedColumns;
00042 class Table;
00043 
00044 template <class T> class Matrix;
00045 } //# NAMESPACE CASA - END
00046 
00047 #include <casa/namespace.h>
00048 
00049 class GBTIFFiller;
00050 class GBTAntennaFile;
00051 class GBTFeed;
00052 
00053 // <summary>
00054 // GBTMSFeedFiller fills the MSFeed table for GBT fillers
00055 // </summary>
00056 
00057 // <use visibility=local>
00058 
00059 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00060 // </reviewed>
00061 
00062 // <prerequisite>
00063 //   <li> MeasurementSets
00064 //   <li> GBT FITS files
00065 // </prerequisite>
00066 //
00067 // <etymology>
00068 // This class puts GBT data (fills) into the MSFeed table.
00069 // </etymology>
00070 //
00071 // <synopsis>
00072 // This class puts the appropriate values for the GBT in an MSFeed
00073 // table (which has been previously created as part of a MeasurementSet).
00074 // On each fill() any necessary additions to the MSFeed are made.  
00075 //
00076 // The feedIds are available to be used by 
00077 // other GBTMS*Fillers as other subtables are filled in turn.
00078 //
00079 // <example>
00080 // </example>
00081 //
00082 // <motivation>
00083 // Writing a filler is a daunting task.  There are various dependencies
00084 // between the subtables.  It helps to encapsulate the knowlege and
00085 // task of filling a specific subtable to separate classes.
00086 // </motivation>
00087 //
00088 
00089 class GBTMSFeedFiller
00090 {
00091 public:
00092 
00093     // The default ctor.  No MSFeed table has been attached yet.
00094     // Calling fill on such a filler will throw an exception.
00095     // It is present so that this object can be instantiated before
00096     // an MSFeed has been created.
00097     GBTMSFeedFiller();
00098 
00099     // A filler attached to an MSFeed table
00100     GBTMSFeedFiller(MSFeed &msFeed);
00101 
00102     ~GBTMSFeedFiller();
00103 
00104     // attach it to an MSFeed
00105     void attach(MSFeed &msFeed);
00106 
00107     // fill - using the given keys from other tables
00108     // this implementation always fills just one feed ID (i.e. FEED_ID == 0 
00109     // here) TIME and INTERVAL are both 0.0 - there is no time dependence and
00110     // there is no spectral window dependence.  This is only used by the
00111     // holography filler since as yet there is no IF information filled for
00112     // that backend and hence no feed information is available.
00113     // Only one row will ever be filled by this and this should not be
00114     // used after the other fill method has been used.
00115     void fill();
00116 
00117     // Add the feeds found here, reusing the previous sequence number if
00118     // sequence is >= 0. sequence is not checked for validity. checkPrior should
00119     // be used to verify that things can be reused.  
00120     // It should be followed by a call to setTime when the mid-point 
00121     // and interval appropriate for the whole scan are known.
00122     // return the feed ID just filled
00123     Int fill(const GBTFeed &feed, Int sequence);
00124 
00125     // Get the srfeed ID at the indicated sequency in the current
00126     // set of filled feeds
00127     Int srFeedId(Int sequence);
00128 
00129     // Set the srfeed ID for the indicated FEED_ID
00130     void setSRFeedId(Int feedId, Int srFeedId);
00131 
00132     // Use this prior to calling fill on all feeds to be filled.  This
00133     // checks to see if the previous item at sequence can be reused.
00134     // If this is false, it also resets the internal feed count 
00135     // anticipating that the subsequent fill will add new rows.
00136     Bool checkPrior(const GBTFeed &feed, Int sequence);
00137 
00138      // Set the time of the previously filled rows
00139     void setTime(Double time, Double interval);
00140     
00141     // get the feed id corresponding to physical feed id indicated
00142     Int feedId(Int whichFeed) const;
00143 
00144     // get the srfeed id corresponding to feedId - feed id is the
00145     // FEED_ID in the most recently filled block of feed information.
00146     Int srfeedId(Int feedId) const;
00147 
00148     // Get the value filled in to the GBT_FEED_NAME column for the
00149     // indicated FEED_ID value.
00150     String gbtFeedName(Int feedId) const;
00151 
00152     // Returns True if any of the filled FEED_IDs are beam-switched pairs
00153     Bool hasBeamSwitched() const {return itsHasBeamSwitched;}
00154 
00155     // Set the hasBeamSwitched flag
00156     void setHasBeamSwitched(Bool hasBeamSwitched) {itsHasBeamSwitched = hasBeamSwitched;}
00157     
00158     // flush the underlying MS subtable
00159     void flush() {itsMSFeed->flush();}
00160     
00161 private:
00162     MSFeed *itsMSFeed;
00163     MSFeedColumns *itsMSFeedCols;
00164     
00165     // a map between the feed number in the IF table and feed id here
00166     SimpleOrderedMap<Int, Int> itsFeedMap;
00167 
00168     // remember where the last filled feed set was
00169     Int itsLastFeedsStart, itsLastFeedsEnd, itsMaxFeedID;
00170 
00171     //# GBT-specific cols in the FEED table
00172     ScalarColumn<Int> itsGBTSRFeedCol;
00173     ScalarColumn<String> itsGBTFeedNameCol, itsGBTTrckBeamCol, itsGBTRxNameCol;
00174     ArrayColumn<String> itsGBTRcptrsCol;
00175 
00176     //# keep the raw SRFEED info around for comparision time
00177     Vector<Int> itsLastSrfeeds;
00178 
00179     Bool itsHasBeamSwitched, itsSRFeedSet;
00180 
00181     // initialize the above for the first time
00182     void init(MSFeed &msFeed);
00183 
00184     // add a row with a new feed id given this information
00185     // return the new feed ID just added.
00186     Int addFeed(Double time, Double interval, const Matrix<Double> &offsets, 
00187                 const Vector<String> &polTypes, const String &feedName,
00188                 Int srFeedId, const String &trckBeam, const String &rxName,
00189                 const Vector<String> &rcptrNames);
00190 
00191     // undefined and unavailable
00192     GBTMSFeedFiller(const GBTMSFeedFiller &other);
00193     void operator=(const GBTMSFeedFiller &other);
00194 };
00195 
00196 #endif