casa
$Rev:20696$
|
00001 //# LFBase.h: 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_LFBASE_H 00028 #define FLAGGING_LFBASE_H 00029 00030 #include <ms/MeasurementSets/MeasurementSet.h> 00031 #include <ms/MeasurementSets/MSSelection.h> 00032 #include <synthesis/MSVis/VisSet.h> 00033 #include <synthesis/MSVis/VisibilityIterator.h> 00034 #include <synthesis/MSVis/VisBuffer.h> 00035 #include <ms/MeasurementSets/MSColumns.h> 00036 00037 #include <casa/Logging/LogIO.h> 00038 #include <casa/Arrays/Vector.h> 00039 #include <casa/Containers/Record.h> 00040 #include <casa/Quanta/Quantum.h> 00041 00042 #include <scimath/Functionals/Polynomial.h> 00043 #include <scimath/Fitting.h> 00044 #include <scimath/Fitting/LinearFit.h> 00045 #include <scimath/Fitting/GenericL2Fit.h> 00046 00047 namespace casa { //# NAMESPACE CASA - BEGIN 00048 00049 class LFBase 00050 { 00051 public: 00052 // default constructor 00053 LFBase (){NumT=0; NumAnt=0; NumB=0; NumC=0; NumP=0; 00054 Record rec = getParameters(); setParameters(rec); }; 00055 // default destructor 00056 virtual ~LFBase (){}; 00057 00058 //Return method name 00059 virtual String methodName()=0; 00060 00061 // Set autoflag params 00062 virtual Bool setParameters(Record &/*parameters*/){ return False;} 00063 00064 // Get default autoflag params 00065 virtual Record getParameters(){return Record();}; 00066 00067 // Run the algorithm 00068 virtual Bool runMethod(const VisBuffer &inVb, 00069 Cube<Float> &inVisc, Cube<Bool> &inFlagc, Cube<Bool> &inPreFlagc, 00070 uInt numT, uInt numAnt, uInt numB, uInt numC, uInt numP) 00071 { 00072 vb.assign(inVb,False); 00073 visc.reference(inVisc); flagc.reference(inFlagc); preflagc.reference(inPreFlagc); 00074 NumT=numT, NumAnt=numAnt; NumB=numB; NumC=numC; NumP=numP; 00075 00076 return False; 00077 }; 00078 00079 // Extract a diagnostic spectrum vector. 00080 virtual Bool getMonitorSpectrum(Vector<Float> &/*monspec*/, uInt /*pl*/, uInt /*bs*/) 00081 {return False;}; 00082 00083 // Set baselineFlags... 00084 virtual Bool setBaselineFlag(Vector<Bool> &inBaselineFlag) 00085 {baselineFlag.reference(inBaselineFlag); return False;} 00086 00087 /* Return antenna numbers from baseline number - upper triangle storage */ 00088 void Ants(uInt bs, uInt *a1, uInt *a2) 00089 { 00090 uInt sum=0,cnt=0; 00091 for(uInt i=(NumAnt);i>1;i--) 00092 { 00093 sum += i; 00094 if(sum<=bs) cnt++; 00095 else break; 00096 } 00097 *a1 = cnt; 00098 sum = (NumAnt)*((NumAnt)+1)/2 - ((NumAnt)-(*a1))*((NumAnt)-(*a1)+1)/2; 00099 *a2 = bs - sum + (*a1); 00100 } 00101 00102 /* Return baseline index from a pair of antenna numbers - upper triangle storage */ 00103 uInt BaselineIndex(uInt /*row*/, uInt a1, uInt a2) 00104 { 00105 return ( (NumAnt)*((NumAnt)+1)/2 - ((NumAnt)-a1)*((NumAnt)-a1+1)/2 + (a2 - a1) ); 00106 } 00107 00108 /* Return baseline index for the autocorrelation value for an antenna */ 00109 uInt Self(uInt ant) 00110 { 00111 return ( (NumAnt)*((NumAnt)+1)/2 - ((NumAnt)-ant)*((NumAnt)-ant+1)/2 ); 00112 } 00113 00114 protected: 00115 00116 Bool dbg; 00117 00118 // Reference to current vb. 00119 VisBuffer vb; 00120 00121 // References to input data and flags 00122 Cube<Float> visc; 00123 Cube<Bool> flagc; 00124 Cube<Bool> preflagc; 00125 Vector<Bool> baselineFlag; 00126 00127 // Shapes per chunk 00128 uInt NumT; // Number of timestamps in one block 00129 uInt NumAnt; // Number of antennas 00130 uInt NumB; // Number of baselines. 00131 uInt NumC; // Number of channels 00132 uInt NumP; // Number of polarizations 00133 00134 }; 00135 00136 00137 } //# NAMESPACE CASA - END 00138 00139 #endif 00140