MSUVBin.h

Go to the documentation of this file.
00001 /*
00002  * MSUVBin.h: This file contains the interface definition of the MSUVBin class.
00003 //#
00004 //#  CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
00005 
00006  //# Copyright (C) 2014
00007 //# Associated Universities, Inc. Washington DC, USA.
00008 //#
00009 //# This library is free software; you can redistribute it and/or modify it
00010 //# under the terms of the GNU  General Public License as published by
00011 //# the Free Software Foundation; either version 2 of the License, or (at your
00012 //# option) any later version.
00013 //#
00014 //# This library is distributed in the hope that it will be useful, but WITHOUT
00015 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00017 //# License for more details.
00018 //#
00019 //# You should have received a copy of the GNU Library General Public License
00020 //# along with this library; if not, write to the Free Software Foundation,
00021 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00022 //#
00023 
00024 //#        Postal address:
00025 //#                        National Radio Astronomy Observatory
00026 //#                        520 Edgemont Road
00027 //#                        Charlottesville, VA 22903-2475 USA
00028 //#
00029 
00030  *  Created on: Feb 3, 2014
00031  *      Author: kgolap
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 { //# NAMESPACE CASA - BEGIN
00044 
00045 
00046 class MSUVBin {
00047 public:
00048         MSUVBin();
00049         //npol should be only 1, 2 (parallel hands)  or 4
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         //Constructor to bin into an existing gridded ms
00053         MSUVBin (MeasurementSet& ms);
00054         //The following can be called multiple times to setup multiple input MS
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         //void setInputMS(const MeasurementSet& ms);
00061         //void setInputMS(const Block<const MeasurementSet*> mssPtr);
00062         void setOutputMS(const String& msname);
00063         //forceDiskUsage is to avoid using in memory gridding even if there is
00064         Bool fillOutputMS();
00065         virtual ~MSUVBin();
00066         //Helper function for creating MDirection from a string
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>& /*wght*/, 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         // returns a false if either no channel map or pol map onto grid
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 }; // end class MSUVBin
00161 } //# NAMESPACE CASA - END
00162 #endif /* MSTRANSFORM_MSUVBIN_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1