From 86c94e9402b29a3eebf1c29132c70cc37a29f48c Mon Sep 17 00:00:00 2001
From: Alexander Drabent <alex@tls-tautenburg.de>
Date: Fri, 24 Apr 2020 14:05:07 +0200
Subject: [PATCH] finish bandpass step

---
 lofar-cwl/steps/H5ParmCollector.cwl        |   5 +-
 lofar-cwl/steps/LoSoTo.Abs.cwl             |   3 +-
 lofar-cwl/steps/LoSoTo.Clip.cwl            |   3 +-
 lofar-cwl/steps/LoSoTo.Duplicate.cwl       |   6 +-
 lofar-cwl/steps/LoSoTo.Faraday.cwl         |   6 +-
 lofar-cwl/steps/LoSoTo.Flag.cwl            |   6 +-
 lofar-cwl/steps/LoSoTo.FlagStation.cwl     |   6 +-
 lofar-cwl/steps/LoSoTo.Flagextend.cwl      |   6 +-
 lofar-cwl/steps/LoSoTo.Interpolate.cwl     |   6 +-
 lofar-cwl/steps/LoSoTo.Lofarbeam.cwl       |   3 +-
 lofar-cwl/steps/LoSoTo.Norm.cwl            |   3 +-
 lofar-cwl/steps/LoSoTo.Plot.cwl            |   8 +-
 lofar-cwl/steps/LoSoTo.Polalign.cwl        |   6 +-
 lofar-cwl/steps/LoSoTo.Replicateonaxis.cwl |   2 +-
 lofar-cwl/steps/LoSoTo.Reset.cwl           |   3 +-
 lofar-cwl/steps/LoSoTo.Residual.cwl        |   6 +-
 lofar-cwl/steps/LoSoTo.Reweight.cwl        |   6 +-
 lofar-cwl/steps/LoSoTo.Smooth.cwl          |   1 +
 lofar-cwl/steps/LoSoTo.Splitleak.cwl       |   3 +-
 lofar-cwl/steps/LoSoTo.Structure.cwl       |   3 +-
 lofar-cwl/steps/applybeam.cwl              |  21 +--
 lofar-cwl/steps/applycal.cwl               |   4 +-
 steps/check_ateam_separation.cwl           |   0
 steps/concatenate_files.cwl                |   4 +-
 steps/h5parm_pointingname.cwl              |  47 ++++++
 steps/transfer_solutions.cwl               |  86 ++++++++++
 subworkflow/apply_calibrate_bp.cwl         |   8 +-
 subworkflow/apply_calibrate_pa.cwl         |   6 +-
 workflows/HBA_calibrator.cwl               |   5 +-
 workflows/prefactor_calibrator.cwl         |  12 +-
 workflows/prefactor_calibrator/bp.cwl      | 174 +++++++++++++++++++--
 workflows/prefactor_calibrator/fr.cwl      |   4 +-
 workflows/prefactor_calibrator/pa.cwl      |   4 +-
 workflows/prefactor_calibrator/prep.cwl    |   8 +-
 34 files changed, 401 insertions(+), 73 deletions(-)
 mode change 100755 => 100644 steps/check_ateam_separation.cwl
 create mode 100644 steps/h5parm_pointingname.cwl
 create mode 100644 steps/transfer_solutions.cwl

diff --git a/lofar-cwl/steps/H5ParmCollector.cwl b/lofar-cwl/steps/H5ParmCollector.cwl
index 31b1b945..5b6a2dcd 100755
--- a/lofar-cwl/steps/H5ParmCollector.cwl
+++ b/lofar-cwl/steps/H5ParmCollector.cwl
@@ -76,13 +76,14 @@ outputs:
     outputBinding:
       glob: $(inputs.outh5parmname)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.outh5parmname)-parm_collector_output.log
+      glob: '$(inputs.outh5parmname)-parm_collector_output*.log'
 label: H5parm_collector
 hints:
   - class: DockerRequirement
     dockerPull: 'lofareosc/prefactor:HBAcalibrator'
 stdout: $(inputs.outh5parmname)-parm_collector_output.log
+stderr: $(inputs.outh5parmname)-parm_collector_output_err.log
 requirements:
   - class: InlineJavascriptRequirement
