From 1622268fca202985fe7fc3777814db2b089c9210 Mon Sep 17 00:00:00 2001
From: mancini <mancini@astron.nl>
Date: Tue, 14 Jan 2020 14:28:32 +0100
Subject: [PATCH] Add bandpass step

Former-commit-id: 586fa97b11c55a6a32949411fc5eb1af8143cef9
---
 .gitlab-ci.yml                          |   6 ++
 steps/LoSoTo.PrefactorBandpass.cwl      | 101 ++++++++++++++++++++++++
 test_jobs/losoto_prefactorbandpass.json |   4 +
 3 files changed, 111 insertions(+)
 create mode 100644 steps/LoSoTo.PrefactorBandpass.cwl
 create mode 100644 test_jobs/losoto_prefactorbandpass.json

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ba19298f..7c35c120 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -115,6 +115,12 @@ losoto_smooth:
   script:
     - cwl-runner --no-container steps/LoSoTo.Smooth.cwl test_jobs/losoto_smooth.json
 
+losoto_prefactor_bandpass:
+  stage: test_steps
+  allow_failure: true
+  script:
+    - cwl-runner --no-container steps/LoSoTo.PrefactorBandpass.cwl test_jobs/losoto_prefactorbandpass.json
+
 losoto_clip:
   stage: test_steps
   allow_failure: true
diff --git a/steps/LoSoTo.PrefactorBandpass.cwl b/steps/LoSoTo.PrefactorBandpass.cwl
new file mode 100644
index 00000000..c81efdab
--- /dev/null
+++ b/steps/LoSoTo.PrefactorBandpass.cwl
@@ -0,0 +1,101 @@
+#!/usr/bin/env cwl-runner
+
+class: CommandLineTool
+cwlVersion: v1.0
+id: losoto_prefactor_bandpass
+
+$namespaces:
+  lofar: https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
+doc: |
+  This operation for LoSoTo implements the Prefactor bandpass operation
+  WEIGHT: flag-only compliant, no need for weight
+
+
+requirements:
+  InlineJavascriptRequirement:
+    expressionLib:
+      - { $include: utils.js}
+  InitialWorkDirRequirement:
+    listing:
+      - entryname: 'parset.config'
+        entry: $(get_losoto_config('PREFACTOR_BANDPASS').join('\n'))
+
+      - entryname: $(inputs.input_h5parm.basename)
+        entry: $(inputs.input_h5parm)
+        writable: true
+
+baseCommand: "losoto"
+
+arguments:
+  - $(inputs.input_h5parm.basename)
+  - parset.config
+
+hints:
+  DockerRequirement:
+    dockerPull: lofareosc/lofar-pipeline-ci:latest
+
+inputs:
+  - id: input_h5parm
+    type: File
+    format: lofar:#H5Parm
+  - id: soltab
+    type: string
+    doc: "Solution table"
+  - id: chanWidth
+    type: string?
+    doc: |
+      the width of each channel in the data from which solutions were obtained. Can be
+      either a string like "48kHz" or a float in Hz. If interpolate = True, chanWidth
+      must be specified
+
+  - id: BadSBList
+    type: string?
+    doc: a list of bad subbands that will be flagged
+
+  - id: outSoltabName
+    type: string?
+    doc: |
+      Name of the output bandpass soltab. An existing soltab with this name will be
+      overwritten
+  - id: interpolate
+    type: boolean?
+    default: false
+    doc: |
+      If True, interpolate to a regular frequency grid and then smooth, ignoring bad
+      subbands. If False, neither interpolation nor smoothing is done and the output
+      frequency grid is the same as the input one. If interpolate = True, chanWidth
+      must be specified
+  - id: removeTimeAxis
+    type: boolean?
+    doc: |
+      If True, the time axis of the output bandpass soltab is removed by doing a median
+      over time. If False, the output time grid is the same as the input one
+  - id: autoFlag
+    type: boolean?
+    doc: If True, automatically flag bad frequencies and stations
+
+  - id: nSigma
+    type: float?
+    doc: Number of sigma for autoFlagging. Amplitudes outside of nSigma*stddev are flagged
+
+  - id: maxFlaggedFraction
+    type: float?
+    doc: |
+      Maximum allowable fraction of flagged frequencies for autoFlagging. Stations with
+      higher fractions will be completely flagged
+  - id: maxStddev
+    type: float?
+    doc: Maximum allowable standard deviation for autoFlagging
+
+  - id: ncpu
+    type: int?
+    doc: Number of CPUs to use during autoFlagging (0 = all)
+
+outputs:
+  - id: output_h5parm
+    type: File
+    format: lofar:#H5Parm
+    outputBinding:
+      glob: $(inputs.input_h5parm.basename)
+$schema:
+  - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/test_jobs/losoto_prefactorbandpass.json b/test_jobs/losoto_prefactorbandpass.json
new file mode 100644
index 00000000..0b34257c
--- /dev/null
+++ b/test_jobs/losoto_prefactorbandpass.json
@@ -0,0 +1,4 @@
+{
+  "input_h5parm": {"class": "File", "path": "/data/example.h5", "format": "lofar:#H5Parm"},
+  "soltab":  "sol000/amplitude000"
+}
-- 
GitLab