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>
39 public:
40 // default constructor, must set lattice after construction but before
41 // using the object
43
44 // <src>iteratorLimitBytes</src> is related to the size of the lattice.
45 // If the lattice is greater than this size, then a lattice iterator will
46 // be used to step through the lattice. If less, then all the data in the
47 // values in the lattice are retrieved in a single chunk. The advantage of
48 // the iterator is that less memory is used. The disadvantage is there is
49 // a significant performace cost, so if the lattice is small, it is better to
50 // get all its values in a single chunk and forgo the iterator. This is particularly
51 // true when looping for a large number of iterations and creating a
52 // LatticeStatsDataProvider each loop (in that case, you probably will want
53 // to create a single object before the loop and use setLattice() to update
54 // its lattice).
55 LatticeStatsDataProvider(const Lattice<T>& lattice, uInt iteratorLimitBytes = 4096 * 4096);
56
58
59 void operator++();
60
61 // estimated number of steps to iterate through the the lattice
63
64 // Are there any data sets left to provide?
65 Bool atEnd() const;
66
67 // Take any actions necessary to finalize the provider. This will be called when
68 // atEnd() returns True.
69 void finalize();
70
71 // get the count of elements in the current data set. When implementing this method, be
72 // certain to take stride into account; ie for a data set with nominally 100 elements that
73 // is to have a stride of two, this method should return 50.
75
76 // get the current data set
77 const T* getData();
78
79 // Get the associated mask of the current dataset. Only called if hasMask() returns True;
80 const Bool* getMask();
81
82 // returns something reasonable based on the lattice size.
84
85 // Does the current data set have an associated mask?
86 Bool hasMask() const;
87
88 // reset the provider to point to the first data set it manages.
89 void reset();
90
91 // set the lattice. Automatically resets the lattice iterator
92 // <src>iteratorLimitBytes</src> is related to the size of the lattice.
93 // If the lattice is greater than this size, then a lattice iterator will
94 // be used to step through the lattice. If less, then all the data in the
95 // values in the lattice are retrieved in a single chunk. The advantage of
96 // the iterator is that less memory is used. The disadvantage is there is
97 // a significant performace cost, so if the lattice is small, it is better to
98 // get all its values in a single chunk and forgo the iterator. This is particularly
99 // true when looping for a large number of iterations and creating a
100 // LatticeStatsDataProvider each loop (in that case, you probably will want
101 // to create a single object before the loop and use setLattice() to update
102 // its lattice).
103 void setLattice(const Lattice<T>& lattice, uInt iteratorLimitBytes = 4096 * 4096);
104
105 // <group>
106 // see base class documentation.
107 void updateMaxPos(const std::pair<Int64, Int64>& maxpos);
108
109 void updateMinPos(const std::pair<Int64, Int64>& minpos);
110 // </group>
111
112 private:
113 std::shared_ptr<RO_LatticeIterator<T>> _iter;
115 const T* _currentPtr;
118
120};
121
122} // namespace casacore
123
124#ifndef CASACORE_NO_AUTO_TEMPLATES
125#include <casacore/lattices/LatticeMath/LatticeStatsDataProvider.tcc>
126#endif // # CASACORE_NO_AUTO_TEMPLATES
127
128#endif
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
For temporary backward namespace compatibility, use casa as alias for casacore.
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