casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTMSSysCalFiller.h
Go to the documentation of this file.
00001 //# GBTMSSysCalFiller.h: GBTMSSysCalFiller fills the MSSysCal table for GBT fillers
00002 //# Copyright (C) 2000,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_GBTMSSYSCALFILLER_H
00030 #define NRAO_GBTMSSYSCALFILLER_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Containers/RecordField.h>
00034 #include <ms/MeasurementSets/MSSysCal.h>
00035 
00036 //# Forward Declarations
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 class MSSysCalColumns;
00039 class ColumnsIndex;
00040 template <class T> class Matrix;
00041 } //# NAMESPACE CASA - END
00042 
00043 #include <casa/namespace.h>
00044 
00045 // <summary>
00046 // GBTMSSysCalFiller fills the MSSysCal table for GBT fillers
00047 // </summary>
00048 
00049 // <use visibility=local>
00050 
00051 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00052 // </reviewed>
00053 
00054 // <prerequisite>
00055 //   <li> MeasurementSets
00056 //   <li> GBT FITS files
00057 // </prerequisite>
00058 //
00059 // <etymology>
00060 // This class puts GBT data (fills) into the MSSysCal table.
00061 // </etymology>
00062 //
00063 // <synopsis>
00064 // This class puts the appropriate values for the GBT in an MSSysCal
00065 // table (which has been previously created as part of a MeasurementSet).
00066 // On each fill() any necessary additions to the MSSysCal are made.
00067 // Each call to fill generates a new row.
00068 //
00069 // </synopsis>
00070 //
00071 // <example>
00072 // </example>
00073 //
00074 // <motivation>
00075 // Writing a filler is a daunting task.  There are various dependencies
00076 // between the subtables.  It helps to encapsulate the knowlege and
00077 // task of filling a specific subtable to separate classes.
00078 // </motivation>
00079 //
00080 //#! <thrown>
00081 //#! A list of exceptions thrown if errors are discovered in the function.
00082 //#! This tag will appear in the body of the header file, preceding the
00083 //#! declaration of each function which throws an exception.
00084 //#! </thrown>
00085 
00086 class GBTMSSysCalFiller
00087 {
00088 public:
00089 
00090     // The default ctor.  No MSSysCal table has been attached yet.
00091     // Calling fill on such a filler will throw an exception.
00092     // It is present so that this object can be instantiated before
00093     // an MSSysCal has been created.
00094     GBTMSSysCalFiller();
00095 
00096     // A filler attached to an MSSysCal table
00097     GBTMSSysCalFiller(MSSysCal &msSysCal);
00098 
00099     ~GBTMSSysCalFiller();
00100     
00101     // attach it to an MSSysCal
00102     void attach(MSSysCal &msSysCal);
00103 
00104     // Pre-fill the TCAL and TRX values.  This associates
00105     // those input values with antennaId, feedId and spectralWindowId.
00106     // and a date string from the receiver CAL table.  Subsequent
00107     // calls to fill use these pre-filled values.  Since these
00108     // values don't change very often with time (generally never during
00109     // an observing run, for example) the calls to fill simply
00110     // involve a time and interval matching that in the main table
00111     // so that the TSYS cell can be prepared for use by the calibration
00112     // routines (which requires one cell for each cell in the main table).
00113     // If this combination of keys has already been used, these values
00114     // of tcal and trx will replace the ones already stored.
00115     void prefill(const Matrix<Float> &tcal, const Matrix<Float> &trx,
00116                  Int antennaId, Int feedId, Int spectralWindowId);
00117 
00118     // Fill the SYSCAL table.  A new row is added to the SYSCAL table.
00119     void fill(Double time, Double interval, Int antennaId, Int feedId,
00120               Int spectralWindowId);
00121 
00122     // flush the underlying MS subtable
00123     void flush() {msSysCal_p->flush();}
00124 
00125 private:
00126     // the actual syscal table and columns
00127     MSSysCal *msSysCal_p;
00128     MSSysCalColumns *msSysCalCols_p;
00129 
00130     // the dummy ones used to hold the cached TCAL and TRX values
00131     MSSysCal *dummySysCal_p;
00132     MSSysCalColumns *dummyCols_p;
00133 
00134     // Table index into the dummy SYSCAL table
00135     ColumnsIndex *dummyIndex_p;
00136     // And the index keys
00137     RecordFieldPtr<Int> antIdKey_p, feedIdKey_p, spwIdKey_p;
00138 
00139     // row number matching these keys
00140     Int lastIndex_p;
00141 
00142     // initialize the above for the first time
00143     void init(MSSysCal &msSysCal);
00144 
00145     // undefined and unavailable
00146     GBTMSSysCalFiller(const GBTMSSysCalFiller &other);
00147     void operator=(const GBTMSSysCalFiller &other);
00148 };
00149 
00150 #endif
00151 
00152