Skip to content

Commit 92ec1fe

Browse files
committed
Ensure that gaintables are written
Always generated but may be null.
1 parent fc7c83d commit 92ec1fe

6 files changed

Lines changed: 34 additions & 15 deletions

File tree

‎processing_components/image/operations.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def show_image(im: Image, fig=None, title: str = '', pol=0, chan=0, cm='Greys',
169169
return fig
170170

171171

172-
def show_components(im, comps, npixels=128, fig=None):
172+
def show_components(im, comps, npixels=128, fig=None, vmax=None, vmin=None):
173173
""" Show components against an image
174174
175175
:param im:
@@ -180,6 +180,11 @@ def show_components(im, comps, npixels=128, fig=None):
180180
"""
181181
import matplotlib.pyplot as plt
182182

183+
if vmax is None:
184+
vmax = numpy.max(im.data[0, 0, ...])
185+
if vmin is None:
186+
vmin = numpy.min(im.data[0, 0, ...])
187+
183188
if not fig:
184189
fig = plt.figure()
185190
plt.clf()
@@ -193,7 +198,7 @@ def show_components(im, comps, npixels=128, fig=None):
193198
(centre[0] - npixels // 2):(centre[0] + npixels // 2)]
194199
newim.wcs.wcs.crpix[0] -= centre[0] - npixels // 2
195200
newim.wcs.wcs.crpix[1] -= centre[1] - npixels // 2
196-
plt.imshow(newim.data[0, 0, ...], origin='lower', cmap='Greys')
201+
plt.imshow(newim.data[0, 0, ...], origin='lower', cmap='Greys', vmax=vmax, vmin=vmin)
197202
x, y = skycoord_to_pixel(sc.direction, newim.wcs, 0, 'wcs')
198203
plt.plot(x, y, marker='+', color='red')
199204
plt.title('Name = %s, flux = %s' % (sc.name, sc.flux))

‎tests/workflows/test_calibrate_arlexecute.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_calibrate_arlexecute_empty(self):
137137
calibration_context='T', controls=controls, do_selfcal=True,
138138
global_solution=False)
139139
calibrate_list = arlexecute.compute(calibrate_list, sync=True)
140-
assert len(calibrate_list[1][0]) == 0
140+
assert len(calibrate_list[1][0]) > 0
141141

142142
def test_calibrate_arlexecute_global(self):
143143
amp_errors = {'T': 0.0, 'G': 0.0}
@@ -178,7 +178,7 @@ def test_calibrate_arlexecute_global_empty(self):
178178
global_solution=True)
179179

180180
calibrate_list = arlexecute.compute(calibrate_list, sync=True)
181-
assert len(calibrate_list[1][0]) == 0
181+
assert len(calibrate_list[1][0]) > 0
182182

183183
if __name__ == '__main__':
184184
unittest.main()

‎tests/workflows/test_pipelines_arlexecute.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from astropy.coordinates import SkyCoord
1313

1414
from data_models.polarisation import PolarisationFrame
15+
from data_models.data_model_helpers import export_gaintable_to_hdf5
1516

1617
from workflows.arlexecute.pipelines.pipeline_arlexecute import ical_list_arlexecute_workflow, \
1718
continuum_imaging_list_arlexecute_workflow
@@ -191,12 +192,14 @@ def test_ical_pipeline(self):
191192
deconvolve_taper='tukey', psf_support=64,
192193
calibration_context='T', controls=controls, do_selfcal=True,
193194
global_solution=False)
194-
clean, residual, restored = arlexecute.compute(ical_list, sync=True)
195+
clean, residual, restored, gt_list = arlexecute.compute(ical_list, sync=True)
195196
centre = len(clean) // 2
196197
if self.persist:
197198
export_image_to_fits(clean[centre], '%s/test_pipelines_ical_pipeline_arlexecute_clean.fits' % self.dir)
198199
export_image_to_fits(residual[centre][0], '%s/test_pipelines_ical_pipeline_arlexecute_residual.fits' % self.dir)
199200
export_image_to_fits(restored[centre], '%s/test_pipelines_ical_pipeline_arlexecute_restored.fits' % self.dir)
201+
export_gaintable_to_hdf5(gt_list[centre]['T'], '%s/test_pipelines_ical_pipeline_arlexecute_gaintable.hdf5' %
202+
self.dir)
200203

