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