\ No newline at end of file
diff --git a/lofar-cwl/steps/LoSoTo.Abs.cwl b/lofar-cwl/steps/LoSoTo.Abs.cwl
index 69ec253b..4ce89e2b 100755
--- a/lofar-cwl/steps/LoSoTo.Abs.cwl
+++ b/lofar-cwl/steps/LoSoTo.Abs.cwl
@@ -25,12 +25,13 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
diff --git a/lofar-cwl/steps/LoSoTo.Clip.cwl b/lofar-cwl/steps/LoSoTo.Clip.cwl
index 867699da..d9cda245 100644
--- a/lofar-cwl/steps/LoSoTo.Clip.cwl
+++ b/lofar-cwl/steps/LoSoTo.Clip.cwl
@@ -26,12 +26,13 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
diff --git a/lofar-cwl/steps/LoSoTo.Duplicate.cwl b/lofar-cwl/steps/LoSoTo.Duplicate.cwl
index 7fe56b03..55208333 100644
--- a/lofar-cwl/steps/LoSoTo.Duplicate.cwl
+++ b/lofar-cwl/steps/LoSoTo.Duplicate.cwl
@@ -25,6 +25,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -49,11 +50,12 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
 $namespaces:
   lofar: https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
 $schema:
diff --git a/lofar-cwl/steps/LoSoTo.Faraday.cwl b/lofar-cwl/steps/LoSoTo.Faraday.cwl
index 85d949b6..c015e412 100644
--- a/lofar-cwl/steps/LoSoTo.Faraday.cwl
+++ b/lofar-cwl/steps/LoSoTo.Faraday.cwl
@@ -27,6 +27,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -61,11 +62,12 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
 
 $schema:
   - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/lofar-cwl/steps/LoSoTo.Flag.cwl b/lofar-cwl/steps/LoSoTo.Flag.cwl
index 7e058ad1..302bc825 100644
--- a/lofar-cwl/steps/LoSoTo.Flag.cwl
+++ b/lofar-cwl/steps/LoSoTo.Flag.cwl
@@ -27,6 +27,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -102,10 +103,11 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
 $schema:
   - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/lofar-cwl/steps/LoSoTo.FlagStation.cwl b/lofar-cwl/steps/LoSoTo.FlagStation.cwl
index 42ee7fbe..be98dbb4 100644
--- a/lofar-cwl/steps/LoSoTo.FlagStation.cwl
+++ b/lofar-cwl/steps/LoSoTo.FlagStation.cwl
@@ -26,6 +26,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -101,10 +102,11 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
 $schema:
   - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/lofar-cwl/steps/LoSoTo.Flagextend.cwl b/lofar-cwl/steps/LoSoTo.Flagextend.cwl
index 20d48f24..c64fae49 100644
--- a/lofar-cwl/steps/LoSoTo.Flagextend.cwl
+++ b/lofar-cwl/steps/LoSoTo.Flagextend.cwl
@@ -28,6 +28,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -68,10 +69,11 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
 $schema:
   - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/lofar-cwl/steps/LoSoTo.Interpolate.cwl b/lofar-cwl/steps/LoSoTo.Interpolate.cwl
index 15d5f32e..f2fee5dc 100644
--- a/lofar-cwl/steps/LoSoTo.Interpolate.cwl
+++ b/lofar-cwl/steps/LoSoTo.Interpolate.cwl
@@ -29,6 +29,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -79,10 +80,11 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: logfile
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
 $schema:
   - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/lofar-cwl/steps/LoSoTo.Lofarbeam.cwl b/lofar-cwl/steps/LoSoTo.Lofarbeam.cwl
index ce421868..ffdc5dcc 100644
--- a/lofar-cwl/steps/LoSoTo.Lofarbeam.cwl
+++ b/lofar-cwl/steps/LoSoTo.Lofarbeam.cwl
@@ -25,12 +25,13 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
diff --git a/lofar-cwl/steps/LoSoTo.Norm.cwl b/lofar-cwl/steps/LoSoTo.Norm.cwl
index e9cadbd6..f193e64c 100644
--- a/lofar-cwl/steps/LoSoTo.Norm.cwl
+++ b/lofar-cwl/steps/LoSoTo.Norm.cwl
@@ -26,12 +26,13 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
diff --git a/lofar-cwl/steps/LoSoTo.Plot.cwl b/lofar-cwl/steps/LoSoTo.Plot.cwl
index a9e82d36..c8533dbe 100644
--- a/lofar-cwl/steps/LoSoTo.Plot.cwl
+++ b/lofar-cwl/steps/LoSoTo.Plot.cwl
@@ -24,6 +24,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -130,11 +131,16 @@ outputs:
     outputBinding:
       glob: "$(inputs.prefix)*.png"
   - id: logfile
