casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LFTimeFreqCrop.h
Go to the documentation of this file.
00001 //# LFTimeFreqCrop: A lighter flagger - for autoflag
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 //# $Jan 28 2011 rurvashi Id$
00027 #ifndef FLAGGING_LFTIMEFREQCROP_H
00028 #define FLAGGING_LFTIMEFREQCROP_H
00029 
00030 #include <flagging/Flagging/LFBase.h>
00031 
00032 namespace casa { //# NAMESPACE CASA - BEGIN
00033   
00034   class LFTimeFreqCrop : public LFBase
00035   {
00036   public:  
00037     // default constructor 
00038     LFTimeFreqCrop  ();
00039     // default destructor
00040     ~LFTimeFreqCrop ();
00041 
00042     // Return method name
00043     String methodName(){return String("tfcrop");};
00044 
00045     // Set autoflag params
00046     Bool setParameters(Record &parameters);
00047     
00048     // Get default autoflag params
00049     Record getParameters();
00050 
00051     // Run the algorithm
00052     Bool runMethod(const VisBuffer &inVb, Cube<Float> &inVisc, Cube<Bool> &inFlagc, Cube<Bool> &inPreFlagc,
00053                    uInt numT, uInt numAnt, uInt numB, uInt numC, uInt numP);    
00054 
00055     Bool getMonitorSpectrum(Vector<Float> &monspec, uInt pl, uInt bs);
00056     
00057   private:
00058 
00059     // TFCROP functions
00060   Float UMean(Vector<Float> vect, Vector<Bool> flag);
00061   Float calcVar(Vector<Float> vect, Vector<Bool> flag, Vector<Float> fit);
00062   Float UStd(Vector<Float> vect, Vector<Bool> flag, Vector<Float> fit);
00063   Float UStd(Vector<Float> vect, Vector<Bool> flag, Float mean);
00064     void FitPiecewisePoly(Vector<Float> data,Vector<Bool> flag, Vector<Float> fit);
00065   void PolyFit(Vector<Float> data,Vector<Bool> flag, Vector<Float> fit, uInt lim1, uInt lim2,uInt deg);
00066   void LineFit(Vector<Float> data,Vector<Bool> flag, Vector<Float> fit, uInt lim1, uInt lim2);
00067 
00068     //  void Ants(uInt bs, uInt *a1, uInt *a2);
00069     //uInt BaselineIndex(uInt row, uInt a1, uInt a2);
00070 
00071   void AllocateMemory();  
00072 
00073     void FitBaseAndFlag(uInt pl, uInt bs, String fittype, String direction, Cube<Float> &cleanArr);
00074     //    void FlagDeviationsFromBase(uInt pl, uInt bs, String direction, Cube<Float> &cleanArr);
00075 
00076     /*
00077     void FitCleanBandPass(uInt pl, uInt bs, String fittype);
00078     void FitCleanTimeSeries(uInt pl, uInt bs, String fittype);
00079 
00080     void FlagTimeSeriesAgain(uInt pl, uInt bs);
00081     void FlagBandPass(uInt pl, uInt bs);
00082     */
00083 
00084     //void FlagTimeSeries(uInt pl, uInt bs, String fittype);
00085 
00086 
00087     // Input parameters
00088     Double ANT_TOL, BASELN_TOL, T_TOL, F_TOL;
00089     Int CorrChoice, NumTime, MaxNPieces, halfWin_p, MaxDeg;
00090     String Expr, Column;
00091     Vector<Int> intSelCorr;
00092 
00093     String timeFitType_p, freqFitType_p, flagDimension_p, winStats_p;
00094  
00095     // Shapes per chunk
00096 
00097     //    uInt Nrow; // Number of rows in current chunk
00098     //  uInt Ncorr; // Number of correlations
00099     //IPosition VisCubeShp;
00100 
00101 
00102   Cube<Float> meanBP;   // mean bandpass - npol x nbaselines x nchannels
00103   Cube<Float> cleanBP;  // cleaned bandpasses - npol x nbaselines x nchannels
00104   Cube<Float> cleanTS;  // cleaned timeseries - npol x nbaselines x ntimes
00105 
00106   Vector<Float> tempBP; // temporary workspace - nchannels
00107   Vector<Float> tempTS; // temporary workspace - ntimes
00108   Vector<Bool> flagBP;  // temporary list of flags - nchannels
00109   Vector<Bool> flagTS;  // temporary list of flags - ntimes
00110   Vector<Float> fitBP;  // temporary fit array - nchannels
00111   Vector<Float> fitTS;  // temporary fit array - ntimes
00112     Vector<Int> ant1,ant2;
00113     
00114   };
00115   
00116   
00117 } //# NAMESPACE CASA - END
00118 
00119 #endif
00120