casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSCache.h
Go to the documentation of this file.
1 //# MSCache.h: casacore::MS-specific casacore::Data cache for plotms.
2 //# Copyright (C) 2009
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef MSCACHE_H_
28 #define MSCACHE_H_
29 
32 
33 
37 //#include <plotms/Threads/PlotMSCacheThread.qo.h>
41 
42 #include <casa/aips.h>
43 #include <casa/Arrays.h>
44 #include <casa/Containers/Block.h>
46 #include <msvis/MSVis/VisBuffer2.h>
50 
51 namespace casa {
52 
53 //# Forward declarations.
54 class PlotMSApp;
55 class PlotMSIndexer;
56 
57 class MSCache : public PlotMSCacheBase {
58 
59  // Friend class declarations.
60  friend class PlotMSIndexer;
61 
62 public:
63 
64  // Constructor which takes parent PlotMS.
65  MSCache(PlotMSApp* parent);
66 
67  // Destructor
68  virtual ~MSCache();
69 
70  // Identify myself
72 
73  // ...not yet casacore::MS-specific... (or ever?)
74  // Set up indexing for the plot
75  // void setUpIndexer(PMS::Axis iteraxis=PMS::SCAN,
76  // casacore::Bool globalXRange=false, casacore::Bool globalYRange=false);
77 
78  void setFilename(casacore::String filename) { filename_ = filename; };
80  const PageHeaderCache& pageHeaderCache() const { return pageHeaderCache_; };
81 
82 protected:
83 
84  // casacore::MS-specific loadIt method
85  virtual void loadIt(std::vector<PMS::Axis>& loadAxes,
86  std::vector<PMS::DataColumn>& loadData,
87  /*PlotMSCacheThread**/ThreadCommunication* thread = NULL);
88 
89  //Returns whether or not the ephemeris data has been
90  //attached to a field - radial velocity and rho.
91  virtual bool isEphemeris();
92 private:
93 
94  // Forbid copy for now
95  MSCache(const MSCache&);
96 
97  // Set up:
98  // DataColumn
99  casacore::String getDataColumn(std::vector<PMS::Axis>& loadAxes,
100  std::vector<PMS::DataColumn>& loadData);
101  PMS::DataColumn checkReqDataColumn(PMS::DataColumn reqDataCol);
102  void adjustCurrentAxes(PMS::Axis axis, PMS::DataColumn olddata,
103  PMS::DataColumn newdata);
106  // MS String names
108  // VisIter
109  void setUpVisIter(PlotMSSelection& selection,
110  PlotMSCalibration& calibration,
111  casacore::String dataColumn,
112  std::vector<PMS::Axis>& loadAxes,
113  std::vector<PMS::DataColumn>& loadData,
114  casacore::Bool interactive=false,
115  casacore::Bool estimateMemory=false,
116  ThreadCommunication* thread=NULL);
122 
123  // clean up
124  void deleteVi();
125  void deleteVm();
126  void loadError(casacore::String mesg);
127 
128  // Estimate cache size for averaging
130  casacore::Vector<casacore::Int>& nIterPerAve,
131  std::vector<PMS::Axis>& loadAxes,
132  std::vector<PMS::DataColumn>& loadData,
133  /*PlotMSCacheThread**/ThreadCommunication* thread);
135 
136  // Trap attempt to use to much memory (too many points)
137  void trapExcessVolume(map<PMS::Axis,casacore::Bool> pendingLoadAxes);
138  std::vector<casacore::IPosition> visBufferShapes_;
139 
140  // Loop over VisIter, filling the cache
142  const std::vector<PMS::Axis> loadAxes,
143  const std::vector<PMS::DataColumn> loadData,
144  /*PlotMSCacheThread**/ThreadCommunication* thread);
146  const PlotMSAveraging& averaging,
147  const casacore::Vector<casacore::Int>& nIterPerAve,
148  const std::vector<PMS::Axis> loadAxes,
149  const std::vector<PMS::DataColumn> loadData,
150  /*PlotMSCacheThread**/ThreadCommunication* thread);
152 
153  // Force read on vb for requested axes
154  // (so pre-cache averaging treats all data it should)
155  void forceVBread(vi::VisBuffer2* vb,
156  std::vector<PMS::Axis> loadAxes,
157  std::vector<PMS::DataColumn> loadData);
158 
159  // Tell time averager which data column to read
160  void discernData(std::vector<PMS::Axis> loadAxes,
161  std::vector<PMS::DataColumn> loadData,
162  PlotMSVBAverager& vba);
163 
164  // Loads the specific axis/metadata into the cache using the given VisBuffer.
165  void loadAxis(vi::VisBuffer2* vb, casacore::Int vbnum, PMS::Axis axis,
166  PMS::DataColumn data = PMS::DEFAULT_DATACOLUMN);
167 
168  // Set flags in the MS
169  virtual void flagToDisk(const PlotMSFlagging& flagging,
172  casacore::Bool setFlag,
173  PlotMSIndexer* indexer, int dataIndex);
174 
176 
177  // For averaging done by PlotMSVBAverager;
178  // Some axes need to come from VB2 attached to VI2
179  bool useAveragedVisBuffer(PMS::Axis axis);
180 
181  // Page Header Cache loading
182  void loadPageHeaderCache(const casacore::MeasurementSet& selectedMS);
184 
185  // Datacolumn to use (requested or "adjusted")
187 
188  // Create map of intent names to "intent ids"
189  // since state ids can duplicate intents.
190  // Then use map to assign intent ids to replace state ids
191  // (stateId -> intent string -> intentId)
192  map<casacore::String, casacore::Int> intentIds_;
193  void mapIntentNamesToIds(); // create map
194  // Use map to assign intent ids
196  // Check if plotting antennas pointing directions is supported for the given MeasurementSet
197  bool pointingsPlotSupported(const MeasurementSet* const &ms);
198 
199  // Provisional flagging helpers
201 
202  // VisIterator pointer
204 
206 
207  // Volume meter for volume calculation
209 
210  map<casacore::Int, casacore::Int> chansPerSpw_;
211 
213 
214 };
216 
217 
218 }
219 
220 #endif /* MSCACHE_H_ */
map< casacore::String, casacore::Int > intentIds_
Create map of intent names to &quot;intent ids&quot; since state ids can duplicate intents. ...
Definition: MSCache.h:192
void loadAxis(vi::VisBuffer2 *vb, casacore::Int vbnum, PMS::Axis axis, PMS::DataColumn data=PMS::DEFAULT_DATACOLUMN)
Loads the specific axis/metadata into the cache using the given VisBuffer.
virtual casacore::String polname(casacore::Int ipol)
Access to pol names.
A 1-D Specialization of the Array class.
Specifies averaging parameters for an MS.
int Int
Definition: aipstype.h:50
std::vector< casacore::IPosition > visBufferShapes_
Definition: MSCache.h:138
bool countChunks(vi::VisibilityIterator2 &vi, casacore::Vector< casacore::Int > &nIterPerAve, std::vector< PMS::Axis > &loadAxes, std::vector< PMS::DataColumn > &loadData, ThreadCommunication *thread)
Estimate cache size for averaging.
void deleteVi()
clean up
void loadPageHeaderCache(const casacore::MeasurementSet &selectedMS)
Page Header Cache loading.
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
void trapExcessVolume(map< PMS::Axis, casacore::Bool > pendingLoadAxes)
Trap attempt to use to much memory (too many points)
casacore::Vector< casacore::Int > assignIntentIds(casacore::Vector< casacore::Int > &stateIds)
Use map to assign intent ids.
void forceVBread(vi::VisBuffer2 *vb, std::vector< PMS::Axis > loadAxes, std::vector< PMS::DataColumn > loadData)
Force read on vb for requested axes (so pre-cache averaging treats all data it should) ...
casacore::String checkLoadedAxesDatacol()
FrequencySelectionUsingChannels()
bool useAveragedVisBuffer(PMS::Axis axis)
For averaging done by PlotMSVBAverager; Some axes need to come from VB2 attached to VI2...
Specifies an casacore::MS selection.
void setUpFrequencySelectionChannels(vi::FrequencySelectionUsingChannels fs, casacore::Vector< casacore::Vector< casacore::Slice > > chansel)
PMS::DataColumn checkReqDataColumn(PMS::DataColumn reqDataCol)
map< casacore::Int, casacore::Int > chansPerSpw_
Definition: MSCache.h:210
MSCacheVolMeter * vm_
Volume meter for volume calculation.
Definition: MSCache.h:208
casacore::String filename_
A copy of the casacore::Data parameters.
casacore::Vector< casacore::Double > calcVelocity(vi::VisBuffer2 *vb)
PlotMSAveraging & averaging()
Access to averaging state in the cache:
MSCache(PlotMSApp *parent)
Constructor which takes parent PlotMS.
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
virtual void loadIt(std::vector< PMS::Axis > &loadAxes, std::vector< PMS::DataColumn > &loadData, ThreadCommunication *thread=NULL)
casacore::MS-specific loadIt method
PlotMSCacheBase::Type cacheType() const
Identify myself.
Definition: MSCache.h:71
Controller class for plotms.
Definition: PlotMS.h:55
A class to average VisBuffers for PlotMS.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
virtual ~MSCache()
Destructor.
vi::PointingInterpolationTVI * piTvi_
Definition: MSCache.h:205
casacore::String normalizeColumnName(casacore::String plotmscol)
Specifies flagging parameters (including possibly flag extension) for an MS.
void setFilename(casacore::String filename)
...not yet casacore::MS-specific...
Definition: MSCache.h:78
void updateProgress(ThreadCommunication *thread, casacore::Int chunk)
void completeLoadPageHeaderCache()
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void discernData(std::vector< PMS::Axis > loadAxes, std::vector< PMS::DataColumn > loadData, PlotMSVBAverager &vba)
Tell time averager which data column to read.
casacore::String getDataColumn(std::vector< PMS::Axis > &loadAxes, std::vector< PMS::DataColumn > &loadData)
Set up: DataColumn.
virtual void flagToDisk(const PlotMSFlagging &flagging, casacore::Vector< casacore::Int > &chunks, casacore::Vector< casacore::Int > &relids, casacore::Bool setFlag, PlotMSIndexer *indexer, int dataIndex)
Set flags in the MS.
static const DataColumn DEFAULT_DATACOLUMN
A Table intended to hold astronomical data (a set of Measurements).
PlotMSIndexer & indexer(int dataIndex, casacore::uInt i)
Reference an indexer; returns -1 if there is no indexer for the given dataIndex.
void loadError(casacore::String mesg)
const PageHeaderCache & pageHeaderCache() const
Definition: MSCache.h:80
void loadChunks(vi::VisibilityIterator2 &vi, const std::vector< PMS::Axis > loadAxes, const std::vector< PMS::DataColumn > loadData, ThreadCommunication *thread)
Loop over VisIter, filling the cache.
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
Type
TBD: friend class PlotMSData;.
void adjustCurrentAxes(PMS::Axis axis, PMS::DataColumn olddata, PMS::DataColumn newdata)
PageHeaderCache pageHeaderCache_
Page header items.
virtual bool isEphemeris()
Returns whether or not the ephemeris data has been attached to a field - radial velocity and rho...
vi::VisibilityIterator2 * vi_p
VisIterator pointer.
Definition: MSCache.h:203
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void setUpVisIter(PlotMSSelection &selection, PlotMSCalibration &calibration, casacore::String dataColumn, std::vector< PMS::Axis > &loadAxes, std::vector< PMS::DataColumn > &loadData, casacore::Bool interactive=false, casacore::Bool estimateMemory=false, ThreadCommunication *thread=NULL)
VisIter.
void getNamesFromMS(casacore::MeasurementSet &ms)
MS String names.
Specifies calibration parameters for an MS.
void updateEstimateProgress(ThreadCommunication *thread)
Subchunk class Provides the ordered pair identifying the current subchunk The first component is the chunk(goes from 0 to nChunks-1 during the outer loop iteration).The second component is the subchunk number which is zero after VisibilityIterator
casacore::Vector< casacore::Int > nVBPerAve_
Provisional flagging helpers.
Definition: MSCache.h:200
casacore::CountedPtr< MSCache > MSCachePtr
Definition: MSCache.h:215
Defines communication mechanisms that the model and data can use to communicate with the UI concernin...
bool ephemerisAvailable
Definition: MSCache.h:212
casacore::String dataColumn_
Datacolumn to use (requested or &quot;adjusted&quot;)
Definition: MSCache.h:186
bool pointingsPlotSupported(const MeasurementSet *const &ms)
Check if plotting antennas pointing directions is supported for the given MeasurementSet.
void mapIntentNamesToIds()