+    type: File[]
+    outputBinding:
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
+  - id: parset
     type: File
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: parset.config
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log      
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log    
 
 
 $namespaces:
diff --git a/lofar-cwl/steps/LoSoTo.Polalign.cwl b/lofar-cwl/steps/LoSoTo.Polalign.cwl
index 0c53cba5..fa4bfe34 100755
--- a/lofar-cwl/steps/LoSoTo.Polalign.cwl
+++ b/lofar-cwl/steps/LoSoTo.Polalign.cwl
@@ -43,6 +43,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -89,8 +90,9 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
diff --git a/lofar-cwl/steps/LoSoTo.Replicateonaxis.cwl b/lofar-cwl/steps/LoSoTo.Replicateonaxis.cwl
index f7512ea6..3f953a16 100644
--- a/lofar-cwl/steps/LoSoTo.Replicateonaxis.cwl
+++ b/lofar-cwl/steps/LoSoTo.Replicateonaxis.cwl
@@ -42,7 +42,7 @@ arguments:
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
diff --git a/lofar-cwl/steps/LoSoTo.Reset.cwl b/lofar-cwl/steps/LoSoTo.Reset.cwl
index 887b0b81..ea6e06cb 100644
--- a/lofar-cwl/steps/LoSoTo.Reset.cwl
+++ b/lofar-cwl/steps/LoSoTo.Reset.cwl
@@ -24,12 +24,13 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
diff --git a/lofar-cwl/steps/LoSoTo.Residual.cwl b/lofar-cwl/steps/LoSoTo.Residual.cwl
index 7a8b8ba5..6642f7ec 100644
--- a/lofar-cwl/steps/LoSoTo.Residual.cwl
+++ b/lofar-cwl/steps/LoSoTo.Residual.cwl
@@ -24,6 +24,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -53,11 +54,12 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
 
 $namespaces:
   lofar: https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/lofar-cwl/steps/LoSoTo.Reweight.cwl b/lofar-cwl/steps/LoSoTo.Reweight.cwl
index 054add11..e8f02761 100644
--- a/lofar-cwl/steps/LoSoTo.Reweight.cwl
+++ b/lofar-cwl/steps/LoSoTo.Reweight.cwl
@@ -27,6 +27,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
@@ -78,10 +79,11 @@ outputs:
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
   - id: log
-    type: File
+    type: File[]
     outputBinding:
-      glob: $(inputs.input_h5parm.basename)-losoto.log
+      glob: '$(inputs.input_h5parm.basename)-losoto*.log'
 
 stdout: $(inputs.input_h5parm.basename)-losoto.log
+stderr: $(inputs.input_h5parm.basename)-losoto_err.log
 $schema:
   - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/lofar-cwl/steps/LoSoTo.Smooth.cwl b/lofar-cwl/steps/LoSoTo.Smooth.cwl
index d1b095a8..9117c041 100644
--- a/lofar-cwl/steps/LoSoTo.Smooth.cwl
+++ b/lofar-cwl/steps/LoSoTo.Smooth.cwl
@@ -30,6 +30,7 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
diff --git a/lofar-cwl/steps/LoSoTo.Splitleak.cwl b/lofar-cwl/steps/LoSoTo.Splitleak.cwl
index 34059375..c29e1da6 100644
--- a/lofar-cwl/steps/LoSoTo.Splitleak.cwl
+++ b/lofar-cwl/steps/LoSoTo.Splitleak.cwl
@@ -24,12 +24,13 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
diff --git a/lofar-cwl/steps/LoSoTo.Structure.cwl b/lofar-cwl/steps/LoSoTo.Structure.cwl
index cdf29c2f..639a7e7d 100644
--- a/lofar-cwl/steps/LoSoTo.Structure.cwl
+++ b/lofar-cwl/steps/LoSoTo.Structure.cwl
@@ -27,12 +27,13 @@ requirements:
 baseCommand: "losoto"
 
 arguments:
