From 526658462120c63e2daf38a138ba07ce19362ecc Mon Sep 17 00:00:00 2001
From: Alexander Drabent <alex@tls-tautenburg.de>
Date: Mon, 4 Dec 2023 09:56:08 +0100
Subject: [PATCH] fix predict step in LBA_target

---
 steps/wsclean.cwl                          |  9 ++++++-
 workflows/linc_target/imaging_subtract.cwl | 28 +++++++++++++++++++---
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/steps/wsclean.cwl b/steps/wsclean.cwl
index e435d8bb..42c08c02 100644
--- a/steps/wsclean.cwl
+++ b/steps/wsclean.cwl
@@ -265,7 +265,9 @@ inputs:
       shellQuote: false
   - id: image_name
     default: 'pointing'
-    type: string?
+    type:
+      - string?
+      - File?
     inputBinding:
       position: 1
       prefix: '-name'
@@ -284,6 +286,11 @@ inputs:
       position: 1
       prefix: '-predict'
       shellQuote: false
+  - id: padding
+    type: float?
+    inputBinding:
+      position: 1
+      prefix: -padding
   - id: baseline_averaging
     default: false
     type: float?
diff --git a/workflows/linc_target/imaging_subtract.cwl b/workflows/linc_target/imaging_subtract.cwl
index 8f4e6264..74e3b942 100644
--- a/workflows/linc_target/imaging_subtract.cwl
+++ b/workflows/linc_target/imaging_subtract.cwl
@@ -233,7 +233,7 @@ steps:
       - id: tempdir
         source: wsclean_tmpdir
       - id: do_predict
-        default: true
+        default: false
       - id: reuse_dirty
         source: make_mask_image/dirty_image
       - id: reuse_psf
@@ -245,10 +245,30 @@ steps:
       - id: logfile
     run: ../../steps/wsclean.cwl
     label: image_predict
+  - id: predict_wsclean
+    in:
+      - id: msin
+        source: make_mask_image/msout # workaround for CWL bug (https://github.com/common-workflow-language/cwltool/issues/1785)
+      - id: image_name
+        source: image_predict/image
+      - id: padding
+        default: 1.8
+      - id: channels-out
+        source: total_bandwidth
+        valueFrom: '$(Math.round(self/4.e6) > 0 ? Math.round(self/4.e6) : 1)'
+      - id: tempdir
+        source: wsclean_tmpdir
+      - id: do_predict
+        default: true
+    out:
+      - id: msout
+      - id: logfile
+    run: ../../steps/wsclean.cwl
+    label: predict_wsclean
   - id: subtract_model
     in:
       - id: msin
-        source: image_predict/msout
+        source: predict_wsclean/msout
       - id: command
         default: "set CORRECTED_DATA = CORRECTED_DATA - MODEL_DATA"
     out:
@@ -559,7 +579,6 @@ steps:
           - make_mask_image/logfile
           - make_mask/logfile
           - blank_image_reg/logfile
-          - image_predict/logfile
         linkMerge: merge_flattened
         pickValue: all_non_null
       - id: file_prefix
@@ -588,6 +607,8 @@ steps:
     in:
       - id: file_list
         source:
+          - image_predict/logfile
+          - predict_wsclean/logfile
           - merge_array_files/output
         linkMerge: merge_flattened
       - id: file_prefix
@@ -600,6 +621,7 @@ steps:
     in:
       - id: file_list
         source:
+          - image_tmp/logfile
           - make_beam_reg/logfile
           - blank_image_reg_1/logfile
           - blank_image_reg_2/logfile
-- 
GitLab