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