#include <casa/Arrays/ArrayMath.h>
#include <casa/Arrays/Array.h>
#include <casa/Arrays/Matrix.h>
#include <casa/Arrays/Cube.h>
#include <casa/Arrays/Vector.h>
#include <casa/OS/HostInfo.h>
#include <casa/System/ProgressMeter.h>
#include <casa/Quanta/QuantumHolder.h>
#include <casa/Utilities/CompositeNumber.h>
#include <measures/Measures/MeasTable.h>
#include <ms/MeasurementSets/MSPolColumns.h>
#include <ms/MeasurementSets/MSPolarization.h>
#include <mstransform/MSTransform/MSUVBin.h>
#include <mstransform/MSTransform/MSTransformDataHandler.h>
#include <coordinates/Coordinates/CoordinateSystem.h>
#include <coordinates/Coordinates/DirectionCoordinate.h>
#include <coordinates/Coordinates/SpectralCoordinate.h>
#include <coordinates/Coordinates/StokesCoordinate.h>
#include <images/Images/PagedImage.h>
#include <images/Images/TempImage.h>
#include <msvis/MSVis/MSUtil.h>
#include <msvis/MSVis/VisBuffer.h>
#include <msvis/MSVis/VisBuffer2Adapter.h>
#include <imageanalysis/Utilities/SpectralImageUtil.h>
#include <msvis/MSVis/VisibilityIterator2.h>
#include <scimath/Mathematics/FFTPack.h>
#include <scimath/Mathematics/ConvolveGridder.h>
#include <wcslib/wcsconfig.h>
#define SINCOS(a,s,c) sincos(a,&s,&c)
typedef unsigned long long ooLong;
using namespace casacore;
MSUVBin::MSUVBin():nx_p(0), ny_p(0), nchan_p(0), npol_p(0),existOut_p(false),numVis_p(), sumWeight_p(){
MSUVBin::MSUVBin(const MDirection& phaseCenter,
const Int nx, const Int ny, const Int nchan, const Int npol, Quantity cellx, Quantity celly, Quantity freqStart, Quantity freqStep, Float memFraction, Bool dow, Bool doflag):
phaseCenter_p=phaseCenter;