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 PLOTMSINDEXER_H_
00028 #define PLOTMSINDEXER_H_
00029
00030 #include <casa/aips.h>
00031 #include <casa/Arrays.h>
00032 #include <casa/Containers/Block.h>
00033 #include <graphics/GenericPlotter/PlotData.h>
00034
00035 #include <plotms/PlotMS/PlotMSConstants.h>
00036 #include <plotms/Data/PlotMSCacheBase.h>
00037
00038
00039
00040 namespace casa {
00041
00042
00043 class PlotMSApp;
00044 class PlotMSIndexer;
00045
00046 typedef Double(PlotMSCacheBase::*CacheMemPtr)(Int,Int);
00047 typedef Int(PlotMSIndexer::*IndexerMethPtr)(Int,Int);
00048 typedef void(PlotMSIndexer::*CollapseMethPtr)(Int,Array<Bool>&);
00049
00050 class PlotMSIndexer : public PlotMaskedPointData, public PlotBinnedData {
00051
00052 public:
00053
00054
00055 static const String CLASS_NAME;
00056
00057
00058 PlotMSIndexer();
00059
00060
00061 PlotMSIndexer(PlotMSCacheBase* plotmscache, PMS::Axis xAxis, PMS::Axis yAxis, int index);
00062
00063 PlotMSIndexer(PlotMSCacheBase* plotmscache, PMS::Axis xAxis, PMS::Axis yAxis,
00064 PMS::Axis iterAxis, Int iterValue, int index);
00065
00066
00067 ~PlotMSIndexer();
00068
00069
00070
00071 bool willDeleteData() const { return true; }
00072 void setDeleteData(bool del = true) { (void)del; }
00073 bool isValid() const { return true;};
00074
00075
00076
00077
00078 unsigned int size() const;
00079 double xAt(unsigned int i) const;
00080 double yAt(unsigned int i) const;
00081 void xAndYAt(unsigned int index, double& x, double& y) const;
00082 bool minsMaxes(double& xMin, double& xMax, double& yMin, double& yMax);
00083
00084
00085
00086
00087 bool maskedAt(unsigned int index) const;
00088 void xyAndMaskAt(unsigned int index, double& x, double& y, bool& mask) const;
00089
00090
00091
00092
00093 unsigned int sizeMasked() const { return sizeMasked_; }
00094 unsigned int sizeUnmasked() const { return sizeUnMasked_; }
00095 bool maskedMinsMaxes(double& xMin, double& xMax, double& yMin,double& yMax);
00096 bool unmaskedMinsMaxes(double& xMin, double& xMax, double& yMin,double& yMax);
00097
00098
00099
00100
00101 unsigned int numBins() const;
00102 unsigned int binAt(unsigned int i) const;
00103 bool isBinned() const;
00104
00105
00106
00107 void setUpIndexing();
00108
00109
00110 void setGlobalMinMax(Bool globalX=False,Bool globalY=False);
00111 bool isGlobalXRange() const;
00112 bool isGlobalYRange() const;
00113
00114
00115 Vector<uInt> nPoints() { return nPoints_; };
00116 Vector<uInt> nCumulative() { return nCumulative_; };
00117
00118
00119 inline Bool indexerReady() const { return indexerReady_; };
00120
00121
00122 Record getPointMetaData(Int i);
00123 Record locateInfo(const Vector<PlotRegion>& regions,
00124 Bool showUnflagged, Bool showFlagged,
00125 Bool selectAll = true);
00126 PlotLogMessage* locateRange(const Vector<PlotRegion>& regions,
00127 Bool showUnflagged, Bool showFlagged);
00128 PlotLogMessage* flagRange(const PlotMSFlagging& flagging,
00129 const Vector<PlotRegion>& regions, Bool flag = True);
00130
00131
00132
00133 void reportMeta(Double x, Double y, Bool masked, stringstream& ss);
00134
00135
00136 void flagInCache(const PlotMSFlagging& flagging,Bool flag);
00137
00138
00139 String iterLabel();
00140 String iterValue();
00141 String fileLabel();
00142
00143
00144 bool maskedMinsMaxesRaw(double& xMin, double& xMax, double& yMin,double& yMax);
00145 bool unmaskedMinsMaxesRaw(double& xMin, double& xMax, double& yMin,double& yMax);
00146
00147
00148
00149
00150 Int getIndex0000(Int ch,Int irel) { return 0; (void)irel; (void)ch; };
00151 Int getIndex1000(Int ch,Int irel) { return irel%icorrmax_(ch);};
00152 Int getIndex0100(Int ch,Int irel) { return (irel/nperchan_(ch))%ichanmax_(ch);};
00153 Int getIndex0010(Int ch,Int irel) { return (irel/nperbsln_(ch))%ibslnmax_(ch);};
00154 Int getIndex0110(Int ch,Int irel) { return (irel/nperchan_(ch))%ichanbslnmax_(ch);};
00155 Int getIndex1010(Int ch,Int irel) { return (irel/nperbsln_(ch))*nperchan_(ch) + irel%nperchan_(ch);};
00156 Int getIndex1110(Int ch,Int irel) { return irel%idatamax_(ch);};
00157 Int getIndex0001(Int ch,Int irel) { return (irel/nperant_(ch))%iantmax_(ch);};
00158
00159
00160
00161 bool colorize(bool doColorize, PMS::Axis colorizeAxis);
00162
00163
00164
00165
00166 private:
00167
00168
00169 PlotMSIndexer(const PlotMSIndexer& mc);
00170
00171 void setMethod(CacheMemPtr& getmethod, PMS::Axis axis);
00172 void setIndexer(IndexerMethPtr& indexmethod, PMS::Axis axis);
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 Int nChunk() const { return (plotmscache_ ? plotmscache_->nChunk() : 0); };
00189
00190
00191 inline Double refTime() { return plotmscache_->refTime(); };
00192
00193
00194 void setChunk(uInt i) const;
00195
00196
00197
00198 void computeRanges();
00199
00200
00201 Double computeBaselineLength(Int ant1, Int ant2);
00202
00203
00204
00205
00206 void logInfo(const String& method, const String& message) {
00207 log(method, message, PlotLogger::MSG_INFO); }
00208 void logDebug(const String& method, const String& message) {
00209 log(method, message, PlotLogger::MSG_DEBUG); }
00210 void logWarn(const String& method, const String& message) {
00211 log(method, message, PlotLogger::MSG_WARN); }
00212 void logError(const String& method, const String& message) {
00213 log(method, message, PlotLogger::MSG_ERROR); }
00214
00215
00216
00217
00218 void log(const String& method, const String& message, int eventType);
00219
00220
00221
00222
00223
00224
00225 PlotMSCacheBase* plotmscache_;
00226
00227
00228 CacheMemPtr getXFromCache_, getYFromCache_,getColFromCache_;
00229 IndexerMethPtr XIndexer_, YIndexer_, ColIndexer_;
00230
00231
00232
00233 mutable Int currChunk_, irel_;
00234 mutable uInt lasti_;
00235
00236
00237 Vector<uInt> nPoints_;
00238
00239
00240 Vector<uInt> nCumulative_;
00241
00242
00243 Int nSegment_;
00244 mutable Int currSeg_;
00245 Vector<uInt> nSegPoints_,nCumulPoints_,cacheChunk_,cacheOffset_;
00246
00247
00248 PMS::Axis currentX_, currentY_;
00249 bool indexerReady_;
00250
00251
00252 Vector<Int> icorrmax_, ichanmax_, ibslnmax_, idatamax_;
00253 Vector<Int> nperchan_, nperbsln_, nperant_;
00254 Vector<Int> ichanbslnmax_;
00255 Vector<Int> iantmax_;
00256
00257
00258 Double xmin_,ymin_,xflmin_,yflmin_,xmax_,ymax_,xflmax_,yflmax_;
00259 Int sizeMasked_, sizeUnMasked_;
00260 Bool globalXMinMax_,globalYMinMax_;
00261
00262
00263
00264 Bool iterate_;
00265 PMS::Axis iterAxis_;
00266 Int iterValue_;
00267
00268
00269
00270
00271 bool itsColorize_;
00272 PMS::Axis itsColorizeAxis_;
00273
00274
00275
00276 PlotMSIndexer* self;
00277
00278
00279 int dataIndex;
00280
00281 };
00282
00283 typedef CountedPtr<PlotMSIndexer> PlotMSIndexerPtr;
00284
00285 }
00286
00287 #endif