LatticeStatsDataProviderBase.h

Go to the documentation of this file.
00001 //# Copyright (C) 2000,2001
00002 //# Associated Universities, Inc. Washington DC, USA.
00003 //#
00004 //# This library is free software; you can redistribute it and/or modify it
00005 //# under the terms of the GNU Library General Public License as published by
00006 //# the Free Software Foundation; either version 2 of the License, or (at your
00007 //# option) any later version.
00008 //#
00009 //# This library is distributed in the hope that it will be useful, but WITHOUT
00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012 //# License for more details.
00013 //#
00014 //# You should have received a copy of the GNU Library General Public License
00015 //# along with this library; if not, write to the Free Software Foundation,
00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00017 //#
00018 //# Correspondence concerning AIPS++ should be addressed as follows:
00019 //#        Internet email: aips2-request@nrao.edu.
00020 //#        Postal address: AIPS++ Project Office
00021 //#                        National Radio Astronomy Observatory
00022 //#                        520 Edgemont Road
00023 //#                        Charlottesville, VA 22903-2475 USA
00024 //#
00025 //# $Id: Array.h 21545 2015-01-22 19:36:35Z gervandiepen $
00026 
00027 #ifndef LATTICES_LATTICESTATSDATAPROVIDERBASE_H
00028 #define LATTICES_LATTICESTATSDATAPROVIDERBASE_H
00029 
00030 #include <casacore/scimath/Mathematics/StatsDataProvider.h>
00031 
00032 #include <casacore/scimath/Mathematics/NumericTraits.h>
00033 #include <casacore/lattices/Lattices/LatticeIterator.h>
00034 #include <casacore/lattices/LatticeMath/LattStatsProgress.h>
00035 
00036 #include <casacore/casa/aips.h>
00037 
00038 namespace casacore {
00039 
00040 class LatticeProgress;
00041 
00042 // Abstract base class of data providers which allows stats framework to iterate through a lattice.
00043 
00044 template <class T> class LatticeStatsDataProviderBase
00045         : public StatsDataProvider<typename NumericTraits<T>::PrecisionType, const T*, const Bool*> {
00046 
00047 public:
00048 
00049         //typedef typename NumericTraits<T>::PrecisionType AccumType;
00050 
00051         virtual ~LatticeStatsDataProviderBase();
00052 
00053         // estimated number of steps to iterate through the the lattice
00054         virtual uInt estimatedSteps() const = 0;
00055 
00056         virtual void finalize();
00057 
00058         // Get the stride for the current mask (only called if hasMask() returns True).
00059         uInt getMaskStride();
00060 
00061         // Get the associated range(s) of the current dataset. Only called if hasRanges() returns True;
00062         std::vector<std::pair<typename NumericTraits<T>::PrecisionType, typename NumericTraits<T>::PrecisionType> > getRanges();
00063 
00064         // Get the stride for the current data set.
00065         uInt getStride();
00066 
00067         // Returns NULL; lattices do not have associated weights.
00068         const T* getWeights();
00069 
00070         // Does the current data set have associated range(s)?
00071         Bool hasRanges() const;
00072 
00073         // returns False; lattices do not have associated weights.
00074         Bool hasWeights() const;
00075 
00076         // If the associated data set has ranges, are these include (return True) or
00077         // exclude (return False) ranges?
00078         Bool isInclude() const;
00079 
00080         // get the positions of the min and max
00081         void minMaxPos(IPosition& minpos, IPosition& maxpos) const;
00082 
00083         virtual void reset();
00084 
00085         void setProgressMeter(CountedPtr<LattStatsProgress> pm);
00086 
00087         // set the data ranges
00088         void setRanges(
00089                 const std::vector<std::pair<typename NumericTraits<T>::PrecisionType, typename NumericTraits<T>::PrecisionType> >& ranges,
00090                 Bool isInclude
00091         );
00092 
00093 protected:
00094         LatticeStatsDataProviderBase();
00095 
00096         //virtual uInt _nsteps() const = 0;
00097 
00098         void _updateMaxPos(const IPosition& maxPos) { _maxPos = maxPos; }
00099 
00100         void _updateMinPos(const IPosition& minPos) { _minPos = minPos; }
00101 
00102         void _updateProgress();
00103 
00104 private:
00105         Bool _hasRanges, _isInclude;
00106         std::vector<std::pair<typename NumericTraits<T>::PrecisionType, typename NumericTraits<T>::PrecisionType> > _ranges;
00107         CountedPtr<LattStatsProgress> _progressMeter;
00108         IPosition _minPos, _maxPos;
00109 };
00110 
00111 }
00112 
00113 #ifndef CASACORE_NO_AUTO_TEMPLATES
00114 #include <casacore/lattices/LatticeMath/LatticeStatsDataProviderBase.tcc>
00115 #endif //# CASACORE_NO_AUTO_TEMPLATES
00116 
00117 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1