Skip to content
Snippets Groups Projects
Commit fd774933 authored by alex's avatar alex
Browse files

automized demixing selection (RAP-414)

parent 21782f27
No related branches found
No related tags found
1 merge request!92automized demixing selection (RAP-414)
Pipeline #27219 failed
Showing
with 169 additions and 30 deletions
...@@ -121,7 +121,7 @@ run_hba_calibrator: ...@@ -121,7 +121,7 @@ run_hba_calibrator:
needs: ["versioning", "download_data"] needs: ["versioning", "download_data"]
image: $INTEGRATION_IMAGE image: $INTEGRATION_IMAGE
script: script:
- cwltool --no-container --preserve-environment PATH --preserve-environment PREFACTOR_DATA_ROOT --preserve-environment PYTHONPATH --preserve-environment OPENBLAS_NUM_THREADS --outdir results --leave-tmpdir --tmpdir-prefix /tmp/run_hba_calibrator/ workflows/HBA_calibrator.cwl test_jobs/HBA_calibrator.json - cwltool --no-container --preserve-environment PATH --preserve-environment PREFACTOR_DATA_ROOT --preserve-environment PYTHONPATH --outdir results --leave-tmpdir --tmpdir-prefix /tmp/run_hba_calibrator/ workflows/HBA_calibrator.cwl test_jobs/HBA_calibrator.json
- test_jobs/check_workflow_results.py results /builds/eosc/prefactor3-cwl/data/results_calibrator - test_jobs/check_workflow_results.py results /builds/eosc/prefactor3-cwl/data/results_calibrator
after_script: after_script:
- find /tmp/run_hba_calibrator -name "*.log" -print0 | tar czf hba_calibrator_logs.tar.gz --null -T - - find /tmp/run_hba_calibrator -name "*.log" -print0 | tar czf hba_calibrator_logs.tar.gz --null -T -
...@@ -135,7 +135,7 @@ run_hba_target: ...@@ -135,7 +135,7 @@ run_hba_target:
needs: ["versioning", "download_data"] needs: ["versioning", "download_data"]
image: $INTEGRATION_IMAGE image: $INTEGRATION_IMAGE
script: script:
- cwltool --no-container --preserve-environment PATH --preserve-environment PREFACTOR_DATA_ROOT --preserve-environment PYTHONPATH --preserve-environment OPENBLAS_NUM_THREADS --outdir results --leave-tmpdir --tmpdir-prefix /tmp/run_hba_target/ workflows/HBA_target.cwl test_jobs/HBA_target.json - cwltool --no-container --preserve-environment PATH --preserve-environment PREFACTOR_DATA_ROOT --preserve-environment PYTHONPATH --outdir results --leave-tmpdir --tmpdir-prefix /tmp/run_hba_target/ workflows/HBA_target.cwl test_jobs/HBA_target.json
- test_jobs/check_workflow_results.py results /builds/eosc/prefactor3-cwl/data/results_target - test_jobs/check_workflow_results.py results /builds/eosc/prefactor3-cwl/data/results_target
after_script: after_script:
- find /tmp/run_hba_target -name "*.log" -print0 | tar czf hba_target_logs.tar.gz --null -T - - find /tmp/run_hba_target -name "*.log" -print0 | tar czf hba_target_logs.tar.gz --null -T -
......
...@@ -258,10 +258,11 @@ A comprehensive explanation of the baseline selection syntax can be found `here` ...@@ -258,10 +258,11 @@ A comprehensive explanation of the baseline selection syntax can be found `here`
*Demixing options* (only used if demix step is added to the ``prep_cal_strategy`` variable) *Demixing options* (only used if demix step is added to the ``prep_cal_strategy`` variable)
- ``demix_sources``: choose sources to demix (provided as list), e.g., ``[CasA,CygA]`` - ``demix_sources``: choose sources to demix (provided as list), e.g., ``[CasA,CygA]``
- ``demix_target``: if given, the target source model (its patch in the SourceDB) is taken into account when solving (default: ``""``)
- ``demix_freqstep``: number of channels to average when demixing (default: 16) - ``demix_freqstep``: number of channels to average when demixing (default: 16)
- ``demix_timestep`` : number of time slots to average when demixing (default: 10) - ``demix_timestep`` : number of time slots to average when demixing (default: 10)
- ``demix``: enable demixing (default: ``false``) - ``demix``: if ``true`` force demixing using all sources of ``demix_sources``, if ``false`` do not demix (default: ``null``, automatically determines sources to be demixed according to ``min_separation``)
- ``lbfgs_historysize``: for the LBFGS solver: the history size, specified as a multiple of the parameter vector, to use to approximate the inverse Hessian (default: 10)
- ``lbfgs_robustdof``: for the LBFGS solver: the degrees of freedom (DOF) given to the noise model (default: 200)
*Further pipeline options* *Further pipeline options*
......
...@@ -61,7 +61,6 @@ There are more parameters you may want to adjust that can be added to this input ...@@ -61,7 +61,6 @@ There are more parameters you may want to adjust that can be added to this input
"do_transfer": false, "do_transfer": false,
"trusted_sources": "3C48,3C147,3C196,3C295,3C380", "trusted_sources": "3C48,3C147,3C196,3C295,3C380",
"demix_sources": ["CasA","CygA"], "demix_sources": ["CasA","CygA"],
"demix_target": "",
"demix_freqstep": 16, "demix_freqstep": 16,
"demix_timestep": 10, "demix_timestep": 10,
"demix": false, "demix": false,
...@@ -78,7 +77,9 @@ There are more parameters you may want to adjust that can be added to this input ...@@ -78,7 +77,9 @@ There are more parameters you may want to adjust that can be added to this input
"A-Team_skymodel": null, "A-Team_skymodel": null,
"avg_timeresolution": 4, "avg_timeresolution": 4,
"avg_freqresolution": "48.82kHz", "avg_freqresolution": "48.82kHz",
"bandpass_freqresolution": "195.3125kHz" "bandpass_freqresolution": "195.3125kHz",
"lbfgs_historysize" : 10,
"lbfgs_robustdof" : 200
} }
If you just want to alter one of the defaults it is sufficient to override it by specifing its new value the JSON input file:: If you just want to alter one of the defaults it is sufficient to override it by specifing its new value the JSON input file::
......
...@@ -280,10 +280,11 @@ A comprehensive explanation of the baseline selection syntax can be found `here` ...@@ -280,10 +280,11 @@ A comprehensive explanation of the baseline selection syntax can be found `here`
*Demixing and clipping options* *Demixing and clipping options*
- ``demix_sources``: choose sources to demix (provided as list), e.g., ``[CasA,CygA]`` - ``demix_sources``: choose sources to demix (provided as list), e.g., ``[CasA,CygA]``
- ``demix_target``: if given, the target source model (its patch in the SourceDB) is taken into account when solving (default: ``""``)
- ``demix_freqstep``: number of channels to average when demixing (default: 16) - ``demix_freqstep``: number of channels to average when demixing (default: 16)
- ``demix_timestep`` : number of time slots to average when demixing (default: 10) - ``demix_timestep`` : number of time slots to average when demixing (default: 10)
- ``demix``: enable demixing (default: ``false``) - ``demix``: if ``true`` force demixing using all sources of ``demix_sources``, if ``false`` do not demix (default: ``null``, automatically determines sources to be demixed according to ``min_separation``)
- ``lbfgs_historysize``: for the LBFGS solver: the history size, specified as a multiple of the parameter vector, to use to approximate the inverse Hessian (default: 10)
- ``lbfgs_robustdof``: for the LBFGS solver: the degrees of freedom (DOF) given to the noise model (default: 200)
- ``clip_sources``: list of the skymodel patches to be used for Ateamclipping (default: ``[VirA_4_patch,CygAGG,CasA_4_patch,TauAGG]``) - ``clip_sources``: list of the skymodel patches to be used for Ateamclipping (default: ``[VirA_4_patch,CygAGG,CasA_4_patch,TauAGG]``)
*Further pipeline options* *Further pipeline options*
......
...@@ -91,8 +91,7 @@ def main(flagFiles = None, pipeline = 'prefactor', run_type = 'calibrator', filt ...@@ -91,8 +91,7 @@ def main(flagFiles = None, pipeline = 'prefactor', run_type = 'calibrator', filt
demix_list = [] demix_list = []
for i in range(len(json_output['metrics'][pipeline]['close_sources'])): for i in range(len(json_output['metrics'][pipeline]['close_sources'])):
Ateam_name = json_output['metrics'][pipeline]['close_sources'][i]['source'] Ateam_name = json_output['metrics'][pipeline]['close_sources'][i]['source']
if demix: if Ateam_name in demix_sources and demix:
if Ateam_name in demix_sources:
json_output['metrics'][pipeline]['close_sources'][i]['mitigation'] = 'demix' json_output['metrics'][pipeline]['close_sources'][i]['mitigation'] = 'demix'
demix_list.append(Ateam_name) demix_list.append(Ateam_name)
elif Ateam_name in clip_sources: elif Ateam_name in clip_sources:
......
...@@ -12,7 +12,7 @@ baseCommand: ...@@ -12,7 +12,7 @@ baseCommand:
inputs: inputs:
- id: h5parmFiles - id: h5parmFiles
type: type:
- 'File[]' - File[]
- File - File
format: lofar:#H5Parm format: lofar:#H5Parm
inputBinding: inputBinding:
......
...@@ -79,7 +79,7 @@ outputs: ...@@ -79,7 +79,7 @@ outputs:
outputBinding: outputBinding:
glob: $(inputs.msout_name) glob: $(inputs.msout_name)
- id: logfile - id: logfile
type: 'File[]' type: File[]
outputBinding: outputBinding:
glob: average*.log glob: average*.log
arguments: arguments:
......
class: CommandLineTool
cwlVersion: v1.2
id: check_demix
baseCommand:
- python3
- check_demix.py
inputs:
- id: skymodel
type: File?
- id: demix_sources
type: string[]?
default:
- VirA_4_patch
- CygAGG
- CasA_4_patch
- TauAGG
- id: clip_sources
type: string[]?
default:
- VirA_4_patch
- CygAGG
- CasA_4_patch
- TauAGG
- id: demix
type: boolean?
inputBinding:
valueFrom: '$(self ? 1 : 0)'
- id: Ateam_separation_file
type: File
outputs:
- id: out_demix
type: boolean
outputBinding:
loadContents: true
glob: 'out.json'
outputEval: '$(JSON.parse(self[0].contents).demix == 0 ? false : true)'
- id: out_demix_sources
type: string[]
outputBinding:
loadContents: true
glob: 'out.json'
outputEval: '$(JSON.parse(self[0].contents).demix_sources)'
- id: out_clip_sources
type: string[]
outputBinding:
loadContents: true
glob: 'out.json'
outputEval: '$(JSON.parse(self[0].contents).clip_sources)'
- id: logfile
type: File
outputBinding:
glob: check_demix.log
label: check_demix
requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: check_demix.py
entry: |
import json
import os
import lsmtool
import numpy, math
null = None
targets = {'CasA' : {'ra' : 6.123487680622104, 'dec' : 1.0265153995604648}, \
'CygA' : {'ra' : 5.233686575770755, 'dec' : 0.7109409582180791}, \
'TauA' : {'ra' : 1.4596748493730913, 'dec' : 0.38422502335921294}, \
'HerA' : {'ra' : 4.4119087330382163, 'dec' : 0.087135562905816893}, \
'VirA' : {'ra' : 3.276086511413598, 'dec' : 0.21626589533567378}, \
'Sun' : {'ra' : 0, 'dec' : 0 }, \
'Jupiter': {'ra' : 0, 'dec' : 0 }, \
'Moon' : {'ra' : 0, 'dec' : 0 }}
inputs = json.loads(r"""$(inputs)""")
demix = inputs['demix']
demix_sources = inputs['demix_sources']
clip_sources = inputs['clip_sources']
skymodel = inputs['skymodel']
Ateam_separation_file = inputs['Ateam_separation_file']["path"]
if skymodel is None:
skymodel = os.path.expandvars("$PREFACTOR_DATA_ROOT/skymodels/Ateam_LBA_CC.skymodel")
else:
skymodel = skymodel["path"]
s = lsmtool.load(skymodel)
f = open(Ateam_separation_file, 'r')
Ateam_separation = json.load(f)
f.close()
if demix is None:
demix = 0
demix_list = []
for item in Ateam_separation:
ra = math.degrees(targets[item['source']]['ra'])
dec = math.degrees(targets[item['source']]['dec'])
dist_deg = s.getDistance(ra, dec, byPatch=True)
if any(dist_deg * 60.0 < 6.0):
for index in numpy.where(dist_deg * 60 < 6.0)[0]:
patch_name = s.getPatchNames()[index]
if patch_name in demix_sources:
demix_list.append(patch_name)
demix = 1
demix_sources = demix_list
if demix == 1:
clip_sources = list(set(clip_sources).difference(demix_sources))
print("The following sources will be demixed: ", demix_sources)
print("The following sources will be clipped: ", clip_sources)
cwl_output = {"demix_sources" : demix_sources,
"clip_sources" : clip_sources,
"demix" : demix}
with open('./out.json', 'w') as fp:
json.dump(cwl_output, fp)
hints:
- class: DockerRequirement
dockerPull: lofareosc/prefactor3-cwl
stdout: check_demix.log
stderr: check_demix_err.log
...@@ -6,7 +6,7 @@ baseCommand: ...@@ -6,7 +6,7 @@ baseCommand:
- bulk_rename.sh - bulk_rename.sh
inputs: inputs:
- id: file_list - id: file_list
type: 'File[]' type: File[]
inputBinding: inputBinding:
position: 0 position: 0
- id: file_prefix - id: file_prefix
......
...@@ -16,7 +16,7 @@ inputs: ...@@ -16,7 +16,7 @@ inputs:
type: int? type: int?
default: 20 default: 20
- id: baselines_to_flag - id: baselines_to_flag
type: 'string[]?' type: string[]?
default: [] default: []
- id: elevation_to_flag - id: elevation_to_flag
type: string? type: string?
...@@ -43,13 +43,19 @@ inputs: ...@@ -43,13 +43,19 @@ inputs:
type: string? type: string?
default: '' default: ''
- id: subtract_sources - id: subtract_sources
type: 'string[]?' type: string[]?
default: default:
- CasA - CasA
- CygA - CygA
- id: ntimechunk - id: ntimechunk
type: int? type: int?
default: 10 default: 10
- id: lbfgs_historysize
type: int?
default: 10
- id: lbfgs_robustdof
type: float?
default: 200
outputs: outputs:
- id: output - id: output
type: File type: File
...@@ -113,3 +119,7 @@ requirements: ...@@ -113,3 +119,7 @@ requirements:
demix.freqstep = 1 demix.freqstep = 1
demix.timestep = 1 demix.timestep = 1
demix.instrumentmodel = instrument demix.instrumentmodel = instrument
demix.uselbfgssolver = True
demix.lbfgs.historysize = $(inputs.lbfgs_historysize)
demix.lbfgs.robustdof = $(inputs.lbfgs_robustdof)
demix.maxiter = 20
...@@ -31,7 +31,7 @@ inputs: ...@@ -31,7 +31,7 @@ inputs:
type: int? type: int?
default: 20 default: 20
- id: baselines_to_flag - id: baselines_to_flag
type: 'string[]?' type: string[]?
default: [] default: []
- id: elevation_to_flag - id: elevation_to_flag
type: string? type: string?
...@@ -61,7 +61,7 @@ inputs: ...@@ -61,7 +61,7 @@ inputs:
type: string? type: string?
default: 'pointing' default: 'pointing'
- id: subtract_sources - id: subtract_sources
type: 'string[]?' type: string[]?
default: default:
- CasA - CasA
- CygA - CygA
......
...@@ -141,7 +141,7 @@ outputs: ...@@ -141,7 +141,7 @@ outputs:
glob: $(inputs.jsonfilename) glob: $(inputs.jsonfilename)
outputEval: $(JSON.parse(self[0].contents).flagged_fraction_dict) outputEval: $(JSON.parse(self[0].contents).flagged_fraction_dict)
- id: logfile - id: logfile
type: 'File[]' type: File[]
outputBinding: outputBinding:
glob: concat*.log glob: concat*.log
arguments: arguments:
......
...@@ -14,7 +14,7 @@ inputs: ...@@ -14,7 +14,7 @@ inputs:
inputBinding: inputBinding:
position: 1 position: 1
- id: measurement_sets - id: measurement_sets
type: 'Directory[]' type: Directory[]
inputBinding: inputBinding:
position: 2 position: 2
outputs: outputs:
......
...@@ -36,7 +36,7 @@ inputs: ...@@ -36,7 +36,7 @@ inputs:
separate: false separate: false
- default: null - default: null
id: sources id: sources
type: 'string[]?' type: string[]?
inputBinding: inputBinding:
position: 0 position: 0
prefix: predict.sources= prefix: predict.sources=
......
...@@ -142,7 +142,7 @@ inputs: ...@@ -142,7 +142,7 @@ inputs:
separate: false separate: false
- default: null - default: null
id: blrange id: blrange
type: 'int[]?' type: int[]?
inputBinding: inputBinding:
position: 0 position: 0
prefix: filter.blrange= prefix: filter.blrange=
......
...@@ -5,7 +5,7 @@ baseCommand: ...@@ -5,7 +5,7 @@ baseCommand:
- python3 - python3
inputs: inputs:
- id: msin - id: msin
type: 'Directory[]' type: Directory[]
inputBinding: inputBinding:
position: 1 position: 1
- id: unflagged_fraction - id: unflagged_fraction
......
...@@ -36,7 +36,7 @@ inputs: ...@@ -36,7 +36,7 @@ inputs:
separate: false separate: false
- default: null - default: null
id: sources id: sources
type: 'string[]?' type: string[]?
inputBinding: inputBinding:
position: 0 position: 0
prefix: predict.sources= prefix: predict.sources=
......
...@@ -8,7 +8,7 @@ baseCommand: ...@@ -8,7 +8,7 @@ baseCommand:
inputs: inputs:
- id: flagFiles - id: flagFiles
type: type:
- 'File[]' - File[]
- File - File
inputBinding: inputBinding:
position: 1 position: 1
......
...@@ -8,7 +8,7 @@ baseCommand: ...@@ -8,7 +8,7 @@ baseCommand:
inputs: inputs:
- id: MSfiles - id: MSfiles
type: type:
- 'Directory[]' - Directory[]
- Directory - Directory
inputBinding: inputBinding:
position: 2 position: 2
......
...@@ -5,7 +5,7 @@ baseCommand: ...@@ -5,7 +5,7 @@ baseCommand:
- wsclean - wsclean
inputs: inputs:
- id: msin - id: msin
type: 'Directory[]' type: Directory[]
inputBinding: inputBinding:
position: 2 position: 2
shellQuote: false shellQuote: false
...@@ -15,7 +15,7 @@ inputs: ...@@ -15,7 +15,7 @@ inputs:
default: default:
- 2500 - 2500
- 2500 - 2500
type: 'int[]' type: int[]
inputBinding: inputBinding:
position: 1 position: 1
shellQuote: false shellQuote: false
...@@ -206,7 +206,7 @@ outputs: ...@@ -206,7 +206,7 @@ outputs:
outputBinding: outputBinding:
glob: [$(inputs.image_name)-MFS-image.fits, $(inputs.image_name)-image.fits] glob: [$(inputs.image_name)-MFS-image.fits, $(inputs.image_name)-image.fits]
- id: logfile - id: logfile
type: 'File[]' type: File[]
outputBinding: outputBinding:
glob: 'wsclean*.log' glob: 'wsclean*.log'
label: WSClean label: WSClean
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment