MSCache.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef MSCACHE_H_
00028 #define MSCACHE_H_
00029
00030 #include <plotms/Data/PlotMSCacheBase.h>
00031
00032 #include <plotms/PlotMS/PlotMSAveraging.h>
00033 #include <plotms/PlotMS/PlotMSConstants.h>
00034 #include <plotms/PlotMS/PlotMSFlagging.h>
00035
00036 #include <plotms/Threads/ThreadCommunication.h>
00037 #include <plotms/Data/PlotMSVBAverager.h>
00038 #include <plotms/Data/MSCacheVolMeter.h>
00039
00040 #include <casa/aips.h>
00041 #include <casa/Arrays.h>
00042 #include <casa/Containers/Block.h>
00043 #include <msvis/MSVis/VisibilityIterator2.h>
00044 #include <msvis/MSVis/VisBuffer2.h>
00045 #include <msvis/MSVis/VisBufferUtil.h>
00046 #include <msvis/MSVis/ViFrequencySelection.h>
00047
00048 namespace casa {
00049
00050
00051 class PlotMSApp;
00052 class PlotMSIndexer;
00053
00054 class MSCache : public PlotMSCacheBase {
00055
00056
00057 friend class PlotMSIndexer;
00058
00059 public:
00060
00061
00062 MSCache(PlotMSApp* parent);
00063
00064
00065 virtual ~MSCache();
00066
00067
00068 PlotMSCacheBase::Type cacheType() const { return PlotMSCacheBase::MS; };
00069
00070
00071
00072
00073
00074
00075 void setFilename(String filename) { filename_ = filename; };
00076 virtual String polname(Int ipol);
00077
00078 protected:
00079
00080
00081 virtual void loadIt(vector<PMS::Axis>& loadAxes,
00082 vector<PMS::DataColumn>& loadData,
00083 ThreadCommunication* thread = NULL);
00084
00085
00086
00087 virtual bool isEphemeris();
00088 private:
00089
00090
00091 MSCache(const MSCache&);
00092
00093
00094 String getDataColumn(vector<PMS::Axis>& loadAxes,
00095 vector<PMS::DataColumn>& loadData);
00096 PMS::DataColumn checkReqDataColumn(PMS::DataColumn reqDataCol);
00097 String checkLoadedAxesDatacol();
00098 String normalizeColumnName(String plotmscol);
00099 void getNamesFromMS(MeasurementSet& ms);
00100 void logChansForSpws(MeasurementSet& ms, Int chanVal);
00101 void setUpVisIter(PlotMSSelection& selection,
00102 PlotMSCalibration& calibration,
00103 String dataColumn,
00104 Bool interactive=False,
00105 Bool estimateMemory=False,
00106 ThreadCommunication* thread=NULL);
00107 vi::VisibilityIterator2* setUpVisIter(MeasurementSet& selectedMS,
00108 Vector<Vector<Slice> > chansel, Vector<Vector<Slice> > corrsel);
00109 void setUpFrequencySelectionChannels(vi::FrequencySelectionUsingChannels fs,
00110 Vector<Vector<Slice> > chansel);
00111
00112
00113 void deleteVi();
00114 void deleteVm();
00115 void loadError(String mesg);
00116
00117
00118 bool countChunks(vi::VisibilityIterator2& vi, Vector<Int>& nIterPerAve,
00119 ThreadCommunication* thread);
00120 void updateEstimateProgress(ThreadCommunication* thread);
00121
00122
00123 void trapExcessVolume(map<PMS::Axis,Bool> pendingLoadAxes);
00124 std::vector<IPosition> visBufferShapes_;
00125
00126
00127 void loadChunks(vi::VisibilityIterator2& vi,
00128 const vector<PMS::Axis> loadAxes,
00129 const vector<PMS::DataColumn> loadData,
00130 ThreadCommunication* thread);
00131 void loadChunks(vi::VisibilityIterator2& vi,
00132 const PlotMSAveraging& averaging,
00133 const Vector<Int>& nIterPerAve,
00134 const vector<PMS::Axis> loadAxes,
00135 const vector<PMS::DataColumn> loadData,
00136 ThreadCommunication* thread);
00137 void updateProgress(ThreadCommunication* thread, Int chunk);
00138
00139
00140
00141 void forceVBread(vi::VisBuffer2* vb,
00142 vector<PMS::Axis> loadAxes,
00143 vector<PMS::DataColumn> loadData);
00144
00145
00146 void discernData(vector<PMS::Axis> loadAxes,
00147 vector<PMS::DataColumn> loadData,
00148 PlotMSVBAverager& vba);
00149
00150
00151 void loadAxis(vi::VisBuffer2* vb, Int vbnum, PMS::Axis axis,
00152 PMS::DataColumn data = PMS::DEFAULT_DATACOLUMN);
00153
00154
00155 virtual void flagToDisk(const PlotMSFlagging& flagging,
00156 Vector<Int>& chunks,
00157 Vector<Int>& relids,
00158 Bool setFlag,
00159 PlotMSIndexer* indexer, int dataIndex);
00160
00161
00162 String dataColumn_;
00163
00164
00165
00166
00167
00168 map<String, Int> intentIds_;
00169 void mapIntentNamesToIds();
00170
00171 Vector<Int> assignIntentIds(Vector<Int>& stateIds);
00172
00173
00174 Vector<Int> nVBPerAve_;
00175
00176
00177 vi::VisibilityIterator2* vi_p;
00178
00179
00180 MSCacheVolMeter* vm_;
00181
00182 Vector<Double> calcVelocity(vi::VisBuffer2* vb);
00183
00184
00185
00186 bool useAveragedVisBuffer(PMS::Axis axis);
00187
00188 bool ephemerisAvailable;
00189 };
00190 typedef CountedPtr<MSCache> MSCachePtr;
00191
00192
00193 }
00194
00195 #endif