CalCache.h

Go to the documentation of this file.
00001 //# CalCache.h: CalTable-specific Data cache for plotms.
00002 //# Copyright (C) 2009
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 #ifndef CALCACHE_H_
00028 #define CALCACHE_H_
00029 
00030 #include <plotms/Data/PlotMSCacheBase.h>
00031 
00032 #include <plotms/PlotMS/PlotMSAveraging.h>
00033 #include <plotms/PlotMS/PlotMSConstants.h>
00034 #include <plotms/PlotMS/PlotMSFlagging.h>
00035 //#include <plotms/Threads/PlotMSCacheThread.qo.h>
00036 
00037 #include <synthesis/CalTables/NewCalTable.h>
00038 #include <synthesis/CalTables/CTIter.h>
00039 #include <casa/aips.h>
00040 #include <casa/Arrays.h>
00041 #include <casa/Containers/Block.h>
00042 
00043 namespace casa {
00044 
00045 //# Forward declarations.
00046 class PlotMSApp;
00047 class PlotMSIndexer;
00048 
00049 class CalCache : public PlotMSCacheBase {
00050     
00051   // Friend class declarations.
00052   friend class PlotMSIndexer;
00053 
00054 public:    
00055   
00056   // Constructor which takes parent PlotMS.
00057   CalCache(PlotMSApp* parent);
00058   
00059   // Destructor
00060   virtual ~CalCache();
00061 
00062   // Identify myself
00063   PlotMSCacheBase::Type cacheType() const { return PlotMSCacheBase::CAL; };
00064 
00065   // Is the underlying table complex?
00066   inline Bool parsAreComplex() { return parsAreComplex_; };
00067 
00068   // Access to channel averaging bounds
00069   Matrix<Int>& chanAveBounds(Int spw) { return chanAveBounds_p(spw); };
00070   
00071   // ...not yet CAL-specific... (or ever?)
00072   // Set up indexing for the plot
00073   //  void setUpIndexer(PMS::Axis iteraxis=PMS::SCAN,
00074   //                Bool globalXRange=False, Bool globalYRange=False);
00075 
00076   // Convert poln index->name and name->index
00077   virtual String polname(Int ipol);
00078 
00079   // given filename, get cal type
00080   void setFilename(String filename); 
00081 
00082 protected:
00083 
00084   // CAL-specific loadIt method
00085   virtual void loadIt(vector<PMS::Axis>& loadAxes,
00086                       vector<PMS::DataColumn>& loadData,
00087                       ThreadCommunication* thread = NULL);
00088 
00089 private:
00090     
00091   // Forbid copy for now
00092   CalCache(const CalCache&);
00093 
00094   // Setup the CalIter
00095   void setUpCalIter(const String& calname,
00096                     PlotMSSelection& selection,
00097                     Bool readonly=True,
00098                     Bool chanselect=True,
00099                     Bool corrselect=True);
00100 
00101   // Count the chunks required in the cache
00102   void countChunks(ROCTIter& ci,ThreadCommunication* thread);  // old
00103 
00104   // Trap attempt to use to much memory (too many points)
00105   //  void trapExcessVolume(map<PMS::Axis,Bool> pendingLoadAxes);
00106 
00107   // Loop over VisIter, filling the cache
00108   void loadCalChunks(ROCTIter& ci,
00109                   const vector<PMS::Axis> loadAxes,
00110                   ThreadCommunication* thread);
00111 
00112   // Loads the specific axis/metadata into the cache using the given VisBuffer.
00113   void loadCalAxis(ROCTIter& cti, Int chunk, PMS::Axis axis, String pol);
00114 
00115   // Check axis and slice param column appropriately
00116   Slice getParSlice(String axis, String polnSel);
00117   // Get axis string for VisCal Slice code
00118   String toVisCalAxis(PMS::Axis axis);
00119 
00120   // Check for divide-by-zero (=inf); set to 1.0 and flag it
00121   void checkRatioArray(Array<Float>& array, Int chunk);
00122 
00123   // Set flags in the CalTable
00124   virtual void flagToDisk(const PlotMSFlagging& flagging,
00125                           Vector<Int>& chunks, 
00126                           Vector<Int>& relids,
00127                           Bool flag,
00128                           PlotMSIndexer* indexer, int index);
00129   
00130 
00131   // A container for channel averaging bounds
00132   Vector<Matrix<Int> > chanAveBounds_p;
00133 
00134   // Provisional flagging helpers
00135   Vector<Int> nVBPerAve_;
00136  
00137   // The polarization basis
00138   String basis_;
00139   // Had to adjust for divide-by-zero in ratio plot (checkRatioArray)
00140   Bool divZero_;
00141 
00142   // VisIterator pointer
00143   ROCTIter* ci_p;
00144   CTIter* wci_p;
00145 
00146   // Is parameter column complex?
00147   Bool parsAreComplex_;
00148 
00149   // Volume meter for volume calculation
00150   //  PMSCacheVolMeter vm_;
00151 
00152     
00153 };
00154 typedef CountedPtr<CalCache> CalCachePtr;
00155 
00156 
00157 }
00158 
00159 #endif /* CALCACHE_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1