From 2296cb13b51443e6d3d89c5ca9882bbdb264f1c4 Mon Sep 17 00:00:00 2001
From: mancini <mancini@astron.nl>
Date: Tue, 10 Dec 2019 14:42:47 +0100
Subject: [PATCH] Add gain cal step

Former-commit-id: 36277e33f947d05de69fc7af0cfe88f1c71a9d63
---
 .gitlab-ci.yml         |   6 +++
 steps/gaincal.cwl      | 114 +++++++++++++++++++++++++++++++++++++++++
 test_jobs/gaincal.json |   9 ++++
 3 files changed, 129 insertions(+)
 create mode 100644 steps/gaincal.cwl
 create mode 100644 test_jobs/gaincal.json

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3e7d60a3..b225cf5d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -159,6 +159,12 @@ ddecal:
   script:
     - cwltool --no-container --preserve-environment LD_LIBRARY_PATH --preserve-environment PATH --preserve-environment PYTHONPATH steps/ddecal.cwl test_jobs/ddecal.json
 
+gaincal:
+  stage: test_steps
+  allow_failure: true
+  script:
+    - cwltool --no-container --preserve-environment LD_LIBRARY_PATH --preserve-environment PATH --preserve-environment PYTHONPATH steps/gaincal.cwl test_jobs/gaincal.json
+    
 predict:
   stage: test_steps
   allow_failure: true
diff --git a/steps/gaincal.cwl b/steps/gaincal.cwl
new file mode 100644
index 00000000..e017373e
--- /dev/null
+++ b/steps/gaincal.cwl
@@ -0,0 +1,114 @@
+#!/usr/bin/env cwl-runner
+
+class: CommandLineTool
+cwlVersion: v1.0
+id: gaincal
+baseCommand: [DPPP]
+
+requirements:
+  InlineJavascriptRequirement: {}
+
+hints:
+  DockerRequirement:
+    dockerPull: lofareosc/lofar-pipeline-ci:latest
+
+arguments:
+  - steps=[gaincal]
+
+
+inputs:
+  - id: msin
+    type: Directory?
+    doc: Input Measurement Set
+    inputBinding:
+        prefix: msin=
+        separate: false
+  - id: caltype
+    doc: |
+      The type of calibration that needs to be performed.
+    type:
+        type: enum
+        symbols:
+            - diagonal
+            - fulljones
+            - phaseonly
+            - scalarphase
+            - amplitude
+            - scalaramplitude
+            - tec
+            - tecandphase
+    inputBinding:
+        prefix: gaincal.caltype=
+        separate: false
+  - id: sourcedb
+    type: File
+    inputBinding:
+        prefix: gaincal.sourcedb=
+        separate: false
+  - id: usebeammodel
+    type: boolean
+    default: true
+    inputBinding:
+        prefix: gaincal.usebeammodel=true
+        separate: false
+  - id: solint
+    type: int
+    default: 1
+    doc: |
+        Number of time slots on which a solution is assumed to be constant (same as CellSize.Time in BBS).
+        0 means all time slots. Note that for larger settings of solint, and specially for solint = 0,
+        the memory usage of gaincal will be large (all visibilities for a solint should fit in memory).
+  - id: msin_datacolumn
+    type: string?
+    default: DATA
+    doc: Input data Column
+    inputBinding:
+        prefix: msin.datacolumn=
+        separate: false
+  - id: onebeamperpatch
+    type: boolean
+    doc: Input data Column
+    default: true
+    inputBinding:
+        prefix: gaincal.onebeamperpatch=True
+        separate: false
+  - id: msin_modelcolum
+    type: string
+    default: MODEL_DATA
+    doc: Model data Column
+    inputBinding:
+        prefix: msin.modelcolumn=
+        separate: false
+
+  - id: output_name_h5parm
+    type: string
+    default: instrument.h5
+    inputBinding:
+        prefix: gaincal.parmdb=
+        separate: false
+  - id: msout_name
+    type: string
+    doc: Output Measurement Set
+    default: out.MS
+    inputBinding:
+        prefix: msout=
+        separate: false
+
+outputs:
+  - id: msout
+    doc: Output Measurement Set
+    type: Directory
+    outputBinding:
+      glob: $(inputs.msout_name=="."?inputs.msin:inputs.msout_name)
+
+  - id: h5parm
+    doc: Filename of output H5Parm (to be read by e.g. losoto)
+    type: File
+    format: lofar:#H5Parm
+    outputBinding:
+      glob: $(inputs.output_name_h5parm)
+
+$namespaces:
+  lofar: https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
+$schema:
+  - https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl
diff --git a/test_jobs/gaincal.json b/test_jobs/gaincal.json
new file mode 100644
index 00000000..d0225a92
--- /dev/null
+++ b/test_jobs/gaincal.json
@@ -0,0 +1,9 @@
+{
+  "msin": {
+    "class": "Directory",
+    "path": "/data/L570745_SB001_uv_MODEL.MS"
+  },
+  "sourcedb": {"class":"File", "path":"/data/A-Team_lowres.sourcedb"},
+  "sourcename": "TauA",
+  "caltype": "diagonal"
+}
-- 
GitLab