00001 // -*- mode: c++ -*- 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2002,2003,2015 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 // 00027 // Data provider weights iterators, based on sigma column 00028 // 00029 #ifndef MSVIS_STATISTICS_VI2_STATS_SIGMAS_ITERATOR_H_ 00030 #define MSVIS_STATISTICS_VI2_STATS_SIGMAS_ITERATOR_H_ 00031 00032 #include <casacore/casa/aips.h> 00033 #include <msvis/MSVis/VisibilityIterator2.h> 00034 #include <msvis/MSVis/VisBuffer2.h> 00035 #include <iterator> 00036 00037 namespace casa { 00038 00039 // Vi2StatsSigmasIterator has the form of a CRTP base class to promote 00040 // efficiency in iterator operations. The weights provided by these iterators 00041 // are converted from sigmas according to 1/(sigma^2) (except for sigma == 0). 00042 // 00043 template<class T> 00044 class Vi2StatsSigmasIterator 00045 : public std::iterator<std::input_iterator_tag,Float> { 00046 00047 public: 00048 Vi2StatsSigmasIterator& operator++(); 00049 00050 Vi2StatsSigmasIterator operator++(int); 00051 00052 bool operator==(const Vi2StatsSigmasIterator& rhs); 00053 00054 bool operator!=(const Vi2StatsSigmasIterator& rhs); 00055 00056 Float operator*(); 00057 00058 bool atEnd(); 00059 00060 protected: 00061 Vi2StatsSigmasIterator(vi::VisBuffer2 *vb2) 00062 : vb2(vb2) {}; 00063 00064 Vi2StatsSigmasIterator() {}; 00065 00066 vi::VisBuffer2 *vb2; 00067 }; 00068 00069 // Weights iterator over sigma cube. 00070 class Vi2StatsSigmasCubeIterator final 00071 : public Vi2StatsSigmasIterator<Vi2StatsSigmasCubeIterator> { 00072 00073 public: 00074 Vi2StatsSigmasCubeIterator(vi::VisBuffer2 *vb2); 00075 00076 Vi2StatsSigmasCubeIterator(); 00077 00078 Vi2StatsSigmasCubeIterator& operator++(); 00079 00080 Vi2StatsSigmasCubeIterator operator++(int); 00081 00082 bool operator==(const Vi2StatsSigmasCubeIterator& rhs); 00083 00084 bool operator!=(const Vi2StatsSigmasCubeIterator& rhs); 00085 00086 Float operator*(); 00087 00088 bool atEnd(); 00089 00090 protected: 00091 uInt correlation; 00092 uInt nCorrelations; 00093 uInt channel; 00094 uInt nChannels; 00095 uInt row; 00096 uInt nRows; 00097 }; 00098 00099 // Weights iterator over row sigmas. 00100 class Vi2StatsSigmasRowIterator final 00101 : public Vi2StatsSigmasIterator<Vi2StatsSigmasRowIterator> { 00102 00103 public: 00104 Vi2StatsSigmasRowIterator(vi::VisBuffer2 *vb2); 00105 00106 Vi2StatsSigmasRowIterator(); 00107 00108 Vi2StatsSigmasRowIterator& operator++(); 00109 00110 Vi2StatsSigmasRowIterator operator++(int); 00111 00112 bool operator==(const Vi2StatsSigmasRowIterator& rhs); 00113 00114 bool operator!=(const Vi2StatsSigmasRowIterator& rhs); 00115 00116 Float operator*(); 00117 00118 bool atEnd(); 00119 00120 protected: 00121 uInt row; 00122 uInt nRows; 00123 }; 00124 00125 } // namespace casa 00126 00127 #endif // MSVIS_STATISTICS_VI2_STATS_SIGMAS_ITERATOR_H_