+  - '--verbose'
   - $(inputs.input_h5parm.basename)
   - parset.config
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
diff --git a/lofar-cwl/steps/applybeam.cwl b/lofar-cwl/steps/applybeam.cwl
index 6c7baccf..81559884 100644
--- a/lofar-cwl/steps/applybeam.cwl
+++ b/lofar-cwl/steps/applybeam.cwl
@@ -45,29 +45,30 @@ inputs:
     inputBinding:
       prefix: msout.storagemanager=
   - id: updateweights
-    type: boolean?
+    type: string?
     inputBinding:
       position: 0
-      prefix: -applybeam.updateweights=
+      prefix: applybeam.updateweights=
       separate: false
-  - id: beammode
+  - id: usechannelfreq
     type: string?
     inputBinding:
       position: 0
-      prefix: -applybeam.beammode=
+      prefix: applybeam.usechannelfreq=
       separate: false
-  - id: usechannelfreq
-    type: boolean?
+  - id: invert
+    type: string?
     inputBinding:
       position: 0
-      prefix: -applybeam.usechannelfreq=
+      prefix: applybeam.invert=
       separate: false
-  - id: invert
-    type: boolean?
+  - id: beammode
+    type: string?
     inputBinding:
       position: 0
-      prefix: -applybeam.invert=
+      prefix: applybeam.beammode=
       separate: false
+  
 outputs:
   - id: msout
     doc: Output Measurement Set
diff --git a/lofar-cwl/steps/applycal.cwl b/lofar-cwl/steps/applycal.cwl
index 49b7af68..03f258d0 100644
--- a/lofar-cwl/steps/applycal.cwl
+++ b/lofar-cwl/steps/applycal.cwl
@@ -54,10 +54,10 @@ inputs:
     inputBinding:
       prefix: msout.storagemanager=
   - id: updateweights
-    type: boolean?
+    type: string?
     inputBinding:
       position: 0
-      prefix: -applycal.updateweights=
+      prefix: applycal.updateweights=
       separate: false
 outputs:
   - id: msout
diff --git a/steps/check_ateam_separation.cwl b/steps/check_ateam_separation.cwl
old mode 100755
new mode 100644
diff --git a/steps/concatenate_files.cwl b/steps/concatenate_files.cwl
index eaae4ab1..ba9c5f64 100644
--- a/steps/concatenate_files.cwl
+++ b/steps/concatenate_files.cwl
@@ -2,7 +2,7 @@ class: CommandLineTool
 cwlVersion: v1.0
 $namespaces:
   sbg: 'https://www.sevenbridges.com/'
-id: bulk_rename
+id: concatfiles
 baseCommand:
   - bash 
   - bulk_rename.sh
@@ -21,7 +21,7 @@ outputs:
     type: File
     outputBinding:
       glob: "$(inputs.file_prefix).$(inputs.file_suffix)"
-label: bulk_rename
+label: concatfiles
 requirements:
   - class: InitialWorkDirRequirement
     listing:
