From 5a5b38e4b55145e0c40c2cf6f8c039e1bc7e8328 Mon Sep 17 00:00:00 2001
From: Alexander Drabent <alex@tls-tautenburg.de>
Date: Fri, 17 Apr 2020 15:51:56 +0200
Subject: [PATCH] add FR step

Former-commit-id: 10e38234f1a15e9c2fa893d6030980bc192684d0
---
 lofar-cwl/steps/H5ParmCollector.cwl   |   8 +-
 lofar-cwl/steps/LoSoTo.Faraday.cwl    |  12 +-
 steps/h5parmcat.cwl                   |  55 ++--
 subworkflow/apply_calibrate_fr.cwl    | 115 +++++++
 subworkflow/faraday_rotation.cwl      | 174 ++++-------
 workflows/prefactor_calibrator.cwl    |  44 ++-
 workflows/prefactor_calibrator/fr.cwl | 428 ++++++++++++++++++++++++++
 workflows/prefactor_calibrator/pa.cwl |   7 +-
 8 files changed, 686 insertions(+), 157 deletions(-)
 create mode 100644 subworkflow/apply_calibrate_fr.cwl
 create mode 100644 workflows/prefactor_calibrator/fr.cwl

diff --git a/lofar-cwl/steps/H5ParmCollector.cwl b/lofar-cwl/steps/H5ParmCollector.cwl
index 0ae9cf7b..31b1b945 100755
--- a/lofar-cwl/steps/H5ParmCollector.cwl
+++ b/lofar-cwl/steps/H5ParmCollector.cwl
@@ -12,7 +12,9 @@ baseCommand:
   - H5parm_collector.py
 inputs:
   - id: h5parmFiles
-    type: 'File[]'
+    type:
+      - 'File[]'
+      - File
     format: lofar:#H5Parm
     inputBinding:
       position: 0
@@ -37,11 +39,13 @@ inputs:
       position: 0
       prefix: '--insoltab'
     doc: Output solset name
-
   - default: output.h5
     id: outh5parmname
     type: string
     doc: Output h5parm name
+    inputBinding:
+      position: 0
+      prefix: '--outh5parm'
   - id: squeeze
     type: boolean
     default: false
diff --git a/lofar-cwl/steps/LoSoTo.Faraday.cwl b/lofar-cwl/steps/LoSoTo.Faraday.cwl
index e3092536..85d949b6 100644
--- a/lofar-cwl/steps/LoSoTo.Faraday.cwl
+++ b/lofar-cwl/steps/LoSoTo.Faraday.cwl
@@ -32,7 +32,7 @@ arguments:
 
 hints:
   DockerRequirement:
-    dockerPull: lofareosc/lofar-pipeline-ci:latest
+    dockerPull: lofareosc/prefactor:HBAcalibrator
 
 inputs:
   - id: input_h5parm
@@ -41,6 +41,9 @@ inputs:
   - id: soltab
     type: string
     doc: "Solution table"
+  - id: soltabout
+    type: string?
+    doc: output table name (same solset)
   - id: refAnt
     type: string?
     doc:  Reference antenna, by default the first.
@@ -57,5 +60,12 @@ outputs:
     format: lofar:#H5Parm
     outputBinding:
       glob: $(inputs.input_h5parm.basename)
+  - id: log
+    type: File
+    outputBinding:
+      glob: $(inputs.input_h5parm.basename)-losoto.log
+
+stdout: $(inputs.input_h5parm.basename)-losoto.log
+
 $schema:
   - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/steps/h5parmcat.cwl b/steps/h5parmcat.cwl
index bd3861c1..861d08e7 100644
--- a/steps/h5parmcat.cwl
+++ b/steps/h5parmcat.cwl
@@ -1,19 +1,15 @@
 class: CommandLineTool
 cwlVersion: v1.0
 $namespaces:
+  lofar: 'https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl'
   sbg: 'https://www.sevenbridges.com/'
