Line data Source code
1 : // -*- mode: c++ -*- 2 : //# Copyright (C) 1996,1997,1998,1999,2000,2002,2003,2015 3 : //# Associated Universities, Inc. Washington DC, USA. 4 : //# 5 : //# This library is free software; you can redistribute it and/or modify it 6 : //# under the terms of the GNU Library General Public License as published by 7 : //# the Free Software Foundation; either version 2 of the License, or (at your 8 : //# option) any later version. 9 : //# 10 : //# This library is distributed in the hope that it will be useful, but WITHOUT 11 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 13 : //# License for more details. 14 : //# 15 : //# You should have received a copy of the GNU Library General Public License 16 : //# along with this library; if not, write to the Free Software Foundation, 17 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 18 : //# 19 : //# Correspondence concerning AIPS++ should be addressed as follows: 20 : //# Internet email: aips2-request@nrao.edu. 21 : //# Postal address: AIPS++ Project Office 22 : //# National Radio Astronomy Observatory 23 : //# 520 Edgemont Road 24 : //# Charlottesville, VA 22903-2475 USA 25 : //# 26 : // 27 : // casacore::Data provider weights iterators, based on sigma column 28 : // 29 : #ifndef MSVIS_STATISTICS_VI2_STATS_SIGMAS_ITERATOR_H_ 30 : #define MSVIS_STATISTICS_VI2_STATS_SIGMAS_ITERATOR_H_ 31 : 32 : #include <casacore/casa/aips.h> 33 : #include <msvis/MSVis/VisibilityIterator2.h> 34 : #include <msvis/MSVis/VisBuffer2.h> 35 : #include <iterator> 36 : 37 : namespace casa { 38 : 39 : // Vi2StatsSigmasIterator has the form of a CRTP base class to promote 40 : // efficiency in iterator operations. The weights provided by these iterators 41 : // are converted from sigmas according to 1/(sigma^2) (except for sigma == 0). 42 : // 43 : template<class T> 44 : class Vi2StatsSigmasIterator 45 : : public std::iterator<std::input_iterator_tag,casacore::Float> { 46 : 47 : public: 48 : Vi2StatsSigmasIterator& operator++(); 49 : 50 : Vi2StatsSigmasIterator operator++(int); 51 : 52 : bool operator==(const Vi2StatsSigmasIterator& rhs); 53 : 54 : bool operator!=(const Vi2StatsSigmasIterator& rhs); 55 : 56 : casacore::Float operator*(); 57 : 58 : bool atEnd(); 59 : 60 : protected: 61 0 : Vi2StatsSigmasIterator(vi::VisBuffer2 *vb2) 62 0 : : vb2(vb2) {}; 63 : 64 705720 : Vi2StatsSigmasIterator() {}; 65 : 66 : vi::VisBuffer2 *vb2; 67 : }; 68 : 69 : // Weights iterator over sigma cube. 70 : class Vi2StatsSigmasCubeIterator final 71 : : public Vi2StatsSigmasIterator<Vi2StatsSigmasCubeIterator> { 72 : 73 : public: 74 : Vi2StatsSigmasCubeIterator(vi::VisBuffer2 *vb2); 75 : 76 : Vi2StatsSigmasCubeIterator(); 77 : 78 : Vi2StatsSigmasCubeIterator& operator++(); 79 : 80 : Vi2StatsSigmasCubeIterator operator++(int); 81 : 82 : bool operator==(const Vi2StatsSigmasCubeIterator& rhs); 83 : 84 : bool operator!=(const Vi2StatsSigmasCubeIterator& rhs); 85 : 86 : casacore::Float operator*(); 87 : 88 : bool atEnd(); 89 : 90 : protected: 91 : casacore::uInt correlation; 92 : casacore::uInt nCorrelations; 93 : casacore::uInt channel; 94 : casacore::uInt nChannels; 95 : casacore::rownr_t row; 96 : casacore::rownr_t nRows; 97 : }; 98 : 99 : // Weights iterator over row sigmas. 100 : class Vi2StatsSigmasRowIterator final 101 : : public Vi2StatsSigmasIterator<Vi2StatsSigmasRowIterator> { 102 : 103 : public: 104 : Vi2StatsSigmasRowIterator(vi::VisBuffer2 *vb2); 105 : 106 : Vi2StatsSigmasRowIterator(); 107 : 108 : Vi2StatsSigmasRowIterator& operator++(); 109 : 110 : Vi2StatsSigmasRowIterator operator++(int); 111 : 112 : bool operator==(const Vi2StatsSigmasRowIterator& rhs); 113 : 114 : bool operator!=(const Vi2StatsSigmasRowIterator& rhs); 115 : 116 : casacore::Float operator*(); 117 : 118 : bool atEnd(); 119 : 120 : protected: 121 : casacore::rownr_t row; 122 : casacore::rownr_t nRows; 123 : }; 124 : 125 : } // namespace casa 126 : 127 : #endif // MSVIS_STATISTICS_VI2_STATS_SIGMAS_ITERATOR_H_