casa
$Rev:20696$
|
00001 //# MsAverager.h: Measurement Sets (Visiablity Averager) 00002 //# Copyright (C) 2003 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 //# 00027 //# 00028 //# ------------------------------------------------------------------------- 00029 00030 #if !defined MSAVERAGER_H 00031 #define MSAVERAGER_H 00032 00033 00034 #include <casa/aips.h> 00035 00036 #include <tables/Tables/SetupNewTab.h> 00037 //#include <tables/Tables/Table.h> 00038 #include <tables/Tables/MemoryTable.h> 00039 #include <tables/Tables/TableDesc.h> 00040 #include <tables/Tables/StManAipsIO.h> 00041 00042 #include <ms/MeasurementSets/MSColumns.h> 00043 #include <ms/MeasurementSets/MeasurementSet.h> 00044 00045 #include <casa/Containers/List.h> 00046 00047 #include <synthesis/MSVis/VisBuffer.h> 00048 #include <synthesis/MSVis/VisibilityIterator.h> 00049 #include <synthesis/MSVis/VisSet.h> 00050 //#include <synthesis/MSVis/SubMS.h> 00051 #include <synthesis/MSVis/SelectAverageSpw.h> 00052 00053 00054 00056 //# Start of documentation. 00057 // 00058 // <summary> 00059 // A class to average a visibilty data set in time and/or channel 00060 // </summary> 00061 // 00062 // <use visibility=export> 00063 // 00064 // <reviewed reviewer="Me" date="2007/12/25" tests="" demos=""> 00065 // </reviewed> 00066 00067 // <prerequisite> 00068 // <li> VisBuffer 00069 // <li> MeasurementSet 00070 // </prerequisite> 00071 // 00072 // <etymology> 00073 // From "visibility", "time", "channel", "polarization" and "averaging". 00074 // </etymology> 00075 // 00076 // <synopsis> 00077 // This class averages VisBuffers in time, channel. 00078 // </synopsis> 00079 // 00080 // <example> 00081 // MS ms("ngc5921.ms" Table::Update); 00082 // MsAverager msa(ms); 00083 // //chanlist is matrix of int its rows [spwid, start, end, step] 00084 // msa.setAverager(chanlist, 90, 32, "data", "SCALAR"); 00085 // if (msa.ok()) { 00086 // MS avems; 00087 // msa.getMS(avems); 00088 // } 00089 // 00090 // </example> 00091 // 00092 // <motivation> 00093 // Provide time/channel averaging capabilities for plotxy. 00094 // </motivation> 00095 // 00096 // <thrown> 00097 // <li> 00098 // <li> 00099 // </thrown> 00100 // 00101 // <todo asof="2007/12/25"> 00102 // <li> everything, and 00103 // <li> everything else 00104 // </todo> 00105 00106 //# End of documentation. 00108 00109 namespace casa { 00110 00111 00112 class MsAverager 00113 { 00114 00115 public: 00116 enum OutputMode { 00117 TableMS = 1, 00118 ListBuffer 00119 }; 00120 00121 MsAverager(MS*, OutputMode = MsAverager::TableMS); 00122 ~MsAverager(); 00123 00124 void reset(MS*, OutputMode = MsAverager::TableMS); 00125 void getMS(MS& ms); 00126 void getXY(Vector<Double>& x, Vector<Double>& y, 00127 Vector<Int>& f, Int pol); 00128 void getMap(Matrix<Int>& rowMap, Matrix<Int>& chanMap); 00129 00130 //average engine and its status 00131 void setAverager( 00132 const Matrix<Int>& chanList, 00133 const Matrix<Int>& baselines, 00134 Double aveTime, Int aveChan, 00135 const String& column = "DATA", 00136 const String& aveMode = "VECTOR", 00137 const Bool& aveFlag = False, 00138 const Bool& aveScan = False, 00139 const Bool& aveBline = False, 00140 const Bool& aveArray = False, 00141 const Bool& aveVelo = False, 00142 const String& restfreq = "", 00143 const String& frame = "", 00144 const String& doppler = ""); 00145 Bool ok() {return aveOK;} 00146 Int outputFormat() {return outputMode;} 00147 00148 void showColumnNames(); 00149 Bool isDataColumn(const String& colNmae); 00150 Bool hasColumn(const String& colName); 00151 static Int baselineRow(const Int& nAnt, const Int& a, const Int& b); 00152 Int baselineRow(const Int& a = -1, const Int& b = -1); 00153 00154 void putAveBuffer(Double bufTime, Int bufField, Int bufScan, 00155 Int bufArray, VisBuffer& p, Int nTime); 00156 void initAveBuffer(Double bufTime, VisBuffer& p, Int nAnt, Int nChan); 00157 void putAveTable(Double bufTime, Int bufField, Int bufScan, 00158 Int bufArray, Int bufSpw, VisBuffer& p, Int nTime, 00159 Double timeShift); 00160 void showVisRow(Cube<Complex>& vc, Int row); 00161 void showMsRow(MSMainColumns* msc, Int row); 00162 void showAveMap(Matrix<Int>& rmap, Matrix<Int>& cmap); 00163 00164 const static String DataColumn[4]; 00165 Int npol() {return nAvePol;} 00166 Int nchan() {return nAveChan;} 00167 Int nAnt() {return nAntenna;} 00168 00169 private: 00170 //to be averaged 00171 void cleanup(); 00172 MS* pMS; 00173 VisSet* vs; 00174 String msName; 00175 //MSDerivedValues *msdv; 00176 00177 //averaged, store as MS 00178 MS aMS; 00179 Int msRow; 00180 MSMainColumns *msc; 00181 //MSColumns *msc; 00182 00183 //averaged, store as VBs 00184 VisBuffer* pAveBuff; 00185 List<VisBuffer*> aveList; 00186 00187 //averaging inputs, ideally, calculate only needed column 00188 String column; 00189 00190 //selected channels for each piece for spw expression 00191 //each row contains [spwid, start, end, stride] 00192 //may contains multiple rows of same spwid 00193 Matrix<Int> chanList; 00194 00195 Vector<SAS> spw; 00196 00197 //map between averaged and original 00198 Matrix<Int> aveChanMap; 00199 //Matrix<Double> aveTimeMap; 00200 Matrix<Int> aveRowMap; 00201 00202 //averaging requirements 00203 String aveMode; 00204 Double aveTime; 00205 Int aveChan; 00206 Bool aveFlag; 00207 Bool crossScans; 00208 Bool crossBlines; 00209 Bool crossArrays; 00210 Bool crossSpws; 00211 Bool aveVel; 00212 Bool sorryVel; 00213 Matrix<Int> baselines; 00214 00215 //size of the averaged 00216 Int nAveChan; 00217 Int nAveTime; 00218 Int nAveRow; 00219 Int nAvePol; 00220 Int nAntenna; 00221 00222 String restfreq; 00223 String frame; 00224 String doppler; 00225 00226 Bool aveOK; 00227 00228 //utility 00229 static const String clname; 00230 //SLog *log; 00231 00232 int outputMode; 00233 00234 00235 }; 00236 00237 00238 } 00239 #endif 00240 00241