From df6cb7260d00e87494df64376e7105cefd1eb83a Mon Sep 17 00:00:00 2001
From: Marcel Loose <loose@astron.nl>
Date: Fri, 8 Feb 2013 15:55:48 +0000
Subject: [PATCH] Task #4124: The MSSS calibrator/target pipelines now read the
 source model to be used for demixing from the parset-file, instead of using
 the hard-coded Ateam_LBA_CC.skymodel

---
 .../sip/bin/msss_calibrator_pipeline.py       | 24 ++++++++++++-------
 .../recipes/sip/bin/msss_target_pipeline.py   | 21 ++++++++++++----
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/CEP/Pipeline/recipes/sip/bin/msss_calibrator_pipeline.py b/CEP/Pipeline/recipes/sip/bin/msss_calibrator_pipeline.py
index 6a9ca3014ba..be1327c0fed 100755
--- a/CEP/Pipeline/recipes/sip/bin/msss_calibrator_pipeline.py
+++ b/CEP/Pipeline/recipes/sip/bin/msss_calibrator_pipeline.py
@@ -208,19 +208,27 @@ class msss_calibrator_pipeline(control):
                 suffix='.dppp.parmdb')['mapfile']
 
         # Create a sourcedb to be used by the demixing phase of DPPP
-        # The path to the A-team sky model is currently hard-coded.
-        # Run makesourcedb on skymodel files for calibrator source(s) and the
-        # Ateam, which are to be stored in a standard place ($LOFARROOT/share)
+        # The user-supplied sky model can either be a name, in which case the
+        # pipeline will search for a file <name>.skymodel in the default search
+        # path $LOFARROOT/share/pipeline/skymodels; or a full path.
+        # It is an error if the file does not exist.
+        skymodel = py_parset.getString('PreProcessing.SkyModel')
+        if not os.path.isabs(skymodel):
+            skymodel = os.path.join(
+                # This should really become os.environ['LOFARROOT']
+                self.config.get('DEFAULT', 'lofarroot'),
+                'share', 'pipeline', 'skymodels', skymodel + '.skymodel'
+            )
+        if not os.path.isfile(skymodel):
+            raise PipelineException("Skymodel %s does not exist" % skymodel)
         with duration(self, "setupsourcedb"):
             sourcedb_mapfile = self.run_task(
                 "setupsourcedb", data_mapfile,
-                skymodel=os.path.join(
-                    self.config.get('DEFAULT', 'lofarroot'),
-                    'share', 'pipeline', 'skymodels', 'Ateam_LBA_CC.skymodel'),
-                                             # TODO: LBA skymodel!! 
                 mapfile=os.path.join(mapfile_dir, 'dppp.sourcedb.mapfile'),
+                skymodel=skymodel,
                 suffix='.dppp.sourcedb',
-                type='blob')['mapfile']
+                type='blob'
+            )['mapfile']
 
         # *********************************************************************
         # 3. Run NDPPP to demix the A-Team sources
diff --git a/CEP/Pipeline/recipes/sip/bin/msss_target_pipeline.py b/CEP/Pipeline/recipes/sip/bin/msss_target_pipeline.py
index a3c8b49da1e..50773647167 100755
--- a/CEP/Pipeline/recipes/sip/bin/msss_target_pipeline.py
+++ b/CEP/Pipeline/recipes/sip/bin/msss_target_pipeline.py
@@ -313,14 +313,25 @@ class msss_target_pipeline(control):
             parmdb_mapfile = self.run_task("setupparmdb", data_mapfile)['mapfile']
 
         # Create a sourcedb to be used by the demixing phase of DPPP
-        # The path to the A-team sky model is currently hard-coded.
+        # The user-supplied sky model can either be a name, in which case the
+        # pipeline will search for a file <name>.skymodel in the default search
+        # path $LOFARROOT/share/pipeline/skymodels; or a full path.
+        # It is an error if the file does not exist.
+        skymodel = py_parset.getString('PreProcessing.SkyModel')
+        if not os.path.isabs(skymodel):
+            skymodel = os.path.join(
+                # This should really become os.environ['LOFARROOT']
+                self.config.get('DEFAULT', 'lofarroot'),
+                'share', 'pipeline', 'skymodels', skymodel + '.skymodel'
+            )
+        if not os.path.isfile(skymodel):
+            raise PipelineException("Skymodel %s does not exist" % skymodel)
         with duration(self, "setupsourcedb"):
             sourcedb_mapfile = self.run_task(
                 "setupsourcedb", data_mapfile,
-                skymodel=os.path.join(
-                    self.config.get('DEFAULT', 'lofarroot'),
-                    'share', 'pipeline', 'skymodels', 'Ateam_LBA_CC.skymodel'
-                )
+                skymodel=skymodel,
+                suffix='.dppp.sourcedb',
+                type='blob'
             )['mapfile']
 
         # *********************************************************************
-- 
GitLab