diff --git a/steps/h5parm_pointingname.cwl b/steps/h5parm_pointingname.cwl
new file mode 100644
index 00000000..21a1b263
--- /dev/null
+++ b/steps/h5parm_pointingname.cwl
@@ -0,0 +1,47 @@
+class: CommandLineTool
+cwlVersion: v1.0
+$namespaces:
+  sbg: 'https://www.sevenbridges.com/'
+id: h5parm_pointingname
+baseCommand:
+  - python3
+  - /usr/local/bin/h5parm_pointingname.py
+inputs:
+  - id: h5parm
+    type: File
+    inputBinding:
+      position: 1
+    doc: H5parm whose pointing direction should be corrected the solutions should be transferred.
+  - id: solsetName
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--solsetName'
+    doc: Name of the input h5parm solution set
+  - id: pointing
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--pointing'
+    doc: Name of the output h5parm solution set
+outputs:
+  - id: outh5parm
+    type: File
+    outputBinding:
+      glob: $(inputs.h5parm.basename)
+  - id: log
+    type: File[]
+    outputBinding:
+      glob: 'h5parm_name*.log'
+stdout: h5parm_name.log
+stderr: h5parm_name_err.log
+label: h5parm_pointingname
+hints:
+  - class: DockerRequirement
+    dockerPull: 'lofareosc/prefactor:HBAcalibrator'
+requirements:
+  - class: InlineJavascriptRequirement
+  - class: InitialWorkDirRequirement
+    listing:
+      - entry: $(inputs.h5parm)
+        writable: true
\ No newline at end of file
diff --git a/steps/transfer_solutions.cwl b/steps/transfer_solutions.cwl
new file mode 100644
index 00000000..995a8d47
--- /dev/null
+++ b/steps/transfer_solutions.cwl
@@ -0,0 +1,86 @@
+class: CommandLineTool
+cwlVersion: v1.0
+$namespaces:
+  sbg: 'https://www.sevenbridges.com/'
+id: transfer_solutions
+baseCommand:
+  - python3
+  - /usr/local/bin/transfer_solutions.py
+inputs:
+  - default: output.h5
+    id: h5parm
+    type: File
+    inputBinding:
+      position: 1
+    doc: H5parm to which the solutions should be transferred.
+  - id: refh5parm
+    type:
+      - File?
+      - string?
+    default: '/data/solutions/3C48.h5'
+    inputBinding:
+      position: 0
+      prefix: '--refh5parm'
+    doc: Name of the h5parm from which the solutions should be transferred.
+  - id: insolset
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--insolset'
+    doc: Name of the input h5parm solution set
+  - id: outsolset
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--outsolset'
+    doc: Name of the output h5parm solution set
+  - id: insoltab
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--insoltab'
+    doc: Name of the input h5parm solution set
+  - id: outsoltab
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--outsoltab'
+    doc: Name of the output h5parm solution set
+  - id: antenna
+    type: string?
+    inputBinding:
+      position: 0
+      prefix: '--antenna'
+    doc: Regular expression of antenna solutions to be transferred
+  - id: parset
+    type: File?
+    inputBinding:
+      position: 0
+      prefix: '--parset'
+    doc: Parset for plotting diagnostic plots after transfer with LoSoTo
+outputs:
+  - id: outh5parm
+    type: File
+    outputBinding:
+      glob: $(inputs.h5parm.basename)
+  - id: log
+    type: File[]
+    outputBinding:
+      glob: 'transfer_solutions*.log'
+  - id: plots
+    type: File[]
+    outputBinding:
+      glob: "*.png"
+
+stdout: transfer_solutions.log
+stderr: transfer_solutions_err.log
+label: transfer_solutions
+hints:
+  - class: DockerRequirement
+    dockerPull: 'lofareosc/prefactor:HBAcalibrator'
+requirements:
+  - class: InlineJavascriptRequirement
+  - class: InitialWorkDirRequirement
+    listing:
+      - entry: $(inputs.h5parm)
+        writable: true
diff --git a/subworkflow/apply_calibrate_bp.cwl b/subworkflow/apply_calibrate_bp.cwl
index 3d08649c..0f21d792 100644
--- a/subworkflow/apply_calibrate_bp.cwl
+++ b/subworkflow/apply_calibrate_bp.cwl
@@ -95,7 +95,7 @@ steps:
       - id: msin_datacolumn
         default: CORRECTED_DATA
       - id: updateweights
-        default: true
+        default: 'True'
       - id: parmdb
         source: input_h5parm
       - id: msout_datacolumn
@@ -116,13 +116,13 @@ steps:
       - id: msout_datacolumn
         default: CORRECTED_DATA
       - id: updateweights
-        default: true
+        default: 'true'
       - id: invert
-        default: true
+        default: 'true'
       - id: beammode
         default: element
       - id: usechannelfreq
-        default: false
+        default: 'false'
       - id: msin
         source: applyBP/msout
       - id: type
diff --git a/subworkflow/apply_calibrate_pa.cwl b/subworkflow/apply_calibrate_pa.cwl
index f13f9282..02c9d1e5 100644
--- a/subworkflow/apply_calibrate_pa.cwl
+++ b/subworkflow/apply_calibrate_pa.cwl
@@ -89,13 +89,13 @@ steps:
       - id: msout_datacolumn
         default: CORRECTED_DATA
       - id: updateweights
-        default: true
+        default: 'true'
       - id: invert
