From b2a87250539766c9923eaee66c25a357a38b87d8 Mon Sep 17 00:00:00 2001 From: Ger van Diepen <diepen@astron.nl> Date: Fri, 22 Jan 2010 08:37:58 +0000 Subject: [PATCH] bug 1446: Created script taqlflagger to easily (un)flag baselines, etc. --- .gitattributes | 1 + CEP/DP3/DPPP/src/CMakeLists.txt | 1 + CEP/DP3/DPPP/src/Makefile.am | 2 +- CEP/DP3/DPPP/src/taqlflagger | 88 +++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100755 CEP/DP3/DPPP/src/taqlflagger diff --git a/.gitattributes b/.gitattributes index 7260158f68e..5a0103def63 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 46077103a47..bbc3ca92f31 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 6046b8fbb54..93784e48353 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 00000000000..6a4c4e8f0a9 --- /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 -- GitLab