casa
$Rev:20696$
|
00001 //# GBTBackendFiller.h: this is a base class for GBT backend fillers 00002 //# Copyright (C) 1999,2000,2001,2002,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_GBTBACKENDFILLER_H 00030 #define NRAO_GBTBACKENDFILLER_H 00031 00032 //#! Includes go here 00033 00034 #include <casa/aips.h> 00035 #include <casa/Arrays/Vector.h> 00036 #include <casa/Containers/Block.h> 00037 #include <nrao/FITS/GBTStateTable.h> 00038 #include <nrao/FITS/GBTScanLogReader.h> 00039 #include <nrao/FITS/GBTGOFile.h> 00040 #include <casa/Quanta/MVTime.h> 00041 #include <nrao/GBTFillers/GBTFeedDDFiller.h> 00042 #include <nrao/GBTFillers/GBTLO1DAPFiller.h> 00043 #include <nrao/GBTFillers/GBTMSAntennaFiller.h> 00044 #include <nrao/GBTFillers/GBTMSDataDescFiller.h> 00045 #include <nrao/GBTFillers/GBTMSFeedFiller.h> 00046 #include <nrao/GBTFillers/GBTMSFieldFiller.h> 00047 #include <nrao/GBTFillers/GBTMSHistoryFiller.h> 00048 #include <nrao/GBTFillers/GBTMSObservationFiller.h> 00049 #include <nrao/GBTFillers/GBTMSPointingFiller.h> 00050 #include <nrao/GBTFillers/GBTMSPolarizationFiller.h> 00051 #include <nrao/GBTFillers/GBTMSProcessorFiller.h> 00052 #include <nrao/GBTFillers/GBTMSSourceFiller.h> 00053 #include <nrao/GBTFillers/GBTMSSpecWinFiller.h> 00054 #include <nrao/GBTFillers/GBTMSStateFiller.h> 00055 #include <nrao/GBTFillers/GBTMSSysCalFiller.h> 00056 #include <nrao/GBTFillers/GBTMSWeatherFiller.h> 00057 #include <nrao/GBTFillers/GBTDAPFiller.h> 00058 #include <tables/Tables/StandardStMan.h> 00059 #include <tables/Tables/TableLock.h> 00060 #include <casa/BasicSL/String.h> 00061 00062 //# Forward Declarations 00063 namespace casa { //# NAMESPACE CASA - BEGIN 00064 class MeasurementSet; 00065 class String; 00066 class TableDesc; 00067 class DataManager; 00068 class MSMainColumns; 00069 00070 template<class T> class Block; 00071 } //# NAMESPACE CASA - END 00072 00073 class GBTLO1File; 00074 class GBTMSFillOptions; 00075 00076 #include <casa/namespace.h> 00077 00078 // <summary> 00079 // A base class for GBT backend fillers. 00080 // </summary> 00081 00082 // <use visibility=local> 00083 00084 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00085 // </reviewed> 00086 00087 // <prerequisite> 00088 // <li> Understand the GBT FITS files to be filled. 00089 // <li> <linkto class=MeasurementSet>MeasurementSet</linkto> 00090 // <li> <linkto class=GBTScanLogReader>GBTScanLogReader</linkto> 00091 // <li> The several GBTMS*Filler classes for filling the subtables. 00092 // </prerequisite> 00093 // 00094 // <etymology> 00095 // The GBT MeasurementSet filler is driven by the contents of the 00096 // backend data to be filled. This class is the base class for 00097 // these backend fillers for GBT data, hence GBTBackendFiller. 00098 // </etymology> 00099 // 00100 // <synopsis> 00101 // </synopsis> 00102 // 00103 // <example> 00104 // </example> 00105 // 00106 // <motivation> 00107 // It should be possible to write a new filler by deriving from this 00108 // class and plug the new class into the filler DO and have the 00109 // DO understand that new backend. It is also required that 00110 // the GBTScanLogReader be updated to recognize this new backend. 00111 // </motivation> 00112 // 00113 // <thrown> 00114 // <li> 00115 // <li> 00116 // </thrown> 00117 // 00118 // <todo asof="yyyy/mm/dd"> 00119 // <li> Probably many things remain to be done. 00120 // </todo> 00121 00122 class GBTBackendFiller 00123 { 00124 public: 00125 // construct an empty filler, openMS or createMS must be 00126 // called before this is a useful filler. 00127 GBTBackendFiller(); 00128 00129 virtual ~GBTBackendFiller(); 00130 00131 // static function giving the default TableLock to be used to 00132 // open all MS tables 00133 static TableLock tableLock() 00134 {return TableLock(TableLock::PermanentLockingWait);} 00135 00136 // what type of backend is this 00137 virtual GBTScanLogReader::BACKENDS type() = 0; 00138 00139 // fill a given backend file and DAP files 00140 virtual Bool fill(const String &backendFile, 00141 const Block<String> &dapFiles, 00142 const String &ifManagerFile, 00143 const Block<String> &rxCalInfoFiles, 00144 const GBTGOFile &GOFile, 00145 const String &antennaFile, 00146 const GBTStateTable &masterState, 00147 const GBTLO1File &LO1A, 00148 const GBTLO1File &LO1B, 00149 const GBTMSFillOptions &fillOptions) = 0; 00150 00151 // prepare the appropriate DAP filler based on the indicated file name 00152 virtual Bool prepareDAPfillers(const String &dapfile, 00153 const MVTime &startTime); 00154 // fill all of the prepared DAP files 00155 virtual void fillDAP(); 00156 00157 // get the MS this filler is associated with 00158 virtual MeasurementSet &ms() { return *ms_p;} 00159 00160 // open the MS, this returns False if an MS of that name 00161 // does not exist or can not be opened. 00162 // The holography filler has useFeedDDFiller = False here. 00163 virtual Bool openMS(const String &msName, Bool useFeedDDFiller = True); 00164 00165 // create and open the MS, using the given TableDesc 00166 // for the Main table of the MS. Also supply a data manager 00167 // an the main table column names it should be bound to. 00168 // When spectralLine is true the following optional columns 00169 // are added to the indicated tables: 00170 // <li> SYSCAL: TCAL_SPECTRUM, TRX, and TRX_FLAG 00171 // <li> SOURCE: REST_FREQUENCY 00172 virtual Bool createMS(const String &msName, 00173 const TableDesc &mainTD, 00174 const DataManager &dm, 00175 const Vector<String> &dmColNames, 00176 const IPosition &defaultTileShape, 00177 const GBTMSFillOptions &fillOptions, 00178 Int nrows = 0, 00179 Bool spectralLine = False, 00180 Bool useFeedDDFiller = True); 00181 00182 // Supply a second data manager and its columns (this 00183 // is used when a LAGS column is required). 00184 // Returns false if the MS can not be created. 00185 // Always uses the GBTFeedDDFiller. 00186 // Only the holography filler has useFeedDDFiller = False. 00187 virtual Bool createMS(const String &msName, 00188 const TableDesc &mainTD, 00189 const DataManager &dm, 00190 const Vector<String> &dmColNames, 00191 const IPosition &defaultTileShape, 00192 const GBTMSFillOptions &fillOptions, 00193 const DataManager &dm2, 00194 const Vector<String> &dm2ColNames, 00195 Int nrows = 0, 00196 Bool spectralLine = False, 00197 Bool useFeedDDFiller = True); 00198 00199 // create and open the MS, no special data manager columns 00200 // Only the holography filler has useFeedDDFiller = False. 00201 virtual Bool createMS(const String &msName, const TableDesc &mainTD, 00202 const GBTMSFillOptions &fillOptions, 00203 Int nrows = 0, 00204 Bool useFeedDDFiller = True); 00205 00206 virtual Bool hasMS() { return hasMS_p;} 00207 00208 // Flush the MS and all subtables known here. 00209 virtual void flush(); 00210 00211 // re-attach to the same MS - forces MSMainColumns to be redone 00212 virtual void reattach(); 00213 00214 // return the main table columns 00215 virtual MSMainColumns &cols() { return *mscols_p;} 00216 00217 // The several sub-table filler. feedFiller, dataDescFiller, 00218 // polarizationFiller and specWinFiller are all not attached 00219 // in favor of feedDDFiller unless useFeedDDFiller is False 00220 // in openMS or createMS. 00221 // <group> 00222 virtual GBTFeedDDFiller &feedDDFiller() { return feedDDFiller_p;} 00223 virtual GBTMSAntennaFiller &antennaFiller() { return antennaFiller_p;} 00224 virtual GBTMSDataDescFiller &dataDescFiller() { return dataDescFiller_p;} 00225 virtual GBTMSFeedFiller &feedFiller() { return feedFiller_p;} 00226 virtual GBTMSFieldFiller &fieldFiller() { return fieldFiller_p;} 00227 virtual GBTMSHistoryFiller &historyFiller() { return historyFiller_p;} 00228 virtual GBTMSObservationFiller &observationFiller() { return observationFiller_p;} 00229 virtual GBTMSPointingFiller &pointingFiller() { return pointingFiller_p;} 00230 virtual GBTMSPolarizationFiller &polarizationFiller() { return polarizationFiller_p;} 00231 virtual GBTMSProcessorFiller &processorFiller() { return processorFiller_p;} 00232 virtual GBTMSSourceFiller &sourceFiller() { return sourceFiller_p;} 00233 virtual GBTMSSpecWinFiller &specWinFiller() { return specWinFiller_p;} 00234 virtual GBTMSStateFiller &stateFiller() { return stateFiller_p;} 00235 virtual GBTMSSysCalFiller &sysCalFiller() { return sysCalFiller_p;} 00236 virtual GBTMSWeatherFiller &weatherFiller() { return weatherFiller_p;} 00237 // </group> 00238 00239 // return the last time in the MS when it was opened 00240 // all filling must happen for times on or after this time 00241 virtual MVTime &startTime() { return startTime_p;} 00242 00243 // return a reference to the LO1 filler, by pointer for now. This pointer 00244 // should not be deleted. It will be a null pointer if there is no LO1 00245 // manager associated with this filler yet. 00246 GBTLO1DAPFiller *lo1Filler() { return (lo1DAPFiller_p >= 0) ? 00247 (dynamic_cast<GBTLO1DAPFiller *>(dapFillers_p[lo1DAPFiller_p])) : 0;} 00248 00249 // The calibration columns 00250 // <group> 00251 ArrayColumn<Complex> &modelData() {return modelData_p;} 00252 ArrayColumn<Complex> &correctedData() {return correctedData_p;} 00253 // </group> 00254 private: 00255 // The MeasurementSet 00256 MeasurementSet *ms_p; 00257 Bool hasMS_p; 00258 00259 // the main table columns 00260 MSMainColumns *mscols_p; 00261 00262 // The various subtable fillers 00263 GBTFeedDDFiller feedDDFiller_p; 00264 GBTMSAntennaFiller antennaFiller_p; 00265 GBTMSDataDescFiller dataDescFiller_p; 00266 GBTMSFeedFiller feedFiller_p; 00267 GBTMSFieldFiller fieldFiller_p; 00268 GBTMSHistoryFiller historyFiller_p; 00269 GBTMSObservationFiller observationFiller_p; 00270 GBTMSPointingFiller pointingFiller_p; 00271 GBTMSPolarizationFiller polarizationFiller_p; 00272 GBTMSProcessorFiller processorFiller_p; 00273 GBTMSSourceFiller sourceFiller_p; 00274 GBTMSSpecWinFiller specWinFiller_p; 00275 GBTMSStateFiller stateFiller_p; 00276 GBTMSSysCalFiller sysCalFiller_p; 00277 GBTMSWeatherFiller weatherFiller_p; 00278 00279 // calibration columns 00280 ArrayColumn<Complex> modelData_p, correctedData_p; 00281 00282 // map device name string to the appropriate GBTDAPFiller 00283 SimpleOrderedMap<String, Int> deviceMap_p; 00284 // the block containing the pointers to the various GBTDAPFillers 00285 Block<GBTDAPFiller *> dapFillers_p; 00286 // this indicates which ones are ready to fill (the flag is 00287 // set to true in prepareDAPfillers and set to False in fillDAP 00288 Block<Bool> readyToFill_p; 00289 // this points to the antenna DAP filler when one exists 00290 Int antennaDAPFiller_p; 00291 // this points to the LO1 DAP filler when one exists 00292 Int lo1DAPFiller_p; 00293 00294 MVTime startTime_p; 00295 00296 // initialize the sub-table fillers once the MS has been 00297 // re-opened or constructed 00298 void initSubTableFillers(Bool useFeedDDFiller); 00299 00300 // add calibration columns 00301 void addCalSet(const IPosition &defaultTileShape, 00302 Bool compress); 00303 00304 // initialize calibration columns by setting their 00305 // shape and their initial default values. This is 00306 // only used when data already has been filled. 00307 void initCalSet(); 00308 00309 // attach the calibration columns 00310 void attachCalSet(); 00311 00312 // undefined and unavailable 00313 GBTBackendFiller(const GBTBackendFiller &other); 00314 GBTBackendFiller &operator=(const GBTBackendFiller &other); 00315 00316 }; 00317 00318 00319 #endif 00320