-        default: true
+        default: 'true'
       - id: beammode
         default: element
       - id: usechannelfreq
-        default: false
+        default: 'false'
       - id: msin
         source: applyPA/msout
       - id: type
diff --git a/workflows/HBA_calibrator.cwl b/workflows/HBA_calibrator.cwl
index cd03d8c1..ad68fdbd 100644
--- a/workflows/HBA_calibrator.cwl
+++ b/workflows/HBA_calibrator.cwl
@@ -45,7 +45,7 @@ inputs:
     'sbg:x': -1000
     'sbg:y': -1000
   - id: ampRange
-    type: 'int[]?'
+    type: 'float[]?'
     default:
       - 0
       - 0
@@ -77,8 +77,7 @@ inputs:
     'sbg:x': -1000
     'sbg:y': -400
   - id: solutions2transfer
-    type: string?
-    default: /data/solutions/3C48.h5
+    type: File?
     'sbg:x': -1000
     'sbg:y': -300
   - id: antennas2transfer
diff --git a/workflows/prefactor_calibrator.cwl b/workflows/prefactor_calibrator.cwl
index 22c1943c..18d50c14 100644
--- a/workflows/prefactor_calibrator.cwl
+++ b/workflows/prefactor_calibrator.cwl
@@ -45,7 +45,7 @@ inputs:
     'sbg:x': -1000
     'sbg:y': -1000
   - id: ampRange
-    type: 'int[]?'
+    type: 'float[]?'
     default:
       - 0
       - 0
@@ -77,8 +77,7 @@ inputs:
     'sbg:x': -1000
     'sbg:y': -400
   - id: solutions2transfer
-    type: string?
-    default: /data/solutions/3C48.h5
+    type: File?
     'sbg:x': -1000
     'sbg:y': -300
   - id: antennas2transfer
@@ -289,6 +288,7 @@ steps:
       - id: check_Ateam_separation.png
       - id: msout
       - id: parset
+      - id: calibrator_name
     run: ./prefactor_calibrator/prep.cwl
     label: prep
     'sbg:x': 0
@@ -386,6 +386,12 @@ steps:
         source: do_smooth
       - id: insolutions
         source: fr/outsolutions
+      - id: solutions2transfer
+        source: solutions2transfer
+      - id: antennas2transfer
+        source: antennas2transfer
+      - id: calibrator_name
+        source: prep/calibrator_name
     out:
       - id: msout
       - id: outsolutions
diff --git a/workflows/prefactor_calibrator/bp.cwl b/workflows/prefactor_calibrator/bp.cwl
index 7a7d1bc7..a5019e8f 100644
--- a/workflows/prefactor_calibrator/bp.cwl
+++ b/workflows/prefactor_calibrator/bp.cwl
@@ -5,6 +5,10 @@ label: BP
 $namespaces:
   sbg: 'https://www.sevenbridges.com/'
 inputs:
+  - id: calibrator_name
+    type: string
+    'sbg:x': -1000
+    'sbg:y': -700
   - id: ampRange
     type: 'float[]?'
     'sbg:x': -1000
@@ -43,8 +47,12 @@ inputs:
     type: File
     'sbg:x': -1000
     'sbg:y': 200
+  - id: solutions2transfer
+    type: File?
+    'sbg:x': -1000
+    'sbg:y': 300
   - id: inh5parm_logfile
-    type: File
+    type: File[]
     'sbg:x': -1000
     'sbg:y': 400
   - id: do_smooth
@@ -56,6 +64,10 @@ inputs:
     type: File
     'sbg:x': -1000
     'sbg:y': 600
+  - id: antennas2transfer
+    type: string?
+    'sbg:x': -1000
+    'sbg:y': 700
 outputs:
   - id: outh5parm
     outputSource:
@@ -76,13 +88,14 @@ outputs:
       - losoto_plot_B1/output_plots
       - losoto_plot_B2/output_plots
       - losoto_plot_B3/output_plots
-    type: 'File[]'
+      - transfer_solutions/plots
+    type: 'File[]?'
     linkMerge: merge_flattened
     'sbg:x': 1000
     'sbg:y': 0
   - id: outsolutions
     outputSource:
-      - write_solutions/outh5parm
+      - transfer_solutions/outh5parm
     type: File
     'sbg:x': 1000
     'sbg:y': 100