-  lofar: https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
-$schema:
-  - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
-
-id: h5parmcat
-
+id: h5parm_cat
 baseCommand:
   - H5parm_collector.py
 inputs:
-  - id: h5parmFiles
+  - format: 'lofar:#H5Parm'
+    id: h5parmFile
     type: File
-    format: lofar:#H5Parm
     inputBinding:
       position: 0
     doc: List of h5parm files
@@ -37,17 +33,13 @@ inputs:
       position: 0
       prefix: '--insoltab'
     doc: Output solset name
-
-  - default: cal_solutions.h5
-    id: outh5parmname
-    type: string
-    inputBinding:
-      position: 0
-      prefix: '--outh5parm'
+  - default: output.h5
+    id: input_file
+    type: File
     doc: Output h5parm name
-  - id: squeeze
+  - default: false
+    id: squeeze
     type: boolean
-    default: false
     inputBinding:
       position: 0
       prefix: '-q'
@@ -59,29 +51,38 @@ inputs:
       position: 0
       prefix: '-v'
     doc: verbose output
-  - default: true
+  - default: false
     id: clobber
     type: boolean
     inputBinding:
       position: 0
       prefix: '-c'
     doc: overwrite output
-    
 outputs:
   - id: outh5parm
     doc: Output h5parm
     type: File
-    format: lofar:#H5Parm
     outputBinding:
-      glob: $(inputs.outh5parmname)
+      glob: $(inputs.input_file.basename)
+    format: lofar:#H5Parm
   - id: log
     type: File
     outputBinding:
-      glob: $(inputs.outh5parmname)-parm_collector_output.log
-label: H5parmcat
+      glob: parm_collector_output.log
+label: h5parm_cat
+arguments:
+  - position: 0
+    prefix: '-o'
+    valueFrom: $(inputs.input_file.basename)
+requirements:
+  - class: InitialWorkDirRequirement
+    listing:
+      - entry: $(inputs.input_file)
+        writable: true
+  - class: InlineJavascriptRequirement
 hints:
   - class: DockerRequirement
