casacore
Loading...
Searching...
No Matches
LatticeStatsDataProvider.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: casa-feedback@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#ifndef LATTICES_LATTICESTATSDATAPROVIDER_H
26#define LATTICES_LATTICESTATSDATAPROVIDER_H
27
28#include <casacore/lattices/Lattices/LatticeIterator.h>
29#include <casacore/lattices/LatticeMath/LatticeStatsDataProviderBase.h>
30
31#include <casacore/casa/aips.h>
32
33namespace casacore {
34
35// Data provider which allows stats framework to iterate through an unmasked lattice.
36
37template <class T> class LatticeStatsDataProvider
39
40public:
41
42 // default constructor, must set lattice after construction but before
43 // using the object
45
46 // <src>iteratorLimitBytes</src> is related to the size of the lattice.
47 // If the lattice is greater than this size, then a lattice iterator will
48 // be used to step through the lattice. If less, then all the data in the
49 // values in the lattice are retrieved in a single chunk. The advantage of
50 // the iterator is that less memory is used. The disadvantage is there is
51 // a significant performace cost, so if the lattice is small, it is better to
52 // get all its values in a single chunk and forgo the iterator. This is particularly
53 // true when looping for a large number of iterations and creating a
54 // LatticeStatsDataProvider each loop (in that case, you probably will want
55 // to create a single object before the loop and use setLattice() to update
56 // its lattice).
58 const Lattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
59 );
60
62
63 void operator++();
64
65 // estimated number of steps to iterate through the the lattice
67
68 // Are there any data sets left to provide?
69 Bool atEnd() const;
70
71 // Take any actions necessary to finalize the provider. This will be called when
72 // atEnd() returns True.
73 void finalize();
74
75 // get the count of elements in the current data set. When implementing this method, be
76 // certain to take stride into account; ie for a data set with nominally 100 elements that
77 // is to have a stride of two, this method should return 50.
79
80 // get the current data set
81 const T* getData();
82
83 // Get the associated mask of the current dataset. Only called if hasMask() returns True;
84 const Bool* getMask();
85
86 // returns something reasonable based on the lattice size.
88
89 // Does the current data set have an associated mask?
90 Bool hasMask() const;
91
92 // reset the provider to point to the first data set it manages.
93 void reset();
94
95 // set the lattice. Automatically resets the lattice iterator
96 // <src>iteratorLimitBytes</src> is related to the size of the lattice.
97 // If the lattice is greater than this size, then a lattice iterator will
98 // be used to step through the lattice. If less, then all the data in the
99 // values in the lattice are retrieved in a single chunk. The advantage of
100 // the iterator is that less memory is used. The disadvantage is there is
101 // a significant performace cost, so if the lattice is small, it is better to
102 // get all its values in a single chunk and forgo the iterator. This is particularly
103 // true when looping for a large number of iterations and creating a
104 // LatticeStatsDataProvider each loop (in that case, you probably will want
105 // to create a single object before the loop and use setLattice() to update
106 // its lattice).
108 const Lattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
109 );
110
111 // <group>
112 // see base class documentation.
113 void updateMaxPos(const std::pair<Int64, Int64>& maxpos);
114
115 void updateMinPos(const std::pair<Int64, Int64>& minpos);
116 // </group>
117
118private:
119 std::shared_ptr<RO_LatticeIterator<T>> _iter;
121 const T* _currentPtr;
124
126
127};
128
129}
130
131#ifndef CASACORE_NO_AUTO_TEMPLATES
132#include <casacore/lattices/LatticeMath/LatticeStatsDataProvider.tcc>
133#endif //# CASACORE_NO_AUTO_TEMPLATES
134
135#endif
Abstract base class of data providers which allows stats framework to iterate through a lattice.
Data provider which allows stats framework to iterate through an unmasked lattice.
void reset()
reset the provider to point to the first data set it manages.
Bool hasMask() const
Does the current data set have an associated mask?
void updateMinPos(const std::pair< Int64, Int64 > &minpos)
void operator++()
increment the data provider to the next dataset, mask, range set, and weights.
std::shared_ptr< RO_LatticeIterator< T > > _iter
LatticeStatsDataProvider()
default constructor, must set lattice after construction but before using the object
Bool atEnd() const
Are there any data sets left to provide?
LatticeStatsDataProvider(const Lattice< T > &lattice, uInt iteratorLimitBytes=4096 *4096)
iteratorLimitBytes is related to the size of the lattice.
uInt64 getCount()
get the count of elements in the current data set.
uInt getNMaxThreads() const
returns something reasonable based on the lattice size.
void updateMaxPos(const std::pair< Int64, Int64 > &maxpos)
see base class documentation.
void finalize()
Take any actions necessary to finalize the provider.
const T * getData()
get the current data set
const Bool * getMask()
Get the associated mask of the current dataset.
void setLattice(const Lattice< T > &lattice, uInt iteratorLimitBytes=4096 *4096)
set the lattice.
uInt estimatedSteps() const
estimated number of steps to iterate through the the lattice
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
unsigned long long uInt64
Definition aipsxtype.h:37