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
00028
00029
00030
00031
00032
00033
00034 #ifndef MSTRANSFORM_MSUVBIN_H
00035 #define MSTRANSFORM_MSUVBIN_H
00036 #include <ms/MeasurementSets/MeasurementSet.h>
00037 #include <coordinates/Coordinates/CoordinateSystem.h>
00038 #include <msvis/MSVis/VisBuffer2.h>
00039 #include <msvis/MSVis/VisBuffer.h>
00040 #include <msvis/MSVis/VisBufferUtil.h>
00041 #include <msvis/MSVis/VisBuffer.h>
00042 #include <msvis/MSVis/VisBufferUtil.h>
00043 namespace casa {
00044
00045
00046 class MSUVBin {
00047 public:
00048 MSUVBin();
00049
00050 MSUVBin(const MDirection& phaseCenter, const Int nx,
00051 const Int ny, const Int nchan, const Int npol, Quantity cellx, Quantity celly, Quantity freqStart, Quantity freqStep, Float memFraction=0.5, Bool dow=False, Bool doflag=False);
00052
00053 MSUVBin (MeasurementSet& ms);
00054
00055 virtual Bool selectData(const String& msname, const String& spw = "", const String& field = "",
00056 const String& baseline = "", const String& scan = "",
00057 const String& uvrange = "", const String& taql = "",
00058 const String& subarray = "", const String& correlation = "",
00059 const String& intent = "", const String& obs = "");
00060
00061
00062 void setOutputMS(const String& msname);
00063
00064 Bool fillOutputMS();
00065 virtual ~MSUVBin();
00066
00067 static Bool String2MDirection(const String& theString,
00068 MDirection& theMeas, const String msname="");
00069
00070 private:
00071 static Int sepCommaEmptyToVectorStrings(Vector<String>& retStr,
00072 const String& str);
00073 Bool fillSmallOutputMS();
00074 Bool fillNewBigOutputMS();
00075 Bool fillBigOutputMS();
00076 Int recoverGridInfo(const String& msname);
00077 void storeGridInfo();
00078 void createOutputMS(const Int nrrows);
00079 Int makeUVW(const Double reffreq, Vector<Double>& incr, Vector<Int>& cent, Matrix<Double>&uvw);
00080 void locateuvw(Matrix<Int>& locuv, const Vector<Double>& increment,
00081 const Vector<Int>& center, const Matrix<Double>& uvw);
00082 void gridData(const vi::VisBuffer2& vb, Cube<Complex>& grid,
00083 Matrix<Float>& wght, Cube<Float>& wghtSpec,
00084 Cube<Bool>& flag, Vector<Bool>& rowFlag, Matrix<Double>& uvw, Vector<Int>& ant1,
00085 Vector<Int>& ant2, Vector<Double>& time, const Matrix<Int>& locuv);
00086 void gridData(const vi::VisBuffer2& vb, Cube<Complex>& grid,
00087 Matrix<Float>& wght, Cube<Float>& wghtSpec,
00088 Cube<Bool>& flag, Vector<Bool>& rowFlag, Matrix<Double>& uvw, Vector<Int>& ant1,
00089 Vector<Int>& ant2, Vector<Double>& time, const Int startchan, const Int endchan);
00090 void gridDataConv(const vi::VisBuffer2& vb, Cube<Complex>& grid,
00091 Matrix<Float>& , Cube<Complex>& wghtSpec,
00092 Cube<Bool>& flag, Vector<Bool>& rowFlag, Matrix<Double>& uvw, Vector<Int>& ant1,
00093 Vector<Int>& ant2, Vector<Double>& timeCen, const Int startchan, const Int endchan,
00094 const Cube<Complex>& convFunc, const Vector<Int>& convSupport, const Double wScale, const Int convSampling);
00095 void gridDataConvThr(const vi::VisBuffer2& vb, Cube<Complex>& grid,
00096 Cube<Complex>& wghtSpec,
00097 Cube<Bool>& flag, Vector<Bool>& rowFlag, Matrix<Double>& uvw, Vector<Int>& ant1,
00098 Vector<Int>& ant2, Vector<Double>& timeCen, const Int startchan, const Int endchan,
00099 const Cube<Complex>& convFunc, const Vector<Int>& convSupport, const Double wScale, const Int convSampling);
00100 void inplaceGridData(const vi::VisBuffer2& vb);
00101 void inplaceLargeBW(const vi::VisBuffer2& vb);
00102 void inplaceSmallBW(const vi::VisBuffer2& vb);
00103 void makeCoordsys();
00104 void weightSync();
00105 void multiThrLoop(const Int outchan, const vi::VisBuffer2& vb, Double refFreq,
00106 Vector<Float> scale, Bool hasCorrected,Bool needRot,
00107 const Vector<Double>& phasor, const Vector<Double>& visFreq,
00108 const Double& fracbw,
00109 Complex*& grid, Complex*& wghtSpec, Bool*& flag,
00110 Bool*& rowFlag, Double*& uvw, Int*& ant1,
00111 Int*& ant2, Double*& timeCen, Double*& sumWeight, Double*& numvis,
00112 const Int startchan,
00113 const Int endchan, const Cube<Complex>& convFunc, const Vector<Int>& convSupport, const Double wScale, const Int convSampling );
00114 void locateFlagFromGrid(vi::VisBuffer2& vb, Cube<Bool>& datFlag,
00115 Cube<Float>& wghtSpec,
00116 Cube<Bool>& flag, Vector<Bool>& rowFlag, Matrix<Double>& uvw, Vector<Int>& ant1,
00117 Vector<Int>& ant2, Vector<Double>& timeCen, const Int startchan, const Int endchan);
00118
00119 Bool datadescMap(const vi::VisBuffer2& vb, Double& fracbw);
00120 Bool datadescMap(const VisBuffer& vb);
00121 Bool saveData(const Cube<Complex>& grid, const Cube<Bool>&flag, const Vector<Bool>& rowFlag,
00122 const Cube<Float>&wghtSpec, const Matrix<Float>& wght,
00123 const Matrix<Double>& uvw, const Vector<Int>& ant1,
00124 const Vector<Int>& ant2, const Vector<Double>& time);
00125
00126 Bool saveData(const Cube<Complex>& grid, const Cube<Bool>&flag, const Vector<Bool>& rowFlag,
00127 const Cube<Float>&wghtSpec,
00128 const Matrix<Double>& uvw, const Vector<Int>& ant1,
00129 const Vector<Int>& ant2, const Vector<Double>& time, const Int startchan, const Int endchan, const Cube<Float>& imagwghtSpec=Cube<Float>());
00130 void fillSubTables();
00131 void fillFieldTable();
00132 void copySubtable(const String& tabName, const Table& inTab,
00133 const Bool noRows=False);
00134 void fillDDTables();
00135 void setTileCache();
00136 void makeSFConv(Cube<Complex>&convFunc,
00137 Vector<Int>& convSupport, Double& wScale, Int& convSampling,
00138 Int& convSize);
00139 void makeWConv(vi::VisibilityIterator2& iter,Cube<Complex>& convFunc,
00140 Vector<Int>& convSupport,
00141 Double& wScale, Int& convSampling, Int& convSize );
00142 CoordinateSystem csys_p;
00143 Int nx_p, ny_p, nchan_p, npol_p;
00144 Double freqStart_p, freqStep_p;
00145 Vector<Int> chanMap_p, polMap_p;
00146 Vector<Vector<Int> > chanMapRev_p;
00147 MDirection phaseCenter_p;
00148 Vector<Double> deltas_p;
00149 Vector<Int> whichStokes_p;
00150 Bool existOut_p;
00151 String outMSName_p;
00152 CountedPtr<MeasurementSet> outMsPtr_p;
00153 Block<const MeasurementSet *> mss_p;
00154 VisBufferUtil vbutil_p;
00155 Float memFraction_p;
00156 Bool doW_p, doFlag_p;
00157 Matrix<Double> numVis_p;
00158 Matrix<Double> sumWeight_p;
00159
00160 };
00161 }
00162 #endif