-    dockerPull: 'lofareosc/prefactor:HBAcalibrator'
-stdout: $(inputs.outh5parmname)-parm_collector_output.log
-requirements:
-  - class: InlineJavascriptRequirement
\ No newline at end of file
+    dockerPull: lofareosc/prefactor:HBAcalibrator
+stdout: parm_collector_output.log
+$schema:
+  - 'https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl'
diff --git a/subworkflow/apply_calibrate_fr.cwl b/subworkflow/apply_calibrate_fr.cwl
new file mode 100644
index 00000000..f04c3dd0
--- /dev/null
+++ b/subworkflow/apply_calibrate_fr.cwl
@@ -0,0 +1,115 @@
+class: Workflow
+cwlVersion: v1.0
+id: apply_calibrate
+label: apply_calibrate
+$namespaces:
+  sbg: 'https://www.sevenbridges.com/'
+inputs:
+  - id: msin
+    type: Directory
+    'sbg:x': -1000
+    'sbg:y': -200
+  - id: do_smooth
+    type: boolean
+    'sbg:x': -1000
+    'sbg:y': -100
+  - id: flagunconverged
+    type: boolean
+    'sbg:x': -1000
+    'sbg:y': 100
+  - id: propagatesolutions
+    type: boolean
+    'sbg:x': -1000
+    'sbg:y': 200
+  - id: input_h5parm
+    type: File
+    'sbg:x': -1000
+    'sbg:y': 300
+outputs:
+  - id: msout
+    outputSource:
+      - calib_cal/msout
+    type: Directory
+    'sbg:x': 1000
+    'sbg:y': -200
+  - id: BLsmooth.log
+    outputSource:
+      - BLsmooth/logfile
+    type: File
+    'sbg:x': 1000
+    'sbg:y': -100
+  - id: apply_cal.log
+    outputSource:
+      - applyFR/logfile
+    type: File
+    'sbg:x': 1000
+    'sbg:y': 0
+  - id: calib_cal.log
+    outputSource:
+      - calib_cal/logfile
+    type: File
+    'sbg:x': 1000
+    'sbg:y': 100
+  - id: outh5parm
+    outputSource:
+      - calib_cal/h5parm
+    type: File
+    'sbg:x': 1000
+    'sbg:y': 200
+steps:
+  - id: applyFR
+    in:
+      - id: msin
+        source: msin
+      - id: msin_datacolumn
+        default: CORRECTED_DATA
+      - id: parmdb
+        source: input_h5parm
+      - id: msout_datacolumn
+        default: CORRECTED_DATA
+      - id: correction
+        default: faraday
+    out:
+      - id: msout
+      - id: logfile
+    run: ../lofar-cwl/steps/applycal.cwl
+    label: applyFR
+    'sbg:x': -400
+    'sbg:y': 0
+  - id: BLsmooth
+    in:
+      - id: msin
+        source: applyFR/msout
+      - id: do_smooth
+        source: do_smooth
+      - id: in_column_name
+        default: CORRECTED_DATA
+    out:
+      - id: msout
+      - id: logfile
+    run: ../steps/blsmooth.cwl
+    label: BLsmooth
+    'sbg:x': 0
+    'sbg:y': 0
+  - id: calib_cal
+    in:
+      - id: msin
+        source: BLsmooth/msout
+      - id: msin_datacolumn
+        default: SMOOTHED_DATA
+      - id: msin_modelcolum
+        default: MODEL_DATA
+      - id: flagunconverged
+        source: flagunconverged
+      - id: propagate_solutions
+        source: propagatesolutions
+      - id: mode
+        default: diagonal
+    out:
+      - id: msout
+      - id: h5parm
+      - id: logfile
+    run: ../lofar-cwl/steps/ddecal.cwl
+    'sbg:x': 500
+    'sbg:y': 0
+requirements: []
diff --git a/subworkflow/faraday_rotation.cwl b/subworkflow/faraday_rotation.cwl
index 3f3fec4e..493146b3 100644
--- a/subworkflow/faraday_rotation.cwl
+++ b/subworkflow/faraday_rotation.cwl
@@ -4,147 +4,81 @@ id: faraday_rotation
 label: faraday_rotation
 $namespaces:
   sbg: 'https://www.sevenbridges.com/'
+  lofar: https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
+$schema:
+  - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
 inputs:
-  - id: msin
-    type: 'Directory[]'
-    'sbg:x': -1017.7406616210938
-    'sbg:y': -230.76498413085938
-  - id: do_smooth
-    type: boolean
-    'sbg:x': -892.199951171875
-    'sbg:y': 63.25977325439453
-  - id: propagate_solutions
-    type: boolean
-    'sbg:x': -862.6722412109375
-    'sbg:y': -476.848876953125
-  - id: flagunconverged
-    type: boolean
-    'sbg:x': -719.998046875
-    'sbg:y': 88.66199493408203
   - id: refAnt
     type: string?
-    'sbg:x': -468.52337646484375
-    'sbg:y': -415.06396484375
+    'sbg:x': -451.3746643066406
+    'sbg:y': -493.92510986328125
+  - id: input_h5parm
+    type: File
+    'sbg:x': -743.1871948242188
+    'sbg:y': -316.5615234375
 outputs:
-  - id: msout
+  - id: output_h5parm
     outputSource:
-      - applycal/msout
-    type: 'Directory[]'
-    'sbg:x': 481.69647216796875
-    'sbg:y': -386.3322448730469
+      - losoto_residual/output_h5parm
+    type: File
+    format: lofar:#H5Parm
+    'sbg:x': 152.59103393554688
+    'sbg:y': -289.2899169921875
+  - id: logfiles
+    outputSource:
+      - losoto_duplicate/log
+      - losoto_faraday/log
+      - losoto_residual/log
+    linkMerge: merge_flattened
+    type: 'File[]'
+    'sbg:x': 300.59103393554688
+    'sbg:y': 0
 steps:
