CFStore2.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //# CFStore2.h: Definition of the CFStore2 class
00003 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
00004 //# Associated Universities, Inc. Washington DC, USA.
00005 //#
00006 //# This library is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU Library General Public License as published by
00008 //# the Free Software Foundation; either version 2 of the License, or (at your
00009 //# option) any later version.
00010 //#
00011 //# This library is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 //# License for more details.
00015 //#
00016 //# You should have received a copy of the GNU Library General Public License
00017 //# along with this library; if not, write to the Free Software Foundation,
00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 //#
00027 //# $Id$
00028 #ifndef SYNTHESIS_TRANSFORM2_CFSTORE2_H
00029 #define SYNTHESIS_TRANSFORM2_CFSTORE2_H
00030 #include <synthesis/TransformMachines2/CFDefs.h>
00031 #include <synthesis/TransformMachines2/CFBuffer.h>
00032 #include <synthesis/TransformMachines/CFCell.h>
00033 #include <synthesis/TransformMachines2/VBStore.h>
00034 #include <synthesis/TransformMachines/SynthesisError.h>
00035 #include <coordinates/Coordinates/CoordinateSystem.h>
00036 #include <casa/Logging/LogIO.h>
00037 #include <casa/Logging/LogSink.h>
00038 #include <casa/Logging/LogOrigin.h>
00039 #include <casa/Containers/OrderedMap.h>
00040 #include <casa/Utilities/CountedPtr.h>
00041 #include <images/Images/ImageInterface.h>
00042 #include <msvis/MSVis/VisBuffer2.h>
00043 namespace casa { //# NAMESPACE CASA - BEGIN
00044   using namespace vi;
00045   namespace refim{
00046   using namespace CFDefs;
00047   typedef Cube<CountedPtr<CFCell > > VBRow2CFMapType;
00048   typedef Vector<CountedPtr<CFBuffer > > VBRow2CFBMapType;
00049   class CFStore2
00050   {
00051   public:
00052     CFStore2():storage_p(), pa_p(), mosPointingPos_p(0) {};
00053 
00054     // CFStore2(CFBuffer<Complex> *dataPtr, Quantity PA, Int mosPointing):
00055     //   storage_p(), pa_p(PA), mosPointingPos_p(mosPointing)
00056     // {storage_p = new CFBuffer<Complex>(*dataPtr);};
00057 
00058     virtual ~CFStore2() {};
00059 
00060     CFStore2& operator=(const CFStore2& other);
00061     //-------------------------------------------------------------------------
00062     void show(const char *Mesg=NULL,ostream &os=cerr, const Bool verbose=False);
00063     //-------------------------------------------------------------------------
00064     void makePersistent(const char *dir,const char *name="", const char *qualifier="");
00065     //-------------------------------------------------------------------------
00066     // This version saves only those pixels of CFStore that correspond
00067     // to [PA,(Ant1,Ant2)] co-ordiantes ([PA, BaselineType]
00068     // co-ordinate).
00069     void makePersistent(const char *dir,
00070                         const char *cfName,
00071                         const char *qualifier,
00072                         const Quantity &pa, const Quantity& dPA,
00073                         const Int& ant1, const Int& ant2);
00074     //-------------------------------------------------------------------------
00075     void primeTheCFB();
00076     //-------------------------------------------------------------------------
00077     void initMaps(const VisBuffer2& vb, const Matrix<Double>& freqSelection, 
00078                   const Double& imRefFreq);
00079     //-------------------------------------------------------------------------
00080     void initPolMaps(PolMapType& polMap, PolMapType& conjPolMap);
00081     //-------------------------------------------------------------------------
00082     Bool null() {return (storage_p.size() == 0);};
00083     //-------------------------------------------------------------------------
00084     Double memUsage();
00085     //-------------------------------------------------------------------------
00086     void set(const CFStore2& other)
00087     {
00088       pa_p.assign(other.pa_p);
00089       ant1_p.assign(other.ant1_p);
00090       ant2_p.assign(other.ant2_p);
00091     }
00092     //-------------------------------------------------------------------------
00093     void setCFBuffer(CFBuffer *dataPtr, Quantity pa, 
00094                      const Int& ant1, const Int& ant2);
00095     //-------------------------------------------------------------------------
00096     CountedPtr<CFBuffer>& getCFBuffer(const Quantity& pa, 
00097                                       const Quantity& paTol, 
00098                                       const Int& ant1, const Int& ant2);
00099     //-------------------------------------------------------------------------
00100     // Get CFBuffer by directly indexing in the list of CFBuffers
00101     CountedPtr<CFBuffer>& getCFBuffer(const Int& paNdx, const Int& antNdx);
00102     CFBuffer& operator()(const Int& paNdx, const Int& antNdx) {return *storage_p(paNdx, antNdx);}
00103     void getParams(Quantity& pa, 
00104                    Int& ant1, Int& ant2, 
00105                    const Int& paNdx, const Int& antNdx);
00106     //-------------------------------------------------------------------------
00107     //
00108     // Generate a map for the given frequency and Mueller element list
00109     // to the index in the internal list of CFs.  This can be used in
00110     // tight loops to get get direct access to the required CF.
00111     //
00112     /*
00113     void makeVBRow2CFMap(VBRow2CFMapType& vbRow2CFMap,
00114                          const VisBuffer2& vb, 
00115                          const Quantity& paTol,
00116                          const Vector<Int>& dataChan2ImChanMap,
00117                          const Vector<Int>& dataPol2ImPolMap);
00118     */
00119     //-------------------------------------------------------------------------
00120     Vector<Int> resize(const Quantity& pa, const Quantity& paTol, 
00121                        const Int& ant1,const Int& ant2, Bool retainValues=True);
00122     // void rememberATerm(CountedPtr<ATerm>& aTerm) {theATermUsed_p = aTerm;}
00123 
00124     // Int mapAntIDToAntType(const Int& ant) {return theATermUsed_p->mapAntIDToAntType(ant);};
00125     Matrix<CountedPtr<CFBuffer> >& getStorage() {return storage_p;}
00126     Vector<Int>& getAnt1List() {return ant1_p;};
00127     Vector<Int>& getAnt2List() {return ant2_p;};
00128     Vector<Quantity> getPAList() {return pa_p;};
00129     IPosition getShape() {return storage_p.shape();}
00130 
00131 
00132   protected:
00133 
00134     Matrix<CountedPtr<CFBuffer > > storage_p;
00135     Vector<Int> ant1_p, ant2_p;
00136     Vector<Quantity> pa_p;
00137     Int mosPointingPos_p;
00138 
00139     virtual void getIndex(const Quantity& pa, 
00140                           const Quantity& paTol, 
00141                           const Int& ant1, const Int& ant2,
00142                           Int& paNdx, Int& antNdx)
00143     {
00144       paNdx  = paHashFunction(pa,paTol);
00145       antNdx = antHashFunction(ant1,ant2);
00146     }
00147 
00148     // virtual Int wHashFunction(const Double& wValue)
00149     // {
00150     //   Int ndx=-1;
00151     //   for(uInt i=0;i<wValue_p.nelements(); i++)
00152     //  if (wValue_p[i] == wValue)
00153     //    {ndx=i;break;}
00154     //   return ndx;
00155     // }
00156     virtual Int antHashFunction(const Int& ant1, const Int& ant2)
00157     {
00158       Int ndx=-1;
00159       for (uInt i=0;i<ant1_p.nelements(); i++)
00160         if ((ant1_p[i]==ant1) && (ant2_p[i]==ant2))
00161           {ndx=i;break;}
00162       return ndx;
00163     };
00164 
00165     virtual Int paHashFunction(const Quantity& pa,const Quantity& paTol)
00166     {
00167       // for (uInt i=0; i<pa_p.nelements(); i++)
00168       //        if ( pa_p[i] == pa)
00169       //          {ndx=i;break;}
00170       return nearestPA(pa, paTol);
00171     }
00172 
00173     virtual Int nearestPA(const Quantity& pa, const Quantity& paTol);
00174   };
00175 } //# NAMESPACE CASA - END
00176 }
00177 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1