casa
$Rev:20696$
|
00001 //# RFRowClipper.h: this defines RFRowClipper 00002 //# Copyright (C) 2000,2001 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 //# $Id$ 00027 #ifndef FLAGGING_RFROWCLIPPER_H 00028 #define FLAGGING_RFROWCLIPPER_H 00029 00030 #include <flagging/Flagging/RFCommon.h> 00031 #include <casa/Arrays/Vector.h> 00032 #include <casa/Arrays/Matrix.h> 00033 00034 namespace casa { //# NAMESPACE CASA - BEGIN 00035 00036 class RFFlagCube; 00037 class RFChunkStats; 00038 00039 // <summary> 00040 // RFRowClipper: flags rows based on their noise level 00041 // </summary> 00042 00043 // <use visibility=local> 00044 00045 // <reviewed reviewer="" date="" tests="" demos=""> 00046 // </reviewed> 00047 00048 // <synopsis> 00049 // RFRowClipper accumulates per-row noise estimates in an [NIFR,NTIME] matrix. 00050 // After each pass it performs flagging of rows with excessive noise (w/respect 00051 // to a sliding median per IFR, over time). 00052 // </synopsis> 00053 // 00054 // <motivation> 00055 // Several flagging agents produce per-row noise estimates and can flag based 00056 // on them. Hence, a commmon implementation was desired. 00057 // </motivation> 00058 // 00059 // <todo asof="2001/04/16"> 00060 // <li> add this feature 00061 // <li> fix this bug 00062 // <li> start discussion of this possible extension 00063 // </todo> 00064 00065 class RFRowClipper : public FlaggerEnums 00066 { 00067 public: 00068 // construct from a chunk accessor and flag cube. Clip is the clipping 00069 // level, HW is the sliding median window half-width, MAXP is maximum 00070 // iterative passes. 00071 RFRowClipper ( RFChunkStats &chunk,RFFlagCube &flag,Float clip,uInt hw=6,uInt maxp=5 ); 00072 // destructor 00073 ~RFRowClipper () {}; 00074 00075 // initialize for an [NI,NT] matrix 00076 void init ( uInt ni,uInt nt ); 00077 // deallocate matrices 00078 void cleanup (); 00079 // reset at start of pass 00080 void reset (); 00081 00082 // returns the current noise estimate 00083 Float sigma0 ( uInt ifr,uInt it ); 00084 // sets a new noise estimate 00085 void setSigma ( uInt ifr,uInt it,Float level ); 00086 // marks a noise estimate as updated without changing it 00087 void markSigma ( uInt ifr ); 00088 00089 // recompute updated estimates and optionally do row flagging 00090 Float updateSigma (uInt &ifrmax,uInt &itmax,Bool flagrows = True, bool clear_flags = true ); 00091 00092 private: 00093 RFChunkStats &chunk; 00094 RFFlagCube &flag; 00095 Float clip_level; 00096 uInt halfwin,maxpass; 00097 00098 uInt nifr,ntime; 00099 Matrix<Float> sig,sig0; 00100 Vector<Bool> sigupdated; 00101 00102 LogIO &os; 00103 }; 00104 00105 inline Float RFRowClipper::sigma0 (uInt ifr,uInt it) 00106 { 00107 return sig0(it,ifr); 00108 } 00109 00110 inline void RFRowClipper::setSigma (uInt ifr,uInt it,Float level) 00111 { 00112 sig(it,ifr) = level; 00113 sigupdated(ifr) = True; 00114 } 00115 00116 inline void RFRowClipper::markSigma (uInt ifr) 00117 { 00118 sigupdated(ifr) = True; 00119 } 00120 00121 00122 } //# NAMESPACE CASA - END 00123 00124 #endif