casa
$Rev:20696$
|
00001 //# PlotCalCache.h: Calibration cache for plotms. 00002 //# Copyright (C) 2009 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 //# $Id: $ 00027 #ifndef PLOTCALCACHE_H_ 00028 #define PLOTCALCACHE_H_ 00029 00030 #include <plotms/PlotMS/PlotMSAveraging.h> 00031 #include <plotms/PlotMS/PlotMSConstants.h> 00032 #include <plotms/PlotMS/PlotMSFlagging.h> 00033 #include <plotms/Actions/PlotMSCacheThread.qo.h> 00034 #include <plotms/Data/PlotMSVBAverager.h> 00035 00036 #include <plotms/Data/PlotMSCache.h> 00037 00038 #include <casa/aips.h> 00039 #include <casa/Arrays.h> 00040 #include <casa/Containers/Block.h> 00041 00042 namespace casa { 00043 00044 //# Forward declarations. 00045 class PlotMSApp; 00046 00047 00048 class PlotCalCache : public PlotMSCache { 00049 00050 // Friend class declarations. 00051 friend class PlotMSData; 00052 00053 public: 00054 00055 // Constructor which takes parent PlotMS. 00056 PlotCalCache(PlotMSApp* parent); 00057 00058 // Destructor 00059 virtual ~PlotCalCache(); 00060 00061 // Identify myself 00062 PlotMSCache::Type cacheType() { return PlotMSCache::CAL; }; 00063 00064 00065 // Loads the cache for the given axes and data 00066 // columns. IMPORTANT: this method assumes that any currently loaded data is 00067 // valid for the given VisIter; i.e., if the meta-information or either of 00068 // the axes are already loaded, then they don't need to be reloaded. If this 00069 // is not the case, then clear() should be called BEFORE append(). If a 00070 // PlotMSCacheThreadHelper object is given, it will be used to report 00071 // progress information. 00072 virtual void load(const vector<PMS::Axis>& axes, 00073 const vector<PMS::DataColumn>& data, 00074 const String& filename, 00075 const PlotMSSelection& selection, 00076 const PlotMSAveraging& averaging, 00077 const PlotMSTransformations& transformations, 00078 PlotMSCacheThread* thread = NULL); 00079 00080 // Set flags in the Cal table 00081 virtual void flagToDisk(const PlotMSFlagging& flagging, 00082 Vector<Int>& chunks, 00083 Vector<Int>& relids, 00084 Bool flag); 00085 00086 private: 00087 00088 // Forbid copy for now 00089 PlotCalCache(const PlotCalCache& mc); 00090 00091 // Manage the cal table 00092 void openCal(const String& msname, 00093 const PlotMSSelection& selection, 00094 Bool readonly=True); 00095 void closeCal(); 00096 00097 00098 // Select on the caltable (via MSSelection semantics) 00099 void selectCal(const PlotMSSelection& selection); 00100 00101 // Count the chunks required in the cache 00102 void countCalChunks(); // old 00103 00104 // Iterate over selected cal table, filling the cache 00105 void loadCalChunks(const vector<PMS::Axis> loadAxes, 00106 const vector<PMS::DataColumn> loadData, 00107 PlotMSCacheThread* thread); 00108 00109 00110 // Issue meta info report to the given stringstream. 00111 void reportMeta(Double x, Double y, stringstream& ss); 00112 00113 // Loads the specific axis/metadata into the cache using the given VisBuffer. 00114 void loadCalAxis(Table& tab, Int vbnum, PMS::Axis axis); 00115 00116 // Support MS-oriented selection 00117 Vector<Int> getAntIdx(const String& antenna); 00118 Vector<Int> getFieldIdx(const String& field); 00119 Vector<Int> getSpwIdx(const String& spw); 00120 Vector<Int> getCalDescIds(const Vector<Int> selspws); 00121 Matrix<Double> getTimeRange(const String& time); 00122 00123 // Manage freq info we get from the MS 00124 void getFrequencyInfo(); 00125 void deleteFreqInfo(); 00126 00127 // Private data 00128 00129 // The name of the caltable, associated MS 00130 String calname_, msname_; 00131 00132 // Spw index, nchan, startchan for each CAL_DESC_ID index 00133 Int nCDI_; 00134 Vector<Int> cdi_; 00135 Vector<Int> spwFromCDI_; 00136 Vector<Int> nchanFromCDI_; 00137 Vector<Int> startFromCDI_; 00138 00139 PtrBlock<Vector<Double>*>freqFromCDI_; 00140 00141 // Transient Table objects used when loading/flagging 00142 Table *tab_p, *seltab_p; 00143 TableIterator *iter_p; 00144 00145 }; 00146 typedef CountedPtr<PlotCalCache> PlotCalCachePtr; 00147 00148 00149 } 00150 00151 #endif /* PLOTMSCACHE_H_ */