casa
$Rev:20696$
|
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 <synthesis/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); 00061 //------------------------------------------------------------------------- 00062 void makePersistent(const char *dir,const char *qualifier=""); 00063 //------------------------------------------------------------------------- 00064 void initMaps(const VisBuffer& vb, const Matrix<Double>& freqSelection, const Double& imRefFreq); 00065 //------------------------------------------------------------------------- 00066 Bool null() {return (storage_p.size() == 0);}; 00067 //------------------------------------------------------------------------- 00068 Double memUsage(); 00069 //------------------------------------------------------------------------- 00070 void set(const CFStore2& other) 00071 { 00072 pa_p.assign(other.pa_p); 00073 ant1_p.assign(other.ant1_p); 00074 ant2_p.assign(other.ant2_p); 00075 } 00076 //------------------------------------------------------------------------- 00077 void setCFBuffer(CFBuffer *dataPtr, Quantity pa, 00078 const Int& ant1, const Int& ant2); 00079 //------------------------------------------------------------------------- 00080 CountedPtr<CFBuffer>& getCFBuffer(const Quantity& pa, 00081 const Quantity& paTol, 00082 const Int& ant1, const Int& ant2); 00083 //------------------------------------------------------------------------- 00084 // Get CFBuffer by directly indexing in the list of CFBuffers 00085 CountedPtr<CFBuffer>& getCFBuffer(const Int& paNdx, const Int& antNdx); 00086 void getParams(Quantity& pa, 00087 Int& ant1, Int& ant2, 00088 const Int& paNdx, const Int& antNdx); 00089 //------------------------------------------------------------------------- 00090 // 00091 // Generate a map for the given frequency and Mueller element list 00092 // to the index in the internal list of CFs. This can be used in 00093 // tight loops to get get direct access to the required CF. 00094 // 00095 /* 00096 void makeVBRow2CFMap(VBRow2CFMapType& vbRow2CFMap, 00097 const VisBuffer& vb, 00098 const Quantity& paTol, 00099 const Vector<Int>& dataChan2ImChanMap, 00100 const Vector<Int>& dataPol2ImPolMap); 00101 */ 00102 //------------------------------------------------------------------------- 00103 Vector<Int> resize(const Quantity& pa, const Quantity& paTol, 00104 const Int& ant1,const Int& ant2, Bool retainValues=True); 00105 // void rememberATerm(CountedPtr<ATerm>& aTerm) {theATermUsed_p = aTerm;} 00106 00107 // Int mapAntIDToAntType(const Int& ant) {return theATermUsed_p->mapAntIDToAntType(ant);}; 00108 Matrix<CountedPtr<CFBuffer> >& getStorage() {return storage_p;} 00109 Vector<Int>& getAnt1List() {return ant1_p;}; 00110 Vector<Int>& getAnt2List() {return ant2_p;}; 00111 Vector<Quantity> getPAList() {return pa_p;}; 00112 00113 protected: 00114 00115 00116 00117 Matrix<CountedPtr<CFBuffer > > storage_p; 00118 Vector<Int> ant1_p, ant2_p; 00119 Vector<Quantity> pa_p; 00120 Int mosPointingPos_p; 00121 00122 virtual void getIndex(const Quantity& pa, 00123 const Quantity& paTol, 00124 const Int& ant1, const Int& ant2, 00125 Int& paNdx, Int& antNdx) 00126 { 00127 paNdx = paHashFunction(pa,paTol); 00128 antNdx = antHashFunction(ant1,ant2); 00129 } 00130 00131 // virtual Int wHashFunction(const Double& wValue) 00132 // { 00133 // Int ndx=-1; 00134 // for(uInt i=0;i<wValue_p.nelements(); i++) 00135 // if (wValue_p[i] == wValue) 00136 // {ndx=i;break;} 00137 // return ndx; 00138 // } 00139 virtual Int antHashFunction(const Int& ant1, const Int& ant2) 00140 { 00141 Int ndx=-1; 00142 for (uInt i=0;i<ant1_p.nelements(); i++) 00143 if ((ant1_p[i]==ant1) && (ant2_p[i]==ant2)) 00144 {ndx=i;break;} 00145 return ndx; 00146 }; 00147 00148 virtual Int paHashFunction(const Quantity& pa,const Quantity& paTol) 00149 { 00150 // for (uInt i=0; i<pa_p.nelements(); i++) 00151 // if ( pa_p[i] == pa) 00152 // {ndx=i;break;} 00153 return nearestPA(pa, paTol); 00154 } 00155 00156 virtual Int nearestPA(const Quantity& pa, const Quantity& paTol); 00157 }; 00158 } //# NAMESPACE CASA - END 00159 00160 #endif