casacore
LatticeStatsDataProviderBase.h
Go to the documentation of this file.
1 //# Copyright (C) 2000,2001
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 //# $Id: Array.h 21545 2015-01-22 19:36:35Z gervandiepen $
26 
27 #ifndef LATTICES_LATTICESTATSDATAPROVIDERBASE_H
28 #define LATTICES_LATTICESTATSDATAPROVIDERBASE_H
29 
30 #include <casacore/scimath/StatsFramework/StatsDataProvider.h>
31 
32 #include <casacore/scimath/Mathematics/NumericTraits.h>
33 #include <casacore/lattices/Lattices/LatticeIterator.h>
34 #include <casacore/lattices/LatticeMath/LattStatsProgress.h>
35 
36 #include <casacore/casa/aips.h>
37 
38 namespace casacore {
39 
40 class LatticeProgress;
41 
42 // Abstract base class of data providers which allows stats framework to iterate through a lattice.
43 
44 template <class T> class LatticeStatsDataProviderBase
45  : public StatsDataProvider<typename NumericTraits<T>::PrecisionType, const T*, const Bool*> {
46 
47 public:
48 
50 
51  // estimated number of steps to iterate through the the lattice
52  virtual uInt estimatedSteps() const = 0;
53 
54  virtual void finalize();
55 
56  // Get the stride for the current mask (only called if hasMask() returns True).
58 
59  // Get the associated range(s) of the current dataset. Only called if hasRanges() returns True;
60  std::vector<std::pair<typename NumericTraits<T>::PrecisionType, typename NumericTraits<T>::PrecisionType> > getRanges();
61 
62  // Get the stride for the current data set.
63  uInt getStride();
64 
65  // Returns NULL; lattices do not have associated weights.
66  const T* getWeights();
67 
68  // Does the current data set have associated range(s)?
69  Bool hasRanges() const;
70 
71  // returns False; lattices do not have associated weights.
72  Bool hasWeights() const;
73 
74  // If the associated data set has ranges, are these include (return True) or
75  // exclude (return False) ranges?
76  Bool isInclude() const;
77 
78  // get the positions of the min and max
79  void minMaxPos(IPosition& minpos, IPosition& maxpos) const;
80 
81  virtual void reset();
82 
84 
85  // set the data ranges
86  void setRanges(
87  const std::vector<std::pair<typename NumericTraits<T>::PrecisionType, typename NumericTraits<T>::PrecisionType> >& ranges,
89  );
90 
91 protected:
93 
94  void _updateMaxPos(const IPosition& maxPos) { _maxPos = maxPos; }
95 
96  void _updateMinPos(const IPosition& minPos) { _minPos = minPos; }
97 
98  void _updateProgress();
99 
100 private:
102  std::vector<std::pair<typename NumericTraits<T>::PrecisionType, typename NumericTraits<T>::PrecisionType> > _ranges;
105 };
106 
107 }
108 
109 #ifndef CASACORE_NO_AUTO_TEMPLATES
110 #include <casacore/lattices/LatticeMath/LatticeStatsDataProviderBase.tcc>
111 #endif //# CASACORE_NO_AUTO_TEMPLATES
112 
113 #endif
casacore::IPosition
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
casacore::LatticeStatsDataProviderBase::hasWeights
Bool hasWeights() const
returns False; lattices do not have associated weights.
casacore::LatticeStatsDataProviderBase::minMaxPos
void minMaxPos(IPosition &minpos, IPosition &maxpos) const
get the positions of the min and max
casacore::LatticeStatsDataProviderBase::getMaskStride
uInt getMaskStride()
Get the stride for the current mask (only called if hasMask() returns True).
casacore::LatticeStatsDataProviderBase::~LatticeStatsDataProviderBase
virtual ~LatticeStatsDataProviderBase()
casacore::LatticeStatsDataProviderBase::finalize
virtual void finalize()
Take any actions necessary to finalize the provider.
casacore::CountedPtr
Referenced counted pointer for constant data.
Definition: CountedPtr.h:80
casacore::LatticeStatsDataProviderBase::_minPos
IPosition _minPos
Definition: LatticeStatsDataProviderBase.h:104
casacore::LatticeStatsDataProviderBase::_ranges
std::vector< std::pair< typename NumericTraits< T >::PrecisionType, typename NumericTraits< T >::PrecisionType > > _ranges
Definition: LatticeStatsDataProviderBase.h:102
casacore::LatticeStatsDataProviderBase::LatticeStatsDataProviderBase
LatticeStatsDataProviderBase()
casacore::LatticeStatsDataProviderBase::reset
virtual void reset()
reset the provider to point to the beginning of the first data set it manages.
casacore::NumericTraits::PrecisionType
Char PrecisionType
Higher precision type (Float->Double)
Definition: NumericTraits.h:232
casacore::LatticeStatsDataProviderBase::estimatedSteps
virtual uInt estimatedSteps() const =0
estimated number of steps to iterate through the the lattice
casacore::LatticeStatsDataProviderBase::_updateProgress
void _updateProgress()
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::LatticeStatsDataProviderBase::setProgressMeter
void setProgressMeter(CountedPtr< LattStatsProgress > pm)
casacore::LatticeStatsDataProviderBase::_updateMaxPos
void _updateMaxPos(const IPosition &maxPos)
Definition: LatticeStatsDataProviderBase.h:94
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::LatticeStatsDataProviderBase
Abstract base class of data providers which allows stats framework to iterate through a lattice.
Definition: LatticeStatsDataProviderBase.h:44
casacore::LatticeStatsDataProviderBase::getStride
uInt getStride()
Get the stride for the current data set.
casacore::LatticeStatsDataProviderBase::isInclude
Bool isInclude() const
If the associated data set has ranges, are these include (return True) or exclude (return False) rang...
casacore::LatticeStatsDataProviderBase::hasRanges
Bool hasRanges() const
Does the current data set have associated range(s)?
casacore::LatticeStatsDataProviderBase::getWeights
const T * getWeights()
Returns NULL; lattices do not have associated weights.
casacore::LatticeStatsDataProviderBase::getRanges
std::vector< std::pair< typename NumericTraits< T >::PrecisionType, typename NumericTraits< T >::PrecisionType > > getRanges()
Get the associated range(s) of the current dataset.
casacore::LatticeStatsDataProviderBase::_updateMinPos
void _updateMinPos(const IPosition &minPos)
Definition: LatticeStatsDataProviderBase.h:96
casacore::LatticeStatsDataProviderBase::_isInclude
Bool _isInclude
Definition: LatticeStatsDataProviderBase.h:101
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::LatticeStatsDataProviderBase::_maxPos
IPosition _maxPos
Definition: LatticeStatsDataProviderBase.h:104
casacore::LatticeStatsDataProviderBase::_progressMeter
CountedPtr< LattStatsProgress > _progressMeter
Definition: LatticeStatsDataProviderBase.h:103
casacore::LatticeStatsDataProviderBase::_hasRanges
Bool _hasRanges
Definition: LatticeStatsDataProviderBase.h:101
casacore::LatticeStatsDataProviderBase::setRanges
void setRanges(const std::vector< std::pair< typename NumericTraits< T >::PrecisionType, typename NumericTraits< T >::PrecisionType > > &ranges, Bool isInclude)
set the data ranges
casacore::StatsDataProvider
Abstract base class which defines interface for providing "datasets" to the statistics framework in c...
Definition: StatsDataProvider.h:43