casa
$Rev:20696$
|
00001 //# GroupProcessor.h: Step through the Measurement Set by groups of VisBuffers. 00002 //# Copyright (C) 2011 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 #ifndef MSVIS_GROUPPROCESSOR_H 00027 #define MSVIS_GROUPPROCESSOR_H 00028 00029 #include <casa/aips.h> 00030 //#include <casa/Containers/Stack.h> 00031 //#include <ms/MeasurementSets/MeasurementSet.h> 00032 //#include <synthesis/MSVis/VisBuffGroup.h> 00033 #include <synthesis/MSVis/VisibilityIterator.h> 00034 #include <synthesis/MSVis/GroupWorker.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# forward decl 00039 //class Block; 00040 //class MeasurementSet; 00041 00042 // <summary> 00043 // GroupProcessor goes through one or more MeasurementSets, feeding VisBuffGroups 00044 // to a GroupWorker. 00045 // </summary> 00046 // <use visibility=export> 00047 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00048 // </reviewed> 00049 // <prerequisite> 00050 // <li> <linkto class="VisibilityIterator">VisibilityIterator</linkto> 00051 // <li> <linkto class="MeasurementSet">MeasurementSet</linkto> 00052 // <li> <linkto class="VisBuffer">VisBuffer</linkto> 00053 // <li> <linkto class="VisBuffGroup">VisBuffGroup</linkto> 00054 // <li> <linkto class="GroupWorker">GroupWorker</linkto> 00055 // </prerequisite> 00056 // 00057 // <etymology> 00058 // The GroupProcessor processes one VisBuffGroup after another. 00059 // </etymology> 00060 // 00061 // <synopsis> 00062 // GroupProcessor handles iteration with by groups of chunklets 00063 // for one or more MSs. 00064 // </synopsis> 00065 // 00066 // <example> 00067 // <code> 00068 // // VBGContinuumSubtractor is a GroupWorker. 00069 // VBGContinuumSubtractor vbgcs(msOut_p, fitorder_p); 00070 // 00071 // // sort is a Block<Int> with the right columns. 00072 // VisibilityIterator viIn(mssel_p, sort, 0.0); 00073 // 00074 // GroupProcessor rogp(viIn, &vbgcs); 00075 // Bool success = rogp.go(); // Encapsulates the nested for loops. 00076 // </code> 00077 // </example> 00078 // 00079 // <motivation> 00080 // For imaging and calibration you need to access an MS in some consistent 00081 // order (by field, spectralwindow, time interval etc.). This class provides 00082 // that access. Furthermore, some calculations or applications need more than 00083 // one VisBuffer. For example, one might want to estimate and subtract the 00084 // continuum from the visibilities of an MS that has a broad line completely 00085 // spanning spw 1, but spws 0 and 2 line-free, so the spws should be combined 00086 // (combine='spw') for the continuum estimation. 00087 // 00088 // It is much more efficient if the group of necessary data can be read only 00089 // once, worked on, and then written. The CalTable approach is more flexible 00090 // in that a CalTable can be applied to an MS with a different number or 00091 // arrangement of rows from the input MS, but per chunk it requires two more 00092 // reads (the CalTable and the _output_ MS) and an extra write (the CalTable). 00093 // 00094 // Another goal is to encapsulate the commonly repeated boilerplate of setting 00095 // up VisIters and VisBuffers, and then looping over chunks and then chunklets. 00096 // 00097 // A separate GroupProcessor is needed so the input MS can be declared const. 00098 // </motivation> 00099 // 00100 // <thrown> 00101 // <li> 00102 // <li> 00103 // </thrown> 00104 // 00105 // <todo asof="2011/11/07"> 00106 // ProgressMeter 00107 // </todo> 00108 class GroupProcessor 00109 { 00110 public: 00111 // Construct from a ROVisibilityIterator (provides the data) and a 00112 // pointer to a GroupWorker (does something with the data). 00113 // 00114 // vi should be set up (selection, slurping, and sort order specified) before 00115 // calling this, but this will call vi.originChunks() and drive the iteration. 00116 // 00117 GroupProcessor(ROVisibilityIterator& vi, GroupWorkerBase *gw, 00118 Double groupInterval=0.0); 00119 00120 // // Copy construct. This calls the assigment operator. 00121 // GroupProcessor(const GroupProcessor & other){ 00122 // vi_p = other.vi_p ? other.vi_p->clone(&(this->vi_p)) : NULL; 00123 // } 00124 00125 // Assigment. Any attached VisBuffers are lost in the assign. 00126 // GroupProcessor & operator=(const GroupProcessor &other); 00127 // // Destructor 00128 // //virtual ~GroupProcessor() {}; 00129 // ~GroupProcessor() {}; 00130 00131 // Members 00132 00133 // Return and set the "timebin" for each group, in s. 00134 Double groupInterval() {return groupInterval_p;} 00135 void setGroupInterval(Double gi) {groupInterval_p = abs(gi);} 00136 00137 // Once it's all set up, you should just have to tell it to go! 00138 // Returns true/false depending on whether it thinks it went all the way. 00139 Bool go(); 00140 00141 static String getAipsRcBase() {return "GroupProcessor";} 00142 00143 private: 00144 void setGroupOrigin(); // Record the beginning of a new group. 00145 Bool groupHasMore(); // Returns whether or not more VisBuffers 00146 // should be added to the group. 00147 00148 // Initialized by c'tor. 00149 ROVisibilityIterator vi_p; 00150 GroupWorkerBase *gw_p; 00151 Double groupInterval_p; // >= 0.0, in s. 00152 00153 // Uninitialized by c'tor. 00154 Vector<Double> timev_p; 00155 Double groupStart_p; 00156 }; 00157 00158 } //# NAMESPACE CASA - END 00159 00160 #endif