@@ -101,7 +114,7 @@ outputs:
   - id: outh5parm_logfile
     outputSource:
       - h5parm_collector/log
-    type: File
+    type: File[]
     'sbg:x': 1000
     'sbg:y': 300
 steps:
@@ -147,7 +160,7 @@ steps:
       - id: logfile
     run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
     label: losoto_plot_A1
-    'sbg:x': 0
+    'sbg:x': -200
     'sbg:y': -200
   - id: losoto_plot_A2
     in:
@@ -170,7 +183,7 @@ steps:
       - id: logfile
     run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
     label: losoto_plot_A2
-    'sbg:x': 0
+    'sbg:x': -200
     'sbg:y': -100
   - id: losoto_plot_B1
     in:
@@ -193,7 +206,7 @@ steps:
       - id: logfile
     run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
     label: losoto_plot_B1
-    'sbg:x': 0
+    'sbg:x': -200
     'sbg:y': 0
   - id: losoto_plot_B2
     in:
@@ -222,7 +235,7 @@ steps:
       - id: logfile
     run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
     label: losoto_plot_B2
-    'sbg:x': 0
+    'sbg:x': -200
     'sbg:y': 100
   - id: losoto_plot_B3
     in:
@@ -249,8 +262,84 @@ steps:
       - id: logfile
     run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
     label: losoto_plot_B3
-    'sbg:x': 0
+    'sbg:x': -200
     'sbg:y': 200
+  - id: losoto_plot_B1_trans
+    in:
+      - id: input_h5parm
+        source: bandpass/output_h5parm
+      - id: soltab
+        default: sol000/bandpass
+      - id: axesInPlot
+        default:
+          - time
+          - freq
+      - id: axisInTable
+        default: ant
+      - id: plotFlag
+        default: true
+      - id: prefix
+        default: bandpass_transfer_
+    out:
+      - id: parset
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_B1_trans
+    'sbg:x': -200
+    'sbg:y': 300
+  - id: losoto_plot_B2_trans
+    in:
+      - id: input_h5parm
+        source: bandpass/output_h5parm
+      - id: soltab
+        default: sol000/bandpass
+      - id: axesInPlot
+        default:
+          - freq
+      - id: axisInTable
+        default: ant
+      - id: axisInCol
+        default: pol
+      - id: plotFlag
+        default: true
+      - id: time.minmaxstep
+        default:
+          - 0
+          - 1e20
+          - 500000
+      - id: prefix
+        default: bandpass_transfer_
+    out:
+      - id: parset
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_B2_trans
+    'sbg:x': -200
+    'sbg:y': 400
+  - id: losoto_plot_B3_trans
+    in:
+      - id: input_h5parm
+        source: bandpass/output_h5parm
+      - id: soltab
+        default: sol000/bandpass
+      - id: axesInPlot
+        default:
+          - freq
+      - id: axisInCol
+        default: ant
+      - id: plotFlag
+        default: true
+      - id: time.minmaxstep
+        default:
+          - 0
+          - 1e20
+          - 500000
+      - id: prefix
+        default: bbandpass_transfer_
+    out:
+      - id: parset
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_B3_trans
+    'sbg:x': -200
+    'sbg:y': 500
   - id: concat_logfiles_bp
     in:
       - id: file_list
@@ -264,6 +353,8 @@ steps:
           - losoto_plot_B2/logfile
           - losoto_plot_B3/logfile
           - write_solutions/log
+          - h5parm_pointingname/log
+          - transfer_solutions/log
       - id: file_prefix
         default: losoto_bandpass
     out:
@@ -293,8 +384,8 @@ steps:
       - id: log
     run: ../../steps/h5parmcat.cwl
     label: write_solutions
-    'sbg:x': 0
-    'sbg:y': 500
+    'sbg:x': -200
+    'sbg:y': 700
   - id: apply_calibrate_bp
     in:
       - id: msin
@@ -306,7 +397,7 @@ steps:
       - id: propagatesolutions
         source: propagatesolutions
       - id: input_h5parm
-        source: write_solutions/outh5parm
+        source: transfer_solutions/outh5parm
     out:
       - id: msout
       - id: BLsmooth.log
