From 0ad7ad9c04a1a4997c3a3c14b27b7391902950c0 Mon Sep 17 00:00:00 2001 From: mancini <mancini@astron.nl> Date: Mon, 13 Jan 2020 16:32:46 +0100 Subject: [PATCH] Add LoSoTo reweight Former-commit-id: 47d2992e9a3d298e18b333e3a0bff8fe600f3493 Former-commit-id: 4a98ba6533fe652a1e1b73ba7c2ea5f3e4440ae1 --- .gitlab-ci.yml | 8 ++++ steps/LoSoTo.Reweight.cwl | 81 ++++++++++++++++++++++++++++++++++ steps/utils.js | 3 +- test_jobs/losoto_reweight.json | 4 ++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 steps/LoSoTo.Reweight.cwl create mode 100644 test_jobs/losoto_reweight.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e94a075..d31f3ae7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -135,6 +135,14 @@ losoto_interpolate: allow_failure: true script: - cwl-runner --no-container steps/LoSoTo.Interpolate.cwl test_jobs/losoto_interpolate.json + +losoto_reweight: + stage: test_steps + allow_failure: true + script: + - cwl-runner --no-container steps/LoSoTo.Reweight.cwl test_jobs/losoto_reweight.json + + losoto_residual: stage: test_steps allow_failure: true diff --git a/steps/LoSoTo.Reweight.cwl b/steps/LoSoTo.Reweight.cwl new file mode 100644 index 00000000..abe16e2c --- /dev/null +++ b/steps/LoSoTo.Reweight.cwl @@ -0,0 +1,81 @@ +#!/usr/bin/env cwl-runner + +class: CommandLineTool +cwlVersion: v1.0 +id: losoto_reweight + +$namespaces: + lofar: https://git.astron.nl/eosc/ontologies/raw/master/schema/lofar.owl +doc: | + Change the the weight values. + Parameters + + +requirements: + InlineJavascriptRequirement: + expressionLib: + - { $include: utils.js} + InitialWorkDirRequirement: + listing: + - entryname: 'parset.config' + entry: $(get_losoto_config('REWEIGHT').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: mode + default: 'uniform' + type: + - type: enum + symbols: + - uniform + - window + - copy + doc: One of 'uniform' (single value), 'window' (sliding window in time), or 'copy' (copy from another table), by default 'uniform'. + - id: weightVal + type: float? + doc: Set weights to this values (0=flagged), by default 1. + - id: nmedian + type: int? + doc: | + Median window size in number of timeslots for 'window' mode. + If nonzero, a median-smoothed version of the input values is + subtracted to detrend them. If 0, no smoothing or subtraction is + done, by default 3. + - id: nstddev + type: int? + doc: Standard deviation window size in number of timeslots for 'window' mode, by default 251. + - id: soltabImport + type: string? + doc: Name of a soltab. Copy weights from this soltab (must have same axes shape), by default none. + - id: flagBad + type: boolean? + doc: Re-apply flags to bad values (1 for amp, 0 for other tables), by default False. + + +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/steps/utils.js b/steps/utils.js index 27b21ab8..3b3804b5 100644 --- a/steps/utils.js +++ b/steps/utils.js @@ -1,6 +1,7 @@ function get_losoto_config(step_name) { var par = ['soltab = ' + inputs.soltab] - if (inputs.ncpu !== null) par.push('ncpu='+inputs.ncpu); + if (inputs.ncpu !== null && inputs.ncpu !== undefined) par.push('ncpu='+inputs.ncpu); + console.log(inputs, par) par.push("[" + step_name + "]") par.push('operation=' + step_name) for(var field_name in inputs){ diff --git a/test_jobs/losoto_reweight.json b/test_jobs/losoto_reweight.json new file mode 100644 index 00000000..eb5cd88a --- /dev/null +++ b/test_jobs/losoto_reweight.json @@ -0,0 +1,4 @@ +{ + "input_h5parm": {"class": "File", "path": "/data/example.h5", "format": "lofar:#H5Parm"}, + "soltab": "sol000/phase000" +} -- GitLab