Skip to content

Commit 41f1c25

Browse files
committed
imaging-dask fix
Creation used 512 pixels, processing used 256. Missing flux caused interesting errors.
1 parent 2435f3c commit 41f1c25

7 files changed

Lines changed: 104 additions & 52 deletions

File tree

‎arl/fourier_transforms/ftprocessor_params.py‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,9 @@ def advise_wide_field(vis, delA=0.02, oversampling_synthesised_beam=3.0, guard_b
232232
image_fov = primary_beam_fov * guard_band_image
233233
log.info("advise_wide_field: Image field of view %s" % (rad_and_deg(image_fov)))
234234

235-
facet_fov = primary_beam_fov * guard_band_image / facets
236-
log.info("advise_wide_field: Facet field of view %s" % (rad_and_deg(facet_fov)))
235+
if facets > 1:
236+
facet_fov = primary_beam_fov * guard_band_image / facets
237+
log.info("advise_wide_field: Facet field of view %s" % (rad_and_deg(facet_fov)))
237238

238239
synthesized_beam = 1.0 / (maximum_baseline)
239240
log.info("advise_wide_field: Synthesized beam %s" % (rad_and_deg(synthesized_beam)))
@@ -251,26 +252,29 @@ def advise_wide_field(vis, delA=0.02, oversampling_synthesised_beam=3.0, guard_b
251252
w_sampling_image = numpy.sqrt(2.0 * delA) / (numpy.pi * image_fov ** 2)
252253
log.info("advice_wide_field: W sampling for full image = %.1f (wavelengths)" % (w_sampling_image))
253254

254-
w_sampling_facet = numpy.sqrt(2.0 * delA) / (numpy.pi * facet_fov ** 2)
255-
log.info("advice_wide_field: W sampling for facet = %.1f (wavelengths)" % (w_sampling_image))
255+
if facets > 1:
256+
w_sampling_facet = numpy.sqrt(2.0 * delA) / (numpy.pi * facet_fov ** 2)
257+
log.info("advice_wide_field: W sampling for facet = %.1f (wavelengths)" % (w_sampling_image))
256258

257259
w_sampling_primary_beam = numpy.sqrt(2.0 * delA) / (numpy.pi * primary_beam_fov ** 2)
258260
log.info("advice_wide_field: W sampling for primary beam = %.1f (wavelengths)" % (w_sampling_primary_beam))
259261

260262
time_sampling_image = 86400.0 * w_sampling_image / (numpy.pi * maximum_baseline)
261263
log.info("advice_wide_field: Time sampling for full image = %.1f (s)" % (time_sampling_image))
262264

263-
time_sampling_facet = 86400.0 * w_sampling_facet / (numpy.pi * maximum_baseline)
264-
log.info("advice_wide_field: Time sampling for facet = %.1f (s)" % (time_sampling_facet))
265+
if facets > 1:
266+
time_sampling_facet = 86400.0 * w_sampling_facet / (numpy.pi * maximum_baseline)
267+
log.info("advice_wide_field: Time sampling for facet = %.1f (s)" % (time_sampling_facet))
265268

266269
time_sampling_primary_beam = 86400.0 * w_sampling_primary_beam / (numpy.pi * maximum_baseline)
267270
log.info("advice_wide_field: Time sampling for primary beam = %.1f (s)" % (time_sampling_primary_beam))
268271

269272
freq_sampling_image = numpy.max(vis.frequency) * w_sampling_image / (numpy.pi * maximum_baseline)
270273
log.info("advice_wide_field: Frequency sampling for full image = %.1f (Hz)" % (freq_sampling_image))
271274

272-
freq_sampling_facet = numpy.max(vis.frequency) * w_sampling_facet / (numpy.pi * maximum_baseline)
273-
log.info("advice_wide_field: Frequency sampling for facet = %.1f (Hz)" % (freq_sampling_facet))
275+
if facets > 1:
276+
freq_sampling_facet = numpy.max(vis.frequency) * w_sampling_facet / (numpy.pi * maximum_baseline)
277+
log.info("advice_wide_field: Frequency sampling for facet = %.1f (Hz)" % (freq_sampling_facet))
274278

275279
freq_sampling_primary_beam = numpy.max(vis.frequency) * w_sampling_primary_beam / (numpy.pi * maximum_baseline)
276280
log.info("advice_wide_field: Frequency sampling for primary beam = %.1f (Hz)" % (freq_sampling_primary_beam))

‎arl/graphs/dask_init.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ def get_dask_Client(timeout=30):
1515
scheduler = os.getenv('ARL_DASK_SCHEDULER', None)
1616
if scheduler is not None:
1717
print("Creating Dask Client using externally defined scheduler")
18-
return Client(scheduler, timeout=timeout)
18+
c = Client(scheduler, timeout=timeout)
19+
print(c)
1920
else:
2021
print("Creating Dask Client")
21-
return Client(timeout=timeout)
22-
22+
c = Client(timeout=timeout)
23+
print(c)
24+
25+
addr = c.scheduler_info()['address']
26+
bokeh_addr = 'http:%s:%s' % (addr.split(':')[1], c.scheduler_info()['services']['bokeh'])
27+
print('Diagnostic pages available on port %s' % bokeh_addr)
28+
return c
29+
30+
2331
def kill_dask_Scheduler(client):
2432
""" Kill the process graphs-ssh"""
2533
import psutil, signal

‎docs/ARL_dask.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ These are well-modeled in ARL.
1616
Conceptually we can think of one visibility set, which may be decomposed into different subsets in processing, and
1717
one image, which also may be subsetted for processing.
1818

19+
Dask is supported in various ways:
20+
21+
- arl/graphs/dask_graphs: Graphs to perform various types of prediction and inversion of visibility data
22+
- arl/graphs/generic_dask_graphs: Graphs to perform generic image or visibility unary operations
23+
- arl/util/dask_graph_support: Graphs to support testing and simulations
24+
- arl/pipelines/pipeline_dask_graphs: Graphs to implement the canonical pipelines (ICAL and Continuum imaging
25+
currently).
26+
27+
In addition there are notebooks:
28+
29+
- imaging-dask: General imaging example
30+
- imaging-pipelines: Pipelines run on small LOW observation (core only)
31+
32+
These notebooks are scaled to run on my laptop (4 cores, 16GB) but can be changed to larger scales.
33+
1934
Using ARL and dask on Darwin
2035
****************************
2136

‎docs/ARL_quickstart.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ See the jupyter note books below:
4343
arl/peeling
4444
arl/simple-dask
4545
arl/imaging-dask
46+
arl/imaging-pipelines
4647
arl/imaging-spectral
4748

4849
In addition, there are other notebooks in examples/arl that are not built as part of this documentation. See e.g.

‎examples/arl/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
NBs = imaging.ipynb imaging-wterm.ipynb imaging-fits.ipynb imaging-mfs.ipynb peeling.ipynb rcal.ipynb peeling.ipynb \
3-
imaging-dask.ipynb imaging-spectral.ipynb simple-dask.ipynb
3+
imaging-dask.ipynb imaging-pipelines.ipynb imaging-spectral.ipynb simple-dask.ipynb
44
include ../jupyter.mk

‎examples/arl/imaging-dask.ipynb‎

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
"source": [
77
"# Dask imaging demonstration\n",
88
"\n",
9-
"This notebook explores the use of dask for parallelisation. We work through the steps of imaging using dask, ending up with a major/minor cycle algorithm without and with selfcalibration.\n",
10-
"\n",
11-
"The functions used are in pipelines/dask_graphs.py"
9+
"This notebook explores the use of dask for parallelisation. We work through the steps of imaging using dask, ending up with a major/minor cycle algorithm without and with selfcalibration."
1210
]
1311
},
1412
{
@@ -110,7 +108,7 @@
110108
" vt = create_blockvisibility(lowcore, times, frequency, channel_bandwidth=channel_bandwidth,\n",
111109
" weight=1.0, phasecentre=phasecentre, \n",
112110
" polarisation_frame=PolarisationFrame(\"stokesI\"))\n",
113-
" npixel = 512\n",
111+
" npixel = 256\n",
114112
" cellsize=0.001\n",
115113
" model = create_image_from_visibility(vt, npixel=npixel, cellsize=cellsize, npol=1, frequency=reffrequency,\n",
116114
" polarisation_frame=PolarisationFrame(\"stokesI\"))\n",
@@ -158,6 +156,13 @@
158156
" return model"
159157
]
160158
},
159+
{
160+
"cell_type": "markdown",
161+
"metadata": {},
162+
"source": [
163+
"Now create the graphs to define the visibility sets, one without errors and one with 1 radian phase errors."
164+
]
165+
},
161166
{
162167
"cell_type": "code",
163168
"execution_count": null,
@@ -167,7 +172,7 @@
167172
},
168173
"outputs": [],
169174
"source": [
170-
"nfreqwin=7\n",
175+
"nfreqwin=3\n",
171176
"vis_graph_list=list()\n",
172177
"for freq in numpy.linspace(0.8e8,1.2e8,nfreqwin):\n",
173178
" vis_graph_list.append(delayed(ingest_visibility)(freq, time=0.0))\n",
@@ -196,12 +201,11 @@
196201
"cell_type": "code",
197202
"execution_count": null,
198203
"metadata": {
199-
"collapsed": true,
200204
"scrolled": false
201205
},
202206
"outputs": [],
203207
"source": [
204-
"advice=advise_wide_field(vis_graph_list[0].compute(), guard_band_image=0.5)"
208+
"advice=advise_wide_field(vis_graph_list[0].compute(), guard_band_image=6.0)"
205209
]
206210
},
207211
{
@@ -215,7 +219,6 @@
215219
"cell_type": "code",
216220
"execution_count": null,
217221
"metadata": {
218-
"collapsed": true,
219222
"scrolled": false
220223
},
221224
"outputs": [],
@@ -229,14 +232,13 @@
229232
"cell_type": "markdown",
230233
"metadata": {},
231234
"source": [
232-
"Make and display a graph to predict using w stacking"
235+
"Make and display a graph from invert using w stacking"
233236
]
234237
},
235238
{
236239
"cell_type": "code",
237240
"execution_count": null,
238241
"metadata": {
239-
"collapsed": true,
240242
"scrolled": false
241243
},
242244
"outputs": [],
@@ -249,15 +251,13 @@
249251
"cell_type": "markdown",
250252
"metadata": {},
251253
"source": [
252-
"Do the same for invert"
254+
"Do the same for invert. note the difference in structure of the graphs."
253255
]
254256
},
255257
{
256258
"cell_type": "code",
257259
"execution_count": null,
258-
"metadata": {
259-
"collapsed": true
260-
},
260+
"metadata": {},
261261
"outputs": [],
262262
"source": [
263263
"dirty_graph = create_invert_facet_graph(vis_graph_list, model_graph, dopsf=False, \n",
@@ -270,7 +270,6 @@
270270
"cell_type": "code",
271271
"execution_count": null,
272272
"metadata": {
273-
"collapsed": true,
274273
"scrolled": false
275274
},
276275
"outputs": [],
@@ -284,27 +283,24 @@
284283
"cell_type": "markdown",
285284
"metadata": {},
286285
"source": [
287-
"Now compute the dirty image using this graph"
286+
"Now compute the dirty image using this graph We can do this either by using the compute() method of the graph or we can create a distributed.Client and use that. With the latter, information about the processing can be seen at tcp://127.0.0.1:8787."
288287
]
289288
},
290289
{
291290
"cell_type": "code",
292291
"execution_count": null,
293292
"metadata": {
294-
"collapsed": true,
295293
"scrolled": false
296294
},
297295
"outputs": [],
298296
"source": [
299-
"c=get_dask_Client()\n",
300-
"print(c)"
297+
"c=get_dask_Client()"
301298
]
302299
},
303300
{
304301
"cell_type": "code",
305302
"execution_count": null,
306303
"metadata": {
307-
"collapsed": true,
308304
"scrolled": false
309305
},
310306
"outputs": [],
@@ -340,15 +336,13 @@
340336
" vis_slices=91, \n",
341337
" algorithm='hogbom', niter=1000, \n",
342338
" fractional_threshold=0.1, threshold=0.2, nmajor=2,\n",
343-
" gain=0.1, facets=4)"
339+
" gain=0.1, facets=1)"
344340
]
345341
},
346342
{
347343
"cell_type": "code",
348344
"execution_count": null,
349-
"metadata": {
350-
"collapsed": true
351-
},
345+
"metadata": {},
352346
"outputs": [],
353347
"source": [
354348
"future=c.compute(continuum_imaging_graph)"
@@ -358,7 +352,6 @@
358352
"cell_type": "code",
359353
"execution_count": null,
360354
"metadata": {
361-
"collapsed": true,
362355
"scrolled": false
363356
},
364357
"outputs": [],
@@ -395,8 +388,8 @@
395388
" c_residual_graph=create_residual_wstack_graph,\n",
396389
" vis_slices=91, \n",
397390
" algorithm='hogbom', niter=1000, \n",
398-
" fractional_threshold=0.1, threshold=0.2, nmajor=4,\n",
399-
" gain=0.1, facets=4, first_selfcal=1)\n",
391+
" fractional_threshold=0.1, threshold=0.2, nmajor=5,\n",
392+
" gain=0.1, facets=1, first_selfcal=1)\n",
400393
"#g=simple_vis(ical_graph, filename='imaging-dask-ical-graph-slices11', format='svg')"
401394
]
402395
},
@@ -415,7 +408,6 @@
415408
"cell_type": "code",
416409
"execution_count": null,
417410
"metadata": {
418-
"collapsed": true,
419411
"scrolled": false
420412
},
421413
"outputs": [],
@@ -441,7 +433,6 @@
441433
"cell_type": "code",
442434
"execution_count": null,
443435
"metadata": {
444-
"collapsed": true,
445436
"scrolled": true
446437
},
447438
"outputs": [],

0 commit comments

Comments
 (0)