201204
qa = qa_image(restored[centre])
202205
assert numpy.abs(qa.data['max'] - 99.32729396999524) < 1.0, str(qa)
@@ -221,13 +224,16 @@ def test_ical_pipeline_global(self):
221224
deconvolve_taper='tukey', psf_support=64,
222225
calibration_context='T', controls=controls, do_selfcal=True,
223226
global_solution=True)
224-
clean, residual, restored = arlexecute.compute(ical_list, sync=True)
227+
clean, residual, restored, gt_list = arlexecute.compute(ical_list, sync=True)
225228
centre = len(clean) // 2
226229
if self.persist:
227230
export_image_to_fits(clean[centre], '%s/test_pipelines_ical_global_pipeline_arlexecute_clean.fits' % self.dir)
228231
export_image_to_fits(residual[centre][0], '%s/test_pipelines_ical_global_pipeline_arlexecute_residual.fits' % self.dir)
229232
export_image_to_fits(restored[centre], '%s/test_pipelines_ical_global_pipeline_arlexecute_restored.fits' % self.dir)
230-
233+
export_gaintable_to_hdf5(gt_list[0]['T'],
234+
'%s/test_pipelines_ical_global_pipeline_arlexecute_gaintable.hdf5' %
235+
self.dir)
236+
231237
qa = qa_image(restored[centre])
232238
assert numpy.abs(qa.data['max'] - 98.92656340122159) < 1.0, str(qa)
233239
assert numpy.abs(qa.data['min'] + 0.7024492707920869) < 1.0, str(qa)

‎tests/workflows/test_pipelines_serial.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from astropy.coordinates import SkyCoord
1313

1414
from data_models.polarisation import PolarisationFrame
15+
from data_models.data_model_helpers import export_gaintable_to_hdf5
1516

1617
from workflows.serial.pipelines.pipeline_serial import ical_list_serial_workflow, continuum_imaging_list_serial_workflow
1718
from wrappers.serial.calibration.calibration_control import create_calibration_controls
@@ -150,7 +151,7 @@ def test_ical_pipeline(self):
150151
controls['T']['first_selfcal'] = 1
151152
controls['T']['timescale'] = 'auto'
152153