-  - id: smooth_corrected
-    in:
-      - id: msin
-        source: msin
-      - id: do_smooth
-        source: do_smooth
-      - id: in_column_name
-        default: CORRECTED_DATA
-      - id: out_column
-        default: SMOOTHED_DATA
-    out:
-      - id: msout
-    run: ../steps/blsmooth.cwl
-    label: smooth_corrected
-    scatter:
-      - msin
-    'sbg:x': -773.8645629882812
-    'sbg:y': -111.44158172607422
-  - id: calib_cal
-    in:
-      - id: msin
-        source: smooth_corrected/msout
-      - id: msin_modelcolum
-        default: SMOOTHED_DATA
-      - id: output_name_h5parm
-        default: output.h5
-      - id: propagate_solutions
-        source: propagate_solutions
-      - id: flagunconverged
-        default: true
-        source: flagunconverged
-      - id: flagdivergedonly
-        default: true
-    out:
-      - id: msout
-      - id: h5parm
-    run: ../lofar-cwl/steps/calib_rot_diag.cwl
-    scatter:
-      - msin
-    'sbg:x': -568.359130859375
-    'sbg:y': -151.39132690429688
-  - id: h5imp_cal_FR
+  - id: losoto_duplicate
     in:
-      - id: h5parmFiles
-        linkMerge: merge_flattened
-        source:
-          - calib_cal/h5parm
-      - id: squeeze
-        default: true
-      - id: verbose
-        default: true
-      - id: clobber
-        default: true
+      - id: input_h5parm
+        source: input_h5parm
+      - id: soltab
+        default: sol000/phase000
+      - id: soltabOut
+        default: phaseOrig
     out:
-      - id: outh5parm
+      - id: output_h5parm
       - id: log
-    run: ../lofar-cwl/steps/H5ParmCollector.cwl
-    label: h5imp_cal_FR
-    'sbg:x': -339.8519592285156
-    'sbg:y': -82.80227661132812
+    run: ../lofar-cwl/steps/LoSoTo.Duplicate.cwl
+    'sbg:x': -423.6229248046875
+    'sbg:y': -287.8958435058594
   - id: losoto_faraday
     in:
       - id: input_h5parm
-        source: h5imp_cal_FR/outh5parm
+        source: losoto_duplicate/output_h5parm
       - id: soltab
-        default: sol000/phase000
+        default: sol000/rotation000
+      - id: soltabout
+        default: faraday
       - id: refAnt
         source: refAnt
       - id: maxResidual
-        default: 1
+        default: 1.0
     out:
       - id: output_h5parm
+      - id: log
     run: ../lofar-cwl/steps/LoSoTo.Faraday.cwl
     'sbg:x': -99.27792358398438
     'sbg:y': -126.80227661132812
-  - id: h5exp_cal_FR
+  - id: losoto_residual
     in:
-      - id: h5parmFiles
-        linkMerge: merge_flattened
-        source:
-          - losoto_faraday/output_h5parm
-      - id: insolset
-        default: sol000
-      - id: squeeze
-        default: true
-      - id: verbose
-        default: true
-      - id: clobber
-        default: false
+      - id: input_h5parm
+        source: losoto_faraday/output_h5parm
+      - id: soltab
+        default: sol000/phase000
+      - id: soltabsToSub
+        default:
+          - faraday
     out:
-      - id: outh5parm
+      - id: output_h5parm
       - id: log
