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_CFSTORE2_H
00029 #define SYNTHESIS_CFSTORE2_H
00030 #include <synthesis/TransformMachines/CFDefs.h>
00031 #include <synthesis/TransformMachines/CFBuffer.h>
00032 #include <synthesis/TransformMachines/CFCell.h>
00033 #include <synthesis/TransformMachines/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/VisBuffer.h>
00043 namespace casa { //# NAMESPACE CASA - BEGIN
00044   using namespace CFDefs;
00045   typedef Cube<CountedPtr<CFCell > > VBRow2CFMapType;
00046   typedef Vector<CountedPtr<CFBuffer > > VBRow2CFBMapType;
00047   class CFStore2
00048   {
00049   public:
00050     CFStore2():storage_p(), pa_p(), mosPointingPos_p(0) {};
00051 
00052     // CFStore2(CFBuffer<Complex> *dataPtr, Quantity PA, Int mosPointing):
00053     //   storage_p(), pa_p(PA), mosPointingPos_p(mosPointing)
00054     // {storage_p = new CFBuffer<Complex>(*dataPtr);};
00055 
00056     virtual ~CFStore2() {};
00057 
00058     CFStore2& operator=(const CFStore2& other);
00059     //-------------------------------------------------------------------------
00060     void show(const char *Mesg=NULL,ostream &os=cerr, const Bool verbose=False);
00061     //-------------------------------------------------------------------------
00062     // This version saves the entire CFStore
00063     void makePersistent(const char *dir,const char *name="", const char *qualifier="");
00064     // This version saves only those pixels of CFStore that correspond
00065     // to [PA,(Ant1,Ant2)] co-ordiantes ([PA, BaselineType]
00066     // co-ordinate).
00067     void makePersistent(const char *dir,
00068                         const char *cfName,
00069                         const char *qualifier,
00070                         const Quantity &pa, const Quantity& dPA,
00071                         const Int& ant1, const Int& ant2);
00072     //-------------------------------------------------------------------------
00073     void primeTheCFB();
00074     //-------------------------------------------------------------------------
00075     void initMaps(const VisBuffer& vb, const Matrix<Double>& freqSelection, 
00076                   const Double& imRefFreq);
00077     //-------------------------------------------------------------------------
00078     void initPolMaps(PolMapType& polMap, PolMapType& conjPolMap);
00079     //-------------------------------------------------------------------------
00080     Bool null() {return (storage_p.size() == 0);};
00081     //-------------------------------------------------------------------------
00082     Double memUsage();
00083     //-------------------------------------------------------------------------
00084     void set(const CFStore2& other)
00085     {
00086       pa_p.assign(other.pa_p);
00087       ant1_p.assign(other.ant1_p);
00088       ant2_p.assign(other.ant2_p);
00089     }
00090     //-------------------------------------------------------------------------
00091     void setCFBuffer(CFBuffer *dataPtr, Quantity pa, 
00092                      const Int& ant1, const Int& ant2);
00093     //-------------------------------------------------------------------------
00094     CountedPtr<CFBuffer>& getCFBuffer(const Quantity& pa, 
00095                                       const Quantity& paTol, 
00096                                       const Int& ant1, const Int& ant2);
00097     //-------------------------------------------------------------------------
00098     // Get CFBuffer by directly indexing in the list of CFBuffers
00099     CountedPtr<CFBuffer>& getCFBuffer(const Int& paNdx, const Int& antNdx);
00100     CFBuffer& operator()(const Int& paNdx, const Int& antNdx) {return *storage_p(paNdx, antNdx);}
00101     void getParams(Quantity& pa, 
00102                    Int& ant1, Int& ant2, 
00103                    const Int& paNdx, const Int& antNdx);
00104     //-------------------------------------------------------------------------
00105     //
00106     // Generate a map for the given frequency and Mueller element list
00107     // to the index in the internal list of CFs.  This can be used in
00108     // tight loops to get get direct access to the required CF.
00109     //
00110     /*
00111     void makeVBRow2CFMap(VBRow2CFMapType& vbRow2CFMap,
00112                          const VisBuffer& vb, 
00113                          const Quantity& paTol,
00114                          const Vector<Int>& dataChan2ImChanMap,
00115                          const Vector<Int>& dataPol2ImPolMap);
00116     */
00117     //-------------------------------------------------------------------------
00118     Vector<Int> resize(const Quantity& pa, const Quantity& paTol, 
00119                        const Int& ant1,const Int& ant2, Bool retainValues=True);
00120     // void rememberATerm(CountedPtr<ATerm>& aTerm) {theATermUsed_p = aTerm;}
00121 
00122     // Int mapAntIDToAntType(const Int& ant) {return theATermUsed_p->mapAntIDToAntType(ant);};
00123     Matrix<CountedPtr<CFBuffer> >& getStorage() {return storage_p;}
00124     Vector<Int>& getAnt1List() {return ant1_p;};
00125     Vector<Int>& getAnt2List() {return ant2_p;};
00126     Vector<Quantity> getPAList() {return pa_p;};
00127     IPosition getShape() {return storage_p.shape();}
00128 
00129 
00130   protected:
00131 
00132     Matrix<CountedPtr<CFBuffer > > storage_p;
00133     Vector<Int> ant1_p, ant2_p;
00134     Vector<Quantity> pa_p;
00135     Int mosPointingPos_p;
00136 
00137     virtual void getIndex(const Quantity& pa, 
00138                           const Quantity& paTol, 
00139                           const Int& ant1, const Int& ant2,
00140                           Int& paNdx, Int& antNdx)
00141     {
00142       paNdx  = paHashFunction(pa,paTol);
00143       antNdx = antHashFunction(ant1,ant2);
00144     }
00145 
00146     // virtual Int wHashFunction(const Double& wValue)
00147     // {
00148     //   Int ndx=-1;
00149     //   for(uInt i=0;i<wValue_p.nelements(); i++)
00150     //  if (wValue_p[i] == wValue)
00151     //    {ndx=i;break;}
00152     //   return ndx;
00153     // }
00154     virtual Int antHashFunction(const Int& ant1, const Int& ant2)
00155     {
00156       Int ndx=-1;
00157       for (uInt i=0;i<ant1_p.nelements(); i++)
00158         if ((ant1_p[i]==ant1) && (ant2_p[i]==ant2))
00159           {ndx=i;break;}
00160       return ndx;
00161     };
00162 
00163     virtual Int paHashFunction(const Quantity& pa,const Quantity& paTol)
00164     {
00165       // for (uInt i=0; i<pa_p.nelements(); i++)
00166       //        if ( pa_p[i] == pa)
00167       //          {ndx=i;break;}
00168       return nearestPA(pa, paTol);
00169     }
00170 
00171     virtual Int nearestPA(const Quantity& pa, const Quantity& paTol);
00172   };
00173 } //# NAMESPACE CASA - END
00174 
00175 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1