Line data Source code
1 : //# RFASpectralRej.h: this defines RFASpectralRej 2 : //# Copyright (C) 2000,2001,2002 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_RFASPECTRALREJ_H 28 : #define FLAGGING_RFASPECTRALREJ_H 29 : 30 : #include <flagging/Flagging/RFAFlagCubeBase.h> 31 : #include <flagging/Flagging/RFDataMapper.h> 32 : #include <flagging/Flagging/RFFlagCube.h> 33 : #include <flagging/Flagging/RFRowClipper.h> 34 : #include <casacore/scimath/Functionals/Polynomial.h> 35 : #include <casacore/scimath/Fitting/LinearFit.h> 36 : #include <casacore/casa/Arrays/LogiVector.h> 37 : 38 : namespace casa { //# NAMESPACE CASA - BEGIN 39 : 40 : // <summary> 41 : // RFASpectralRej: Spectral rejection agent 42 : // </summary> 43 : 44 : // <use visibility=local> 45 : 46 : // <reviewed reviewer="" date="" tests="" demos=""> 47 : // </reviewed> 48 : 49 : // <prerequisite> 50 : // <li> RFDataMapper 51 : // <li> RFFlagCubeBase 52 : // <li> RFRowClipper 53 : // </prerequisite> 54 : // 55 : // <synopsis> 56 : // RFASpectralRej fits a polynomial to a specified segment of the spectrum 57 : // (presumably, spectral line-free). The fit produces a noise estimate for 58 : // each row. Rows with excessive noise levels are flagged using RFRowClipper. 59 : // </synopsis> 60 : // 61 : // <todo asof="2001/04/16"> 62 : // <li> add this feature 63 : // <li> fix this bug 64 : // <li> start discussion of this possible extension 65 : // </todo> 66 : 67 : class RFASpectralRej : public RFAFlagCubeBase, public RFDataMapper 68 : { 69 : public: 70 : RFASpectralRej ( RFChunkStats &ch,const casacore::RecordInterface &parm ); 71 0 : virtual ~RFASpectralRej () {}; 72 : 73 0 : virtual casacore::uInt estimateMemoryUse () { return RFAFlagCubeBase::estimateMemoryUse()+2; } 74 : virtual casacore::Bool newChunk (casacore::Int &maxmem); 75 : virtual void endChunk (); 76 : virtual void startData (bool verbose); 77 : virtual IterMode iterTime (casacore::uInt it); 78 : virtual IterMode iterRow (casacore::uInt ir); 79 : virtual IterMode endData (); 80 : 81 : virtual casacore::String getDesc (); 82 : static const casacore::RecordInterface & getDefaults (); 83 : 84 : protected: 85 : void addSegment ( casacore::Int spwid,casacore::Double fq0,casacore::Double fq1,casacore::Int ch0,casacore::Int ch1 ); 86 : void parseRegion ( const casacore::RecordInterface &parm ); 87 : 88 : // spectral region specifications 89 : typedef struct Segment { casacore::Int spwid; casacore::Double fq0,fq1; casacore::Int ch0,ch1; } Segment; 90 : 91 : casacore::Block<Segment> segments; 92 : casacore::LogicalVector fitchan; 93 : casacore::uInt num_fitchan; 94 : 95 : casacore::uInt ndeg,halfwin; 96 : casacore::Double threshold; 97 : 98 : RFRowClipper rowclipper; // row clipper object 99 : 100 : casacore::Polynomial<casacore::AutoDiff<casacore::Float> > poly; // fitted polynomial 101 : casacore::LinearFit<casacore::Float> fitter; // fitter object 102 : 103 : casacore::Double xnorm; 104 : }; 105 : 106 : 107 : } //# NAMESPACE CASA - END 108 : 109 : #endif