Line data Source code
1 : //# RFRowClipper.h: this defines RFRowClipper 2 : //# Copyright (C) 2000,2001 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 : //# $Id$ 27 : #ifndef FLAGGING_RFROWCLIPPER_H 28 : #define FLAGGING_RFROWCLIPPER_H 29 : 30 : #include <flagging/Flagging/RFCommon.h> 31 : #include <casacore/casa/Arrays/Vector.h> 32 : #include <casacore/casa/Arrays/Matrix.h> 33 : 34 : namespace casa { //# NAMESPACE CASA - BEGIN 35 : 36 : class RFFlagCube; 37 : class RFChunkStats; 38 : 39 : // <summary> 40 : // RFRowClipper: flags rows based on their noise level 41 : // </summary> 42 : 43 : // <use visibility=local> 44 : 45 : // <reviewed reviewer="" date="" tests="" demos=""> 46 : // </reviewed> 47 : 48 : // <synopsis> 49 : // RFRowClipper accumulates per-row noise estimates in an [NIFR,NTIME] matrix. 50 : // After each pass it performs flagging of rows with excessive noise (w/respect 51 : // to a sliding median per IFR, over time). 52 : // </synopsis> 53 : // 54 : // <motivation> 55 : // Several flagging agents produce per-row noise estimates and can flag based 56 : // on them. Hence, a commmon implementation was desired. 57 : // </motivation> 58 : // 59 : // <todo asof="2001/04/16"> 60 : // <li> add this feature 61 : // <li> fix this bug 62 : // <li> start discussion of this possible extension 63 : // </todo> 64 : 65 : class RFRowClipper : public FlaggerEnums 66 : { 67 : public: 68 : // construct from a chunk accessor and flag cube. Clip is the clipping 69 : // level, HW is the sliding median window half-width, MAXP is maximum 70 : // iterative passes. 71 : RFRowClipper ( RFChunkStats &chunk,RFFlagCube &flag,casacore::Float clip,casacore::uInt hw=6,casacore::uInt maxp=5 ); 72 : // destructor 73 0 : ~RFRowClipper () {}; 74 : 75 : // initialize for an [NI,NT] matrix 76 : void init ( casacore::uInt ni,casacore::uInt nt ); 77 : // deallocate matrices 78 : void cleanup (); 79 : // reset at start of pass 80 : void reset (); 81 : 82 : // returns the current noise estimate 83 : casacore::Float sigma0 ( casacore::uInt ifr,casacore::uInt it ); 84 : // sets a new noise estimate 85 : void setSigma ( casacore::uInt ifr,casacore::uInt it,casacore::Float level ); 86 : // marks a noise estimate as updated without changing it 87 : void markSigma ( casacore::uInt ifr ); 88 : 89 : // recompute updated estimates and optionally do row flagging 90 : casacore::Float updateSigma (casacore::uInt &ifrmax,casacore::uInt &itmax,casacore::Bool flagrows = true, bool clear_flags = true ); 91 : 92 : private: 93 : RFChunkStats &chunk; 94 : RFFlagCube &flag; 95 : casacore::Float clip_level; 96 : casacore::uInt halfwin,maxpass; 97 : 98 : casacore::uInt nifr,ntime; 99 : casacore::Matrix<casacore::Float> sig,sig0; 100 : casacore::Vector<casacore::Bool> sigupdated; 101 : 102 : casacore::LogIO &os; 103 : }; 104 : 105 0 : inline casacore::Float RFRowClipper::sigma0 (casacore::uInt ifr,casacore::uInt it) 106 : { 107 0 : return sig0(it,ifr); 108 : } 109 : 110 0 : inline void RFRowClipper::setSigma (casacore::uInt ifr,casacore::uInt it,casacore::Float level) 111 : { 112 0 : sig(it,ifr) = level; 113 0 : sigupdated(ifr) = true; 114 0 : } 115 : 116 0 : inline void RFRowClipper::markSigma (casacore::uInt ifr) 117 : { 118 0 : sigupdated(ifr) = true; 119 0 : } 120 : 121 : 122 : } //# NAMESPACE CASA - END 123 : 124 : #endif