153-
clean, residual, restored = \
154+
clean, residual, restored, gt_list = \
154155
ical_list_serial_workflow(self.vis_list,
155156
model_imagelist=self.model_imagelist,
156157
context='2d',
@@ -168,7 +169,9 @@ def test_ical_pipeline(self):
168169
export_image_to_fits(clean[centre], '%s/test_pipelines_ical_pipeline_serial_clean.fits' % self.dir)
169170
export_image_to_fits(residual[centre][0], '%s/test_pipelines_ical_pipeline_serial_residual.fits' % self.dir)
170171
export_image_to_fits(restored[centre], '%s/test_pipelines_ical_pipeline_serial_restored.fits' % self.dir)
171-
172+
export_gaintable_to_hdf5(gt_list[centre], '%s/test_pipelines_ical_pipeline_serial_gaintable.hdf5' %
173+
self.dir)
174+
172175
qa = qa_image(restored[centre])
173176
assert numpy.abs(qa.data['max'] - 99.32729396999524) < 1.0, str(qa)
174177
assert numpy.abs(qa.data['min'] + 0.6501547522800477) < 1.0, str(qa)
@@ -179,7 +182,7 @@ def test_ical_pipeline_global(self):
179182
controls['T']['first_selfcal'] = 1
180183
controls['T']['timescale'] = 'auto'
181184

182-
clean, residual, restored = \
185+
clean, residual, restored, gt_list = \
183186
ical_list_serial_workflow(self.vis_list,
184187
model_imagelist=self.model_imagelist,
185188
context='2d',
@@ -198,7 +201,9 @@ def test_ical_pipeline_global(self):
198201
export_image_to_fits(clean[centre], '%s/test_pipelines_ical_global_pipeline_serial_clean.fits' % self.dir)
199202
export_image_to_fits(residual[centre][0], '%s/test_pipelines_ical_global_pipeline_serial_residual.fits' % self.dir)
200203
export_image_to_fits(restored[centre], '%s/test_pipelines_ical_global_pipeline_serial_restored.fits' % self.dir)
201-
204+
export_gaintable_to_hdf5(gt_list[centre], '%s/test_pipelines_ical_global_pipeline_serial_gaintable.hdf5' %
205+
self.dir)
206+
202207
qa = qa_image(restored[centre])
203208
assert numpy.abs(qa.data['max'] - 98.92656340122159) < 1.0, str(qa)
204209
assert numpy.abs(qa.data['min'] + 0.7024492707920869) < 1.0, str(qa)

‎workflows/arlexecute/calibration/calibration_arlexecute.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import numpy
66

7+
from data_models.data_model_helpers import GainTable
78
from wrappers.arlexecute.execution_support.arlexecute import arlexecute
89
from wrappers.arlexecute.calibration.calibration_control import calibrate_function, apply_calibration_function, \
910
solve_calibrate_function

‎workflows/arlexecute/pipelines/pipeline_arlexecute.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def ical_list_arlexecute_workflow(vis_list, model_imagelist, context, vis_slices
2323
:param kwargs: Parameters for functions in components
2424
:return:
2525
"""
26-
26+
27+
gt_list = list()
28+
2729
if gcfcf is None:
2830
gcfcf = [arlexecute.execute(create_pswf_convolutionfunction)(model_imagelist[0])]
2931

@@ -43,7 +45,7 @@ def ical_list_arlexecute_workflow(vis_list, model_imagelist, context, vis_slices
4345
model_vislist = predict_list_arlexecute_workflow(model_vislist, model_imagelist,
4446
context=context, vis_slices=vis_slices, facets=facets,
4547
gcgcf=gcfcf, **kwargs)
46-
cal_vis_list, _ = calibrate_list_arlexecute_workflow(cal_vis_list, model_vislist,
48+
cal_vis_list, gt_list = calibrate_list_arlexecute_workflow(cal_vis_list, model_vislist,
4749
calibration_context=calibration_context, **kwargs)
4850
residual_vislist = subtract_list_arlexecute_workflow(cal_vis_list, model_vislist)
4951
residual_imagelist = invert_list_arlexecute_workflow(residual_vislist, model_imagelist,
@@ -69,7 +71,7 @@ def ical_list_arlexecute_workflow(vis_list, model_imagelist, context, vis_slices
6971
context=context, vis_slices=vis_slices, facets=facets,
7072
gcgcf=gcfcf, **kwargs)
7173
cal_vis_list = [arlexecute.execute(copy_visibility, nout=1)(v) for v in vis_list]
72-
cal_vis_list, _ = calibrate_list_arlexecute_workflow(cal_vis_list, model_vislist,
74+
cal_vis_list, gt_list = calibrate_list_arlexecute_workflow(cal_vis_list, model_vislist,
7375
calibration_context=calibration_context,
7476
iteration=cycle, **kwargs)
7577
residual_vislist = subtract_list_arlexecute_workflow(cal_vis_list, model_vislist)
@@ -92,7 +94,7 @@ def ical_list_arlexecute_workflow(vis_list, model_imagelist, context, vis_slices
9294
residual_imagelist = residual_list_arlexecute_workflow(cal_vis_list, deconvolve_model_imagelist, context=context,
9395
vis_slices=vis_slices, facets=facets, gcgcf=gcfcf, **kwargs)
9496
restore_imagelist = restore_list_arlexecute_workflow(deconvolve_model_imagelist, psf_imagelist, residual_imagelist)
95-
return arlexecute.execute((deconvolve_model_imagelist, residual_imagelist, restore_imagelist))
97+
return arlexecute.execute((deconvolve_model_imagelist, residual_imagelist, restore_imagelist, gt_list))
9698

9799

98100
def continuum_imaging_list_arlexecute_workflow(vis_list, model_imagelist, context, gcfcf=None,

0 commit comments

Comments
 (0)