From 0f5bf10bb459452570f58b7bb5f843b0bae2b629 Mon Sep 17 00:00:00 2001
From: mancini <mancini@astron.nl>
Date: Thu, 26 Sep 2019 14:02:16 +0200
Subject: [PATCH] Fix CWL and python for parsetgenerator

---
 steps/AveragingStepGenerator.cwl |  27 ++++---
 steps/DP3_flag_averaging.cwl     | 123 +++++++++++++++++++++++++++++++
 steps/echo.cwl                   |  12 +++
 utils/parset_concat.py           |   2 +-
 4 files changed, 151 insertions(+), 13 deletions(-)
 create mode 100644 steps/DP3_flag_averaging.cwl
 create mode 100644 steps/echo.cwl

diff --git a/steps/AveragingStepGenerator.cwl b/steps/AveragingStepGenerator.cwl
index 1abe69cf..0be4cc15 100755
--- a/steps/AveragingStepGenerator.cwl
+++ b/steps/AveragingStepGenerator.cwl
@@ -15,53 +15,56 @@ inputs:
   - id: parset
     type: File
     inputBinding:
-      prefix: --input_parset=
-      position: 1 
-
+        position: -1
+        prefix: --input_parset
   - id: step_name
     type: string
     default: average
     doc: unique name for the step
     inputBinding:
-      position: 2
+        position: -1
   - id: timestep
     type: int
     default: 1
     doc: Number of time slots to average. It is truncated if exceeding the actual number of times.
     inputBinding:
-      prefix: timestep=
-      
+        prefix: timestep=
+        separate: false
   - id: freqstep
     type: int
     default: 1
     doc: Number of channels to average. It is truncated if exceeding the actual number of channels.
     inputBinding:
-      prefix: freqstep=
-      
+        prefix: freqstep=
+        separate: false
   - id: minpoints
     type: int
     doc: If number of averaged unflagged input points < minpoints, the averaged point is flagged.
     default: 0
     inputBinding:
-      prefix: minpoints=
+        prefix: minpoints=
+        separate: false
   - id: minperc
     type: float
     doc: Like minpoints, but expressed as a percentage of timestep*freqstep.
     default: 0
     inputBinding:
-      prefix: minperc=
+        prefix: minperc=
+        separate: false
   - id: timeresolution
     type: float
     doc: Target time resolution, in seconds. If this is given, and bigger than zero, it overrides <step>.timestep
     default: 0
     inputBinding:
-      prefix: timeresolution
+        prefix: timeresolution=
+        separate: false
   - id: freqresolution
     type: float
     doc: Target frequency resolution, in Hz (or append “MHz” or “kHz” to specify it in those units). If this is given, and bigger than zero, it overrides <step>.freqstep
     default: 0
     inputBinding:
-      prefix: freqresolution=
+        prefix: freqresolution=
+        separate: false
 
 
 outputs:
diff --git a/steps/DP3_flag_averaging.cwl b/steps/DP3_flag_averaging.cwl
new file mode 100644
index 00000000..7556cc69
--- /dev/null
+++ b/steps/DP3_flag_averaging.cwl
@@ -0,0 +1,123 @@
+cwlVersion: 1.1
+class: CommandLineTool
+baseCommand: [DPPP]
+
+label: "Flagging and Averaging"
+
+hints:
+    DockerRequirements:
+        dockerPull: lofaruser/imaging-pipeline
+
+inputs:
+    msin:
+        type: Directory
+    
+    msin_data_column:
+        type: string
+        default: "DATA"
+    
+    msin_writefullresflag:
+        type: boolean
+        default: False
+    
+    msin_baselines:
+        type: string
+        default: ""
+    
+    msin_autoweight:
+        type: boolean
+        default: False
+    
+    msout_data_column:
+        type: string
+        default: "DATA"
+        
+    msout_writefullresflag:
+        type: boolean
+        default: False
+    
+    msout_overwrite:
+        type: boolean
+        default: True
+    
+    msout_storagemanager:
+        type: string
+        default: "Dysco"
+        
+    msout_storagemanager_databitrate:
+        type: int
+        default: 0
+        
+    flagger_memory_used:
+        type: int
+        default: 0
+    
+    flagger_keep_statistics:
+        type: boolean
+        default: False
+        
+    flag_baseline:
+        type: string
+        default: ""
+    
+    flag_elevation:
+        type: string
+        default: "0deg..20deg"
+    
+    flag_amplitude:
+        type: double
+        default: 1.e-30
+    
+    interpolate_windowsize:
+        type: int
+    
+    
+    avg_timeresolution:
+        type: int
+    avg_frequenciesresolution:
+        type: int
+        
+    demixer_baseline:
+        type: string
+        default: ""
+    
+    demixer_frequency_steps:
+        type: int
+        default: 4
+    
+    demixer_time_steps:
+        type: int
+        default: 4
+        
+    demixer_ignore_target:
+        type: boolean
+        default: False
+    
+    demixer_target_source:
+        type: string
+    
+    demixer_subtract_sources:
+        type: string
+        
+    
+    
+outputs:
+    
+        
+
+        
+ndppp_prep_cal.control.type                                 =   dppp
+ndppp_prep_cal.control.max_per_node                         =   {{ num_proc_per_node_limit }}
+ndppp_prep_cal.control.error_tolerance                      =   {{ error_tolerance }}
+ndppp_prep_cal.argument.numthreads                          =   {{ max_dppp_threads }}
+
+ndppp_prep_cal.argument.steps                               =   [{{ initial_flagging }},{{ demix_step }}interp,avg]
+ndppp_prep_cal.argument.flagedge.type                       =   preflagger
+ndppp_prep_cal.argument.flagedge.chan                       =   [0..nchan/32-1,31*nchan/32..nchan-1] # we are running on a single subband
+
+ndppp_prep_cal.argument.flagbaseline.type                   =   preflagger
+ndppp_prep_cal.argument.flagamp.type                        =   preflagger
+ndppp_prep_cal.argument.interp.type                         =   interpolate
+ndppp_prep_cal.argument.avg.type                            =   average
+ndppp_prep_cal.argument.flagamp.type                        =   preflagger
+ndppp_prep_cal.argument.demix.type                          =   demixer
diff --git a/steps/echo.cwl b/steps/echo.cwl
new file mode 100644
index 00000000..8e273f66
--- /dev/null
+++ b/steps/echo.cwl
@@ -0,0 +1,12 @@
+class: CommandLineTool
+cwlVersion: v1.0
+id: echo
+baseCommand:
+  - cat
+inputs: 
+  file:
+    type: File
+    inputBinding:
+      position: 1
+    
+outputs: []
\ No newline at end of file
diff --git a/utils/parset_concat.py b/utils/parset_concat.py
index 5d488417..c4c05062 100755
--- a/utils/parset_concat.py
+++ b/utils/parset_concat.py
@@ -9,8 +9,8 @@ from argparse import ArgumentParser
 
 def parse_arguments(args):
     parser = ArgumentParser(description='Concatenate step defined to the input parset')
-    parser.add_argument('step_type', help='type of the step')
     parser.add_argument('step_name', help='name of the step')
+    parser.add_argument('step_type', help='type of the step')
     parser.add_argument('--input_parset', default=None, help='input parset')
     parser.add_argument('step_arguments', help='step arguments', nargs='+')
 
-- 
GitLab