casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
RFASelector.h
Go to the documentation of this file.
00001 
00002 //# RFASelector.h: this defines RFASelector
00003 //# Copyright (C) 2000,2001
00004 //# Associated Universities, Inc. Washington DC, USA.
00005 //#
00006 //# This library is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU Library General Public License as published by
00008 //# the Free Software Foundation; either version 2 of the License, or (at your
00009 //# option) any later version.
00010 //#
00011 //# This library is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 //# License for more details.
00015 //#
00016 //# You should have received a copy of the GNU Library General Public License
00017 //# along with this library; if not, write to the Free Software Foundation,
00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 //#
00027 //# $Id$
00028 #ifndef FLAGGING_RFASELECTOR_H
00029 #define FLAGGING_RFASELECTOR_H
00030 
00031 #include <flagging/Flagging/RFAFlagCubeBase.h> 
00032 #include <flagging/Flagging/RFDataMapper.h>
00033 #include <ms/MeasurementSets/MSColumns.h>
00034 #include <casa/Arrays/LogiVector.h>
00035     
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // <summary>
00039 // RFASelector: flags pixels/rows based on a specified selection
00040 // </summary>
00041 
00042 // <use visibility=local>
00043 
00044 // <reviewed reviewer="" date="" tests="" demos="">
00045 // </reviewed>
00046 
00047 // <prerequisite>
00048 //   <li> RFAFlagCubebase
00049 // </prerequisite>
00050 //
00051 // <etymology>
00052 // RedFlaggerAgent Selector
00053 // </etymology>
00054 //
00055 // <synopsis>
00056 // RFASelector accepts a whole bunch of options to select a subset of the
00057 // MS (by time, antenna, baseline, channel/frequency, etc.), and to flag/unflag 
00058 // the whole selection, or specific parts of it (autocorrelations, specific 
00059 // time slots, VLA quacks, etc.)
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 RFASelector : public RFAFlagCubeBase
00069 {
00070 public:
00071 // constructor. 
00072   RFASelector ( RFChunkStats &ch,const RecordInterface &parm ); 
00073   virtual ~RFASelector ();
00074   
00075   virtual uInt estimateMemoryUse () { return RFAFlagCubeBase::estimateMemoryUse()+2; }
00076   virtual Bool newChunk ( Int &maxmem );
00077   virtual IterMode iterTime ( uInt it );
00078   virtual void endRows(uInt itime);
00079   virtual IterMode iterRow  ( uInt ir );
00080   virtual void iterFlag(uInt itime);
00081   virtual void startData(bool verbose);
00082 
00083   virtual String getDesc ();
00084   static const RecordInterface & getDefaults ();
00085 
00086   Bool fortestingonly_parseMinMax( Float &vmin,Float &vmax,const RecordInterface &spec,uInt f0 );
00087   void fortestingonly_parseClipField( const RecordInterface &spec,Bool clip );
00088 
00089 protected:
00090   typedef struct ClipInfo {
00091       RFDataMapper *mapper; 
00092       Float vmin, vmax; 
00093       Bool channel_average; // average data over channels?
00094       Bool clip;            // flag outside range if True (otherwise flag inside)
00095       Float offset;         // offset added to value (used for angles, etc.)
00096   } ClipInfo;
00097   
00098     
00099   template<class T> Bool reformRange( Matrix<T> &rng,const Array<T> &arr );
00100   template<class T> Bool parseRange( Matrix<T> &rng,const RecordInterface &parm,const String &id );
00101   template<class T> Bool find( uInt &index,const T &obj,const Vector<T> &arr );
00102   
00103   Bool parseTimes  ( Array<Double> &times,const RecordInterface &parm,const String &id,Bool secs=False );
00104   void addString   ( String &str,const String &s1,const char *sep=" " );
00105   virtual void processRow  ( uInt ifr,uInt it );
00106   Bool parseMinMax ( Float &vmin,Float &vmax,const RecordInterface &spec,uInt f0 );
00107   void addClipInfo ( const Vector<String> &expr,Float vmin,Float vmax,Bool clip, Bool channel_average );
00108   void parseClipField  ( const RecordInterface &spec,Bool clip );
00109   void addClipInfoDesc ( const Block<ClipInfo> &clip );
00110 
00111   // shadow mode
00112   Double diameter;   /* diameter to use. If negative use 
00113                         the diameters array (true antenna diameters)
00114                      */
00115   Vector< Double > diameters;
00116   ROMSAntennaColumns *ac;
00117 
00118   // elevation
00119   double lowerlimit;
00120   double upperlimit;
00121 
00122 // description of agent
00123   String desc_str;
00124 // selection arguments
00125   Matrix<Double> sel_freq,sel_time,sel_timerng,sel_uvrange;
00126   Matrix<Int>    sel_chan;
00127   Vector<Int>    sel_corr,sel_spwid,sel_fieldid, sel_stateid;
00128   Vector<String>  sel_fieldnames;
00129   LogicalVector  sel_ifr,flagchan,sel_feed;
00130   Bool          sel_autocorr,unflag;
00131   Block<ClipInfo> sel_clip,sel_clip_row;
00132   LogicalVector  sel_clip_active;
00133   Bool            sum_sel_clip_active;
00134   Double        quack_si, quack_dt;
00135   String        quack_mode;
00136   Bool          quack_increment;
00137   Vector<Int>   sel_scannumber,sel_arrayid,sel_observation;
00138   String        sel_column;
00139 
00140   Bool select_fullrow,flag_everything, shadow, elevation;
00141 
00142 };
00143 
00144     
00145     
00146 
00147 } //# NAMESPACE CASA - END
00148 
00149 #ifndef AIPS_NO_TEMPLATE_SRC
00150 #include <flagging/Flagging/RFASelector.tcc>
00151 #endif //# AIPS_NO_TEMPLATE_SRC
00152 #endif