@@ -404,6 +495,65 @@ steps:
     label: H5parm_collector
     'sbg:x': 750
     'sbg:y': -300
+  - id: h5parm_pointingname
+    in:
+      - id: h5parm
+        source: write_solutions/outh5parm
+      - id: solsetName
+        default: calibrator
+      - id: pointing
+        source: calibrator_name
+    out:
+      - id: outh5parm
+      - id: log
+    run: ../../steps/h5parm_pointingname.cwl
+    label: h5parm_pointingname
+    'sbg:x': 0
+    'sbg:y': 300
+  - id: transfer_solutions
+    in:
+      - id: h5parm
+        source: h5parm_pointingname/outh5parm
+      - id: refh5parm
+        source: solutions2transfer
+      - id: insolset
+        default: calibrator
+      - id: outsolset
+        default: calibrator
+      - id: insoltab
+        default: bandpass
+      - id: outsoltab
+        default: bandpass
+      - id: antenna
+        source: antennas2transfer
+      - id: parset
+        source: concat_parset/output
+    out:
+      - id: outh5parm
+      - id: log
+      - id: plots
+    run: ../../steps/transfer_solutions.cwl
+    label: transfer_solutions
+    'sbg:x': 200
+    'sbg:y': 300
+  - id: concat_parset
+    in:
+      - id: file_list
+        linkMerge: merge_flattened
+        source:
+          - losoto_plot_B1_trans/parset
+          - losoto_plot_B2_trans/parset
+          - losoto_plot_B3_trans/parset
+      - id: file_prefix
+        default: losoto
+      - id: file_suffix
+        default: parset
+    out:
+      - id: output
+    run: ../../steps/concatenate_files.cwl
+    label: concat_parset
+    'sbg:x': 0
+    'sbg:y': 500
 requirements:
   - class: SubworkflowFeatureRequirement
   - class: ScatterFeatureRequirement
diff --git a/workflows/prefactor_calibrator/fr.cwl b/workflows/prefactor_calibrator/fr.cwl
index 6c8a01c7..b907a043 100644
--- a/workflows/prefactor_calibrator/fr.cwl
+++ b/workflows/prefactor_calibrator/fr.cwl
@@ -28,7 +28,7 @@ inputs:
     'sbg:x': -1000
     'sbg:y': 100
   - id: inh5parm_logfile
-    type: File
+    type: File[]
     'sbg:x': -1000
     'sbg:y': 200
   - id: do_smooth
@@ -85,7 +85,7 @@ outputs:
   - id: outh5parm_logfile
     outputSource:
       - h5parm_collector/log
-    type: File
+    type: File[]
     'sbg:x': 1000
     'sbg:y': 300
 steps:
diff --git a/workflows/prefactor_calibrator/pa.cwl b/workflows/prefactor_calibrator/pa.cwl
index 7ff28e55..6a6e66cd 100644
--- a/workflows/prefactor_calibrator/pa.cwl
+++ b/workflows/prefactor_calibrator/pa.cwl
@@ -28,7 +28,7 @@ inputs:
     'sbg:x': -1000
     'sbg:y': 100
   - id: inh5parm_logfile
-    type: File
+    type: File[]
     'sbg:x': -1000
     'sbg:y': 200
   - id: do_smooth
@@ -82,7 +82,7 @@ outputs:
   - id: outh5parm_logfile
     outputSource:
       - h5parm_collector/log
-    type: File
+    type: File[]
     'sbg:x': 1000
     'sbg:y': 300
 steps:
diff --git a/workflows/prefactor_calibrator/prep.cwl b/workflows/prefactor_calibrator/prep.cwl
index 950f70d6..313b1474 100644
--- a/workflows/prefactor_calibrator/prep.cwl
+++ b/workflows/prefactor_calibrator/prep.cwl
@@ -134,10 +134,16 @@ outputs:
     type: 'File[]'
     'sbg:x': 1000
     'sbg:y': 200
+  - id: calibrator_name
+    outputSource:
+      - find_skymodel_cal/model_name
+    type: string
+    'sbg:x': 1000
+    'sbg:y': 400
   - id: outh5parm_logfile
     outputSource:
       - h5parm_collector/log
-    type: File
+    type: File[]
     'sbg:x': 1000
     'sbg:y': 650
   - id: logfiles
-- 
GitLab