-    run: ../lofar-cwl/steps/H5ParmCollector.cwl
-    label: H5parm_collector
-    'sbg:x': 56.72110366821289
-    'sbg:y': -198
-  - id: applycal
-    in:
-      - id: msin
-        source: msin
-      - id: msin_datacolumn
-        default: CORRECTED_DATA
-      - id: parmdb
-        source: h5exp_cal_FR/outh5parm
-      - id: correction
-        default: rotationmeasure000
-    out:
-      - id: msout
-    run: ../lofar-cwl/steps/applycal.cwl
-    scatter:
-      - msin
-    'sbg:x': 291.55780029296875
-    'sbg:y': -384.2626647949219
-requirements:
-  - class: ScatterFeatureRequirement
+    run: ../lofar-cwl/steps/LoSoTo.Residual.cwl
+    'sbg:x': -0.012040258385241032
+    'sbg:y': -287.7294006347656
+requirements: []
diff --git a/workflows/prefactor_calibrator.cwl b/workflows/prefactor_calibrator.cwl
index 083d9683..a21a2560 100644
--- a/workflows/prefactor_calibrator.cwl
+++ b/workflows/prefactor_calibrator.cwl
@@ -197,18 +197,19 @@ outputs:
     outputSource:
       - prep/check_Ateam_separation.png 
       - pa/inspection
+      - fr/inspection
     type: File[]
     'sbg:x': 1000
     'sbg:y': -600
   - id: solutions
     outputSource:
-      - pa/solutions
+      - fr/outsolutions
     type: File
     'sbg:x': 1000
     'sbg:y': -500
   - id: msout
     outputSource:
-      - pa/msout
+      - fr/msout
     type: 'Directory[]'
     'sbg:x': 1000
     'sbg:y': 0
@@ -222,6 +223,7 @@ outputs:
     outputSource:
       - prep/logfiles
       - pa/logfiles
+      - fr/logfiles
     type: 'File[]'
     linkMerge: merge_flattened
     'sbg:x': 1000
@@ -308,12 +310,46 @@ steps:
         source: do_smooth
     out:
       - id: msout
-      - id: solutions
+      - id: outsolutions
       - id: inspection
       - id: logfiles
+      - id: outh5parm
+      - id: outh5parm_logfile
     run: ./prefactor_calibrator/pa.cwl
     label: PA
-    'sbg:x': 500
+    'sbg:x': 400
+    'sbg:y': 0
+  - id: fr
+    in:
+      - id: msin
+        source:
+          - pa/msout
+      - id: h5parm
+        source:
+          - pa/outh5parm
+      - id: refant
+        source: refant
+      - id: inh5parm_logfile
+        source:
+          - pa/outh5parm_logfile
+      - id: flagunconverged
+        source: flagunconverged
+      - id: propagatesolutions
+        source: propagatesolutions
+      - id: do_smooth
+        source: do_smooth
+      - id: insolutions
+        source: pa/outsolutions
+    out:
+      - id: msout
+      - id: outsolutions
+      - id: inspection
+      - id: logfiles
+      - id: outh5parm
+      - id: outh5parm_logfile
+    run: ./prefactor_calibrator/fr.cwl
+    label: FR
+    'sbg:x': 700
     'sbg:y': 0
 requirements:
   - class: SubworkflowFeatureRequirement
diff --git a/workflows/prefactor_calibrator/fr.cwl b/workflows/prefactor_calibrator/fr.cwl
new file mode 100644
index 00000000..6c8a01c7
--- /dev/null
+++ b/workflows/prefactor_calibrator/fr.cwl
@@ -0,0 +1,428 @@
+class: Workflow
+cwlVersion: v1.0
+id: fr
+label: FR
+$namespaces:
+  sbg: 'https://www.sevenbridges.com/'
+inputs:
+  - id: flagunconverged
+    type: boolean?
+    default: false
+    'sbg:x': -1000
+    'sbg:y': -300
+  - id: propagatesolutions
+    type: boolean?
+    default: true
+    'sbg:x': -1000
+    'sbg:y': -200
+  - id: msin
+    type: 'Directory[]'
+    'sbg:x': -1000
+    'sbg:y': -100
+  - id: h5parm
+    type: File
+    'sbg:x': -1000
+    'sbg:y': 0
+  - id: refant
+    type: string?
+    'sbg:x': -1000
+    'sbg:y': 100
+  - id: inh5parm_logfile
+    type: File
+    'sbg:x': -1000
+    'sbg:y': 200
+  - id: do_smooth
+    type: boolean?
+    default: false
+    'sbg:x': -1000
+    'sbg:y': 300
+  - id: insolutions
+    type: File
+    'sbg:x': -1000
+    'sbg:y': 400
+outputs:
+  - id: outh5parm
+    outputSource:
+      - h5parm_collector/outh5parm
+    type: File
+    'sbg:x': 1000
+    'sbg:y': -200
+  - id: msout
+    outputSource:
+      - apply_calibrate_fr/msout
+    type: 'Directory[]'
+    'sbg:x': 1000
+    'sbg:y': -100
+  - id: inspection
+    outputSource:
+      - losoto_plot_P3/output_plots
+      - losoto_plot_Pd/output_plots
+      - losoto_plot_Rot3/output_plots
+      - losoto_plot_A3/output_plots
+      - losoto_plot_fr/output_plots
+      - losoto_plot_Pr/output_plots
+      - losoto_plot_Pr2/output_plots
+    type: 'File[]'
+    linkMerge: merge_flattened
+    'sbg:x': 1000
+    'sbg:y': 0
+  - id: outsolutions
+    outputSource:
+      - write_solutions/outh5parm
+    type: File
+    'sbg:x': 1000
+    'sbg:y': 100
+  - id: logfiles
+    outputSource:
+      - concat_logfiles_fr/output
+      - concat_logfiles_calib/output
+      - concat_logfiles_blsmooth/output
+      - concat_logfiles_apply/output
+    type: 'File[]'
+    linkMerge: merge_flattened
+    'sbg:x': 1000
+    'sbg:y': 200
+  - id: outh5parm_logfile
+    outputSource:
+      - h5parm_collector/log
+    type: File
+    'sbg:x': 1000
+    'sbg:y': 300
+steps:
+  - id: faraday_rot
+    in:
+      - id: refAnt
+        default: CS001HBA0
+        source: refant
+      - id: input_h5parm
+        source: h5parm
+    out:
+      - id: output_h5parm
+      - id: logfiles
+    run: ../../subworkflow/faraday_rotation.cwl
+    label: FaradayRot
+    'sbg:x': -500
+    'sbg:y': 0
+  - id: losoto_plot_P3
+    in:
+      - id: input_h5parm
+        source: faraday_rot/output_h5parm
+      - id: soltab
+        default: sol000/phaseOrig
+      - id: axesInPlot
+        default:
+          - time
+          - freq
+      - id: axisInTable
+        default: ant
+      - id: minmax
+        default:
+          - -3.14
+          - 3.14
+      - id: plotFlag
+        default: true
+      - id: refAnt
+        source: refant
+      - id: prefix
+        default: fr_ph_
+    out:
+      - id: output_plots
+      - id: logfile
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_P3
+    'sbg:x': 0
+    'sbg:y': -200
+  - id: losoto_plot_Pd
+    in:
+      - id: input_h5parm
+        source: faraday_rot/output_h5parm
+      - id: soltab
+        default: sol000/phaseOrig
+      - id: axesInPlot
+        default:
+          - time
+          - freq
+      - id: axisInTable
+        default: ant
+      - id: axisDiff
+        default: pol
+      - id: minmax
+        default:
+          - -3.14
+          - 3.14
+      - id: plotFlag
+        default: true
+      - id: refAnt
+        source: refant
+      - id: prefix
+        default: fr_ph_poldif
+    out:
+      - id: output_plots
+      - id: logfile
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_Pd
+    'sbg:x': 0
+    'sbg:y': -100
+  - id: losoto_plot_Rot3
+    in:
+      - id: input_h5parm
+        source: faraday_rot/output_h5parm
+      - id: soltab
+        default: sol000/rotation000
+      - id: axesInPlot
+        default:
+          - time
+          - freq
+      - id: axisInTable
+        default: ant
+      - id: plotFlag
+        default: true
+      - id: refAnt
+        source: refant
+      - id: prefix
+        default: fr_rotangle
+    out:
+      - id: output_plots
+      - id: logfile
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_Rot3
+    'sbg:x': 0
+    'sbg:y': 0
+  - id: losoto_plot_A3
+    in:
+      - id: input_h5parm
+        source: faraday_rot/output_h5parm
+      - id: soltab
+        default: sol000/amplitude000
+      - id: axesInPlot
+        default:
+          - time
+          - freq
+      - id: axisInTable
+        default: ant
+      - id: plotFlag
+        default: true
+      - id: prefix
+        default: fr_amp
+    out:
+      - id: output_plots
+      - id: logfile
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_A3
+    'sbg:x': 0
+    'sbg:y': 100
+  - id: losoto_plot_fr
+    in:
+      - id: input_h5parm
+        source: faraday_rot/output_h5parm
+      - id: soltab
+        default: sol000/faraday
+      - id: axesInPlot
+        default:
+          - time
+      - id: axisInTable
+        default: ant
+      - id: refAnt
+        source: refant
+      - id: prefix
+        default: fr
+    out:
+      - id: output_plots
+      - id: logfile
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_fr
+    'sbg:x': 0
+    'sbg:y': 200
+  - id: losoto_plot_Pr
+    in:
+      - id: input_h5parm
+        source: faraday_rot/output_h5parm
+      - id: soltab
+        default: sol000/phase000
+      - id: axesInPlot
+        default:
+          - time
+          - freq
+      - id: axisInTable
+        default: ant
+      - id: axisDiff
+        default: pol
+      - id: minmax
+        default:
+          - -3.14
+          - 3.14
+      - id: plotFlag
+        default: true
+      - id: refAnt
+        source: refant
+      - id: prefix
+        default: fr_ph-res_poldif
+    out:
+      - id: output_plots
+      - id: logfile
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_Pr
+    'sbg:x': 0
+    'sbg:y': 300
+  - id: losoto_plot_Pr2
+    in:
+      - id: input_h5parm
+        source: faraday_rot/output_h5parm
+      - id: soltab
+        default: sol000/phase000
+      - id: axesInPlot
+        default:
+          - time
+          - freq
+      - id: axisInTable
+        default: ant
+      - id: axisInCol
+        default: pol
+      - id: minmax
+        default:
+          - -3.14
+          - 3.14
+      - id: plotFlag
+        default: true
+      - id: refAnt
+        source: refant
+      - id: prefix
+        default: fr_ph-res_
+    out:
+      - id: output_plots
+      - id: logfile
+    run: ../../lofar-cwl/steps/LoSoTo.Plot.cwl
+    label: losoto_plot_Pr2
+    'sbg:x': 0
+    'sbg:y': 400
+  - id: concat_logfiles_fr
+    in:
+      - id: file_list
+        linkMerge: merge_flattened
+        source:
+          - inh5parm_logfile
+          - faraday_rot/logfiles
+          - losoto_plot_P3/logfile
+          - losoto_plot_Pd/logfile
+          - losoto_plot_Rot3/logfile
+          - losoto_plot_A3/logfile
+          - losoto_plot_fr/logfile
+          - losoto_plot_Pr/logfile
+          - losoto_plot_Pr2/logfile
+          - write_solutions/log
+      - id: file_prefix
+        default: losoto_FR
+    out:
+      - id: output
+    run: ../../steps/concatenate_files.cwl
+    label: concat_logfiles_FR
+    'sbg:x': 500
+    'sbg:y': 500
+  - id: write_solutions
+    in:
+      - id: h5parmFile
+        source: faraday_rot/output_h5parm
+      - id: input_file
+        source: insolutions
+      - id: outsolset
+        default: calibrator
+      - id: insoltab
+        default: faraday
+      - id: outh5parmname
+        default: cal_solutions.h5
+      - id: squeeze
+        default: true
+      - id: verbose
+        default: true
+    out:
+      - id: outh5parm
+      - id: log
+    run: ../../steps/h5parmcat.cwl
+    label: write_solutions
+    'sbg:x': 0
+    'sbg:y': 500
+  - id: apply_calibrate_fr
+    in:
+      - id: msin
+        source: msin
+      - id: do_smooth
+        source: do_smooth
+      - id: flagunconverged
+        source: flagunconverged
+      - id: propagatesolutions
+        source: propagatesolutions
+      - id: input_h5parm
+        source: write_solutions/outh5parm
+    out:
+      - id: msout
+      - id: BLsmooth.log
+      - id: apply_cal.log
+      - id: calib_cal.log
+      - id: outh5parm
+    run: ../../subworkflow/apply_calibrate_fr.cwl
+    label: apply_calibrate_fr
+    scatter:
+      - msin
+    'sbg:x': 500
+    'sbg:y': 0
+  - id: concat_logfiles_blsmooth
+    in:
+      - id: file_list
+        source:
+          - apply_calibrate_fr/BLsmooth.log
+      - id: file_prefix
+        default: blsmooth_FR
+    out:
+      - id: output
+    run: ../../steps/concatenate_files.cwl
+    label: concat_logfiles_blsmooth
+    'sbg:x': 750
+    'sbg:y': 300
+  - id: concat_logfiles_apply
+    in:
+      - id: file_list
+        source:
+          - apply_calibrate_fr/apply_cal.log
+      - id: file_prefix
+        default: apply_cal_FR
+    out:
+      - id: output
+    run: ../../steps/concatenate_files.cwl
+    label: concat_logfiles_apply
+    'sbg:x': 750
+    'sbg:y': 600
+  - id: concat_logfiles_calib
+    in:
+      - id: file_list
+        source:
+          - apply_calibrate_fr/calib_cal.log
+      - id: file_prefix
+        default: calib_cal_FR
+    out:
+      - id: output
+    run: ../../steps/concatenate_files.cwl
+    label: concat_logfiles_calib
+    'sbg:x': 750
+    'sbg:y': 800
+  - id: h5parm_collector
+    in:
+      - id: h5parmFiles
+        source:
+          - apply_calibrate_fr/outh5parm
+      - id: squeeze
+        default: true
+      - id: verbose
+        default: true
+      - id: clobber
+        default: true
+    out:
+      - id: outh5parm
+      - id: log
+    run: ../../lofar-cwl/steps/H5ParmCollector.cwl
+    label: H5parm_collector
+    'sbg:x': 750
+    'sbg:y': -300
+requirements:
+  - class: SubworkflowFeatureRequirement
+  - class: ScatterFeatureRequirement
+  - class: MultipleInputFeatureRequirement
diff --git a/workflows/prefactor_calibrator/pa.cwl b/workflows/prefactor_calibrator/pa.cwl
index 9bdac658..7ff28e55 100644
--- a/workflows/prefactor_calibrator/pa.cwl
+++ b/workflows/prefactor_calibrator/pa.cwl
@@ -62,7 +62,7 @@ outputs:
     linkMerge: merge_flattened
     'sbg:x': 1000
     'sbg:y': 0
-  - id: solutions
+  - id: outsolutions
     outputSource:
       - write_solutions/outh5parm
     type: File
@@ -327,7 +327,8 @@ steps:
   - id: write_solutions
     in:
       - id: h5parmFiles
-        source: pol_align/output_h5parm
+        source:
+          - pol_align/output_h5parm
       - id: outsolset
         default: calibrator
       - id: insoltab
@@ -341,7 +342,7 @@ steps:
     out:
       - id: outh5parm
       - id: log
-    run: ../../steps/h5parmcat.cwl
+    run: ../../lofar-cwl/steps/H5ParmCollector.cwl
     label: write_solutions
     'sbg:x': 0
     'sbg:y': 500
-- 
GitLab