From b69e4a0e1876779d491b19e0c4a3390781f8342b Mon Sep 17 00:00:00 2001
From: Ger van Diepen <diepen@astron.nl>
Date: Thu, 22 Mar 2012 11:13:57 +0000
Subject: [PATCH] Task #3054 Made it work on CEP2

---
 CEP/MS/src/expandcalps |  2 --
 CEP/MS/src/mstools.py  | 10 +++++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/CEP/MS/src/expandcalps b/CEP/MS/src/expandcalps
index 9532e10a8be..12538cc74c8 100755
--- a/CEP/MS/src/expandcalps
+++ b/CEP/MS/src/expandcalps
@@ -33,8 +33,6 @@ if __name__ == "__main__":
     if len(sys.argv) > 4  and  len(sys.argv[4]) > 0:
         outname = [sys.argv[4]]
     # Expand the parset.
-    print inname, outname
-    exit
     lmt.expandps (sys.argv[1], sys.argv[2],
                   {'in': [(inname, 'Input_Correlated')],
                    'out': [(outname, 'Output_InstrumentModel')]})
diff --git a/CEP/MS/src/mstools.py b/CEP/MS/src/mstools.py
index b249d3392b7..cb0f383dcbf 100644
--- a/CEP/MS/src/mstools.py
+++ b/CEP/MS/src/mstools.py
@@ -267,9 +267,9 @@ def expandps (parsetin, parsetout, keymap, nsubbands=0, nodeindex=0):
     ps = lofar.parameterset.parameterset (parsetin)
     pskeys = ps.keys()
     # See if nsubbands parameter is given; otherwise set to 1.
-    havesubbands = true
+    havesubbands = True
     if nsubbands <= 0:
-        havesubbands = false
+        havesubbands = False
         nsubbands = 1
         # Check and initialize.
     if nodeindex < 0  or  nodeindex >= nsubbands:
@@ -290,13 +290,14 @@ def expandps (parsetin, parsetout, keymap, nsubbands=0, nodeindex=0):
                 raise KeyError, "keyword " + keyin + " not found in parset " + parsetin
             # Get the file name pattern
             patterns = ps.getStringVector(keyin)
+            ps.remove (keyin)
         else:
             patterns = keyin
         locs  = []
         names = []
         for patt in patterns:
             # Get all nodes and file names
-            (nodes,files) = findDirs(ps.getString(keyin))
+            (nodes,files) = findDirs(patt)
             ##(nodes,files) = (['locus1','locus2'], ['/data/L1/L1a.MS','/data/L1/L1b.MS'])
             # Split into location (node:dir/) and basename.
             for i in range(len(files)):
@@ -315,7 +316,6 @@ def expandps (parsetin, parsetout, keymap, nsubbands=0, nodeindex=0):
         newkey = 'ObsSW.Observation.DataProducts.' + keyout
         ps.add (newkey + '.locations', str(locs));
         ps.add (newkey + '.filenames', str(names));
-        ps.remove (keyin)
 
     # Write nsubbands if needed.
     if havesubbands:
@@ -333,6 +333,7 @@ def expandps (parsetin, parsetout, keymap, nsubbands=0, nodeindex=0):
                 if keyin not in pskeys:
                     raise KeyError, "keyword " + keyin + " not found in parset " + parsetin
                 name = ps.getString(keyin)
+                ps.remove (keyin)
             else:
                 if len(keyin) != 1:
                     raise KeyError, "Output key " + keyin + " is not a string, thus should be a sequence of length 1"
@@ -361,7 +362,6 @@ def expandps (parsetin, parsetout, keymap, nsubbands=0, nodeindex=0):
             newkey = 'ObsSW.Observation.DataProducts.' + keyout
             ps.add (newkey + '.locations', str(locs));
             ps.add (newkey + '.filenames', str(names));
-            ps.remove (keyin)
 
     # Check if all keymap keywords have been processed.
     if nrproc != len(keymap):
-- 
GitLab