casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
RFCommon.h
Go to the documentation of this file.
00001 //# RFCommon.h: this defines RFCommon
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 //# $Id$
00027 #ifndef FLAGGING_RFCOMMON_H
00028 #define FLAGGING_RFCOMMON_H
00029     
00030 #include <casa/Arrays/Vector.h>
00031 #include <casa/Arrays/Matrix.h>
00032 #include <casa/Containers/RecordInterface.h>
00033 #include <casa/Containers/RecordInterface.h>
00034 #include <casa/Logging/LogIO.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // RFAs use bitwise flags
00039 typedef uInt RFlagWord;
00040 typedef Vector<RFlagWord> FlagVector;
00041 typedef Matrix<RFlagWord> FlagMatrix;
00042 
00043 // character constants for common agent parameters
00044 const char 
00045     RF_GLISHINDEX[] = "_glishindex", // this is set automatically to indicate 1-based indexing
00046     
00047     RF_NAME[]    = "name",
00048     
00049     RF_DEBUG[]   = "debug",
00050     RF_PLOT[]    = "plot",
00051     RF_PLOTSCR[] = "plotscr",
00052     RF_GLOBAL[]  = "global",
00053     RF_TRIAL[]   = "trial",
00054 
00055     RF_RESET[]   = "reset",
00056     RF_FIGNORE[] = "fignore",
00057     RF_UNFLAG[]  = "unflag",
00058     RF_SHADOW[]  = "shadow",
00059     RF_ELEVATION[] = "elevation",
00060     
00061     RF_THR[]     = "thr",
00062     RF_ROW_THR[] = "rowthr",
00063     
00064     RF_HW[]      = "hw",
00065     RF_ROW_HW[]  = "rowhw",
00066     RF_ROW_DISABLE[] = "norow",
00067 
00068     RF_COLUMN[]  = "column",
00069     RF_EXPR[]    = "expr",
00070     
00071     RF_CLIP[]      = "clip",
00072     RF_FLAGRANGE[] = "flagrange",
00073     RF_MIN[]       = "min",
00074     RF_MAX[]       = "max",
00075     RF_CHANAVG[]   = "chanavg",
00076     
00077     RF_NDEG[]    = "ndeg",
00078     RF_SPWID[]   = "spwid", 
00079     RF_FREQS[]   = "fq",
00080     RF_CHANS[]   = "chan",
00081     RF_REGION[]  = "region",
00082     
00083     RF_NBINS[]   = "nbins",
00084     RF_MINPOP[]  = "minpop",
00085     
00086     RF_CORR[]    = "corr",
00087     RF_ANT[]     = "ant",
00088     RF_FIELD[]   = "field",
00089     RF_BASELINE[] = "baseline",
00090     RF_AUTOCORR[] = "autocorr",
00091 
00092     RF_INTENT[] = "intent",
00093     RF_SCAN[]    = "scan",
00094     RF_ARRAY[]   = "array",
00095     RF_OBSERVATION[] = "observation",
00096     RF_FEED[]    = "feed",
00097     RF_UVRANGE[] = "uvrange",
00098     RF_DIAMETER[] = "diameter",
00099     RF_LOWERLIMIT[]  = "lowerlimit",
00100     RF_UPPERLIMIT[]  = "upperlimit",
00101     
00102     RF_TIMERANGE[] = "timerng",
00103     RF_CENTERTIME[] = "timeslot",
00104     RF_TIMEDELTA[] = "dtime",
00105     
00106     RF_QUACK[]     = "quack",
00107     RF_QUACKMODE[] = "quackmode",
00108     RF_QUACKINC[]  = "quackinc",
00109 
00110     RF_NCHAN[] = "nchan",
00111     RF_START[] = "start",
00112     RF_STEP[] = "step",
00113     RF_MODE[] = "mode",
00114     RF_MSSELECT[] = "msselect";
00115 
00116 // <summary>
00117 // FlaggerEnums: collection of enums for various flagger classes
00118 // </summary>
00119 
00120 // <use visibility=local>
00121 
00122 // <reviewed reviewer="" date="" tests="" demos="">
00123 // </reviewed>
00124 class FlaggerEnums 
00125 {
00126 public:
00127   typedef enum 
00128     { POLZN = 0,POL=POLZN,CORR=POLZN,
00129       CHAN  = 1,
00130       IFR   = 2,
00131       TIME  = 3,
00132       ROW   = 4,
00133       ANT   = 5,
00134       FEED  = 6,
00135       FEEDCORR  = 7,
00136       NONE  = -1,
00137       Num_StatEnums=8 
00138     } StatEnums;
00139 
00140   typedef enum 
00141   {
00142     FL_HONOR  = 0,
00143     FL_IGNORE = 1,
00144     FL_RESET  = 2
00145   } PreFlagPolicy;
00146 };
00147    
00148 
00149 // short inline function for checking the type of a record field
00150 inline Bool fieldType ( const RecordInterface &parm,const String &id,DataType type,DataType type2 = TpNumberOfTypes )
00151 {
00152   if( !parm.isDefined(id) || !parm.shape(id).product() )
00153     return False;
00154   DataType t = parm.dataType(id);
00155   return t==type || t==type2;
00156 }
00157     
00158 // short inline function for checking a field's data type against some function
00159 inline Bool isField ( const RecordInterface &parm,const String &id,Bool (*func)(DataType) )
00160 {
00161   if( !parm.isDefined(id) )
00162     return False;
00163   DataType type = parm.dataType(id);
00164   return (*func)(type);
00165 }
00166 
00167 // short inline function for checking that a field is a non-empty record
00168 inline Bool isValidRecord ( const RecordInterface &parm,const String &id)
00169 {
00170   if( !parm.isDefined(id) || parm.dataType(id) != TpRecord )
00171     return False;
00172   return parm.asRecord(id).nfields() > 0;
00173 }
00174     
00175 // Short inline function for checking if a record field is "set",
00176 // i.e. exists, and is not an empty array or a boolean False.
00177 inline Bool isFieldSet ( const RecordInterface &parm,const String &id )
00178 {
00179   return parm.isDefined(id) && parm.shape(id).product() && ( parm.dataType(id) != TpBool || parm.asBool(id) );
00180 }
00181     
00182 // Short inline function for returning the number of elements in a field
00183 // (0 for no field, 1 for scalar, >1 for arrays)
00184 inline uInt fieldSize ( const RecordInterface &parm,const String &id )
00185 {
00186   return parm.isDefined(id) ? parm.shape(id).product() : 0;
00187 }
00188 
00189 // Basically just upcase(), but in a form suitable for Array::apply
00190 inline String stringUpper ( const String &in )
00191 {
00192   return upcase(in);
00193 }
00194 
00195 // a debug-printf function, for printf-ing debug messages
00196 int dprintf( LogIO &os, const char *format, ... );
00197 
00198 
00199 } //# NAMESPACE CASA - END
00200 
00201 #endif