1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
"""Dummy deconvolution algorithm writing its inputs to disk
Usage:
wsclean ... -python-deconvolution test_deconvolution_write_input.py ...
This is used by the test_direction_dependent_psfs() test in long_system_checks.py to
inspect dirty and psf images passed on by the parallel deconvolution algorithm
"""
import numpy as np
def deconvolve(residual, model, psf, meta):
"""Dummy deconvolution function to be called from the PythonDeconvolution class in Radler
Input residual and psf images are written to disk as numpy (.npy) array
The function keeps a counter to generate unique filenames per application run
"""
# Only write out files for the first call per image
# The first call is peak finding only, max_iterations is zero then
if meta.max_iterations == 0:
# deconvolve.counter is an attribute of the deconvolve() function (this function).
# It keeps track of many times the function is called with meta.max_iteration = 0
deconvolve.counter = getattr(deconvolve, "counter", 0)
count = deconvolve.counter
deconvolve.counter += 1
# Write out dirty image
filename_dirty = (
f"test_results/test-deconvolution-write-input-dirty-{count}.npy"
)
np.save(filename_dirty, residual)
# Write out psf
filename_psf = (
f"test_results/test-deconvolution-write-input-psf-{count}.npy"
)
np.save(filename_psf, psf)
# Fill a dictionary with values that wsclean expects:
result = dict()
result["residual"] = residual
result["model"] = model
result["level"] = 0.0
result["continue"] = False
return result
|