casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
RFASpectralRej.h
Go to the documentation of this file.
00001 //# RFASpectralRej.h: this defines RFASpectralRej
00002 //# Copyright (C) 2000,2001,2002
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_RFASPECTRALREJ_H
00028 #define FLAGGING_RFASPECTRALREJ_H
00029 
00030 #include <flagging/Flagging/RFAFlagCubeBase.h> 
00031 #include <flagging/Flagging/RFDataMapper.h> 
00032 #include <flagging/Flagging/RFFlagCube.h> 
00033 #include <flagging/Flagging/RFRowClipper.h> 
00034 #include <scimath/Functionals/Polynomial.h>
00035 #include <scimath/Fitting/LinearFit.h>
00036 #include <casa/Containers/Queue.h>
00037 #include <casa/Arrays/LogiVector.h>
00038     
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 // <summary>
00042 // RFASpectralRej: Spectral rejection agent
00043 // </summary>
00044 
00045 // <use visibility=local>
00046 
00047 // <reviewed reviewer="" date="" tests="" demos="">
00048 // </reviewed>
00049 
00050 // <prerequisite>
00051 //   <li> RFDataMapper
00052 //   <li> RFFlagCubeBase
00053 //   <li> RFRowClipper
00054 // </prerequisite>
00055 //
00056 // <synopsis>
00057 // RFASpectralRej fits a polynomial to a specified segment of the spectrum 
00058 // (presumably, spectral line-free). The fit produces a noise estimate for
00059 // each row. Rows with excessive noise levels are flagged using RFRowClipper.
00060 // </synopsis>
00061 //
00062 // <todo asof="2001/04/16">
00063 //   <li> add this feature
00064 //   <li> fix this bug
00065 //   <li> start discussion of this possible extension
00066 // </todo>
00067 
00068 class RFASpectralRej : public RFAFlagCubeBase, public RFDataMapper
00069 {
00070 public:
00071   RFASpectralRej  ( RFChunkStats &ch,const RecordInterface &parm ); 
00072   virtual ~RFASpectralRej () {};
00073   
00074   virtual uInt estimateMemoryUse () { return RFAFlagCubeBase::estimateMemoryUse()+2; }
00075   virtual Bool newChunk (Int &maxmem);
00076   virtual void endChunk ();
00077   virtual void startData (bool verbose);
00078   virtual IterMode iterTime (uInt it);
00079   virtual IterMode iterRow  (uInt ir);
00080   virtual IterMode endData  ();
00081 
00082   virtual String getDesc ();
00083   static const RecordInterface & getDefaults ();
00084   
00085 protected:
00086   void addSegment  ( Int spwid,Double fq0,Double fq1,Int ch0,Int ch1 );
00087   void parseRegion ( const RecordInterface &parm );
00088     
00089   // spectral region specifications
00090   typedef struct Segment { Int spwid; Double fq0,fq1; Int ch0,ch1; } Segment;
00091   
00092   Block<Segment> segments;
00093   LogicalVector fitchan;
00094   uInt num_fitchan;
00095 
00096   uInt       ndeg,halfwin;
00097   Double     threshold;  
00098   
00099   RFRowClipper rowclipper; // row clipper object
00100 
00101   Polynomial<AutoDiff<Float> > poly; // fitted polynomial
00102   LinearFit<Float> fitter;     // fitter object
00103   
00104   Double     xnorm;
00105 };
00106 
00107 
00108 } //# NAMESPACE CASA - END
00109 
00110 #endif