diff --git a/.gitattributes b/.gitattributes index 7260158f68e945481e0e6ef345a5f6f7ae069afb..5a0103def633107d8912e18affd272b5a9cb6716 100644 --- a/.gitattributes +++ b/.gitattributes @@ -99,6 +99,7 @@ CEP/DP3/DPPP/src/PipelineProcessControl.cc -text CEP/DP3/DPPP/src/RunDetails.cc -text CEP/DP3/DPPP/src/mwflagger -text CEP/DP3/DPPP/src/mwflagger-part -text +CEP/DP3/DPPP/src/taqlflagger -text CEP/DP3/DPPP/test/CS1_IDPPP.log_prop -text CEP/DP3/DPPP/test/CS1_IDPPP.parset -text CEP/DP3/DPPP/test/Makefile.am -text diff --git a/CEP/DP3/DPPP/src/CMakeLists.txt b/CEP/DP3/DPPP/src/CMakeLists.txt index 46077103a47de2dac1e269ba28c7058e02ecb493..bbc3ca92f3145d17bc3aa504c478dcdaf5338f2a 100644 --- a/CEP/DP3/DPPP/src/CMakeLists.txt +++ b/CEP/DP3/DPPP/src/CMakeLists.txt @@ -25,4 +25,5 @@ lofar_add_bin_program(versiondppp versiondppp.cc) install(PROGRAMS mwflagger mwflagger-part + taqlflagger DESTINATION bin) diff --git a/CEP/DP3/DPPP/src/Makefile.am b/CEP/DP3/DPPP/src/Makefile.am index 6046b8fbb54e9e15c05ec8442e6fc3352990cea6..93784e48353a4c3835706deaf80de7dd69d2d314 100644 --- a/CEP/DP3/DPPP/src/Makefile.am +++ b/CEP/DP3/DPPP/src/Makefile.am @@ -27,7 +27,7 @@ pythondir = $(bindir) dist_python_SCRIPTS = scriptdir = $(bindir) -dist_script_SCRIPTS = mwflagger mwflagger-part +dist_script_SCRIPTS = mwflagger mwflagger-part taqlflagger versiondppp_SOURCES = versiondppp.cc versiondppp_LDADD = libdppp.la diff --git a/CEP/DP3/DPPP/src/taqlflagger b/CEP/DP3/DPPP/src/taqlflagger new file mode 100755 index 0000000000000000000000000000000000000000..6a4c4e8f0a9a44ac6dbbbba17c72889c2bab866b --- /dev/null +++ b/CEP/DP3/DPPP/src/taqlflagger @@ -0,0 +1,88 @@ +#!/bin/sh + +# Skip first argument if it is a rank (a numeric value). +res=`echo $1 | sed 's/[0-9]*//'` +test "$res" = "" && shift + +# Test if an MS name is given. +err=1 +ms=$1 +if test "$ms" != ""; then + shift + err=0 + + # Test if -dry or dry is given. + dry=0 + if test "$1" = "-dry" -o "$1" = "dry"; then + dry=1 + fi + # Test if flag or unflag is given. flag means use value T, otherwise F. + val=T + if test "$1" = "flag"; then + shift + elif test "$1" = "unflag"; then + val=F + shift + fi + + pol= + chan= + where= + while test $# != 0 -a $err = 0 + do + sel=$1 + # Check if a pol or chan selection is given. + case $sel in + chan=*) + test "$chan" = "" || err=1 + chan=`echo $sel | sed -e 's/chan=//'` + cmd="update $ms set FLAG[$chan,]=T" + ;; + pol=*) + test "$pol" = "" || err=1 + pol=`echo $sel | sed -e 's/pol=//'` + cmd="update $ms set FLAG[,$pol]=T" + ;; + *) + if test "$where" = ""; then + where="$sel" + else + where="($where) && ($sel)" + fi + ;; + esac + shift + done +fi + +if test $err = 0; then + cmd="update $ms set FLAG[$chan,$pol]=$val" + if test "$where" != ""; then + cmd="$cmd where $where" + fi + echo "taql '$cmd'" + if test $dry = 0; then + taql "$cmd" || err=1 + fi +fi + +if test $err != 0; then + echo "" + echo "Run as: taqlflagger [rank] ms [-dry] [flag|unflag] [selection1 ...]" + echo "The rank is a dummy argument meant for rundist." + echo "ms is the name of the MS to be (un)flagged." + echo "dry tells to do a dry run; it only shows the command to execute." + echo "flag or unflag tells what to do (default is flag)." + echo "The selections must be a TaQL WHERE part like" + echo " ANTENNA1=1" + echo " where multiple such parts are anded" + echo "or a polarization or channel selection like" + echo " pol=0 or chan=0:4" + echo " where the end is exclusive (a la python)" + echo "E.g." + echo " taqlflagger unflag ~/my.ms chan=0:32 pol=0 ANTENNA1=1 'ANTENNA2 in [1:4]'" + echo "unflags XX for channel 0 till 31 for baseline 1,1, 1,2 and 1,3" + echo "" + exit 1 +fi +exit 0