1414
1515import numpy
1616
17- from processing_library .image .operations import copy_image , create_empty_image_like
1817from data_models .memory_data_models import Image
1918from data_models .parameters import get_parameter
19+ from processing_library .image .operations import copy_image , create_empty_image_like
2020from workflows .shared .imaging .imaging_shared import imaging_context
2121from workflows .shared .imaging .imaging_shared import sum_invert_results , remove_sumwt , sum_predict_results , \
2222 threshold_list
@@ -192,10 +192,14 @@ def restore_list_arlexecute_workflow(model_imagelist, psf_imagelist, residual_im
192192 :param kwargs: Parameters for functions in components
193193 :return:
194194 """
195- return [arlexecute .execute (restore_cube )(model_imagelist [i ], psf_imagelist [i ][0 ],
196- residual_imagelist [i ][0 ], ** kwargs )
197- for i , _ in enumerate (model_imagelist )]
198-
195+ psf_list = arlexecute .execute (remove_sumwt )(psf_imagelist )
196+ residual_list = arlexecute .execute (remove_sumwt )(residual_imagelist )
197+ print ('model_imagelist' , model_imagelist )
198+ print ('psf_imagelist' , psf_imagelist )
199+ print ('residual_imagelist' , residual_imagelist )
200+ return [arlexecute .execute (restore_cube )(model_imagelist [i ], psf_list [i ],
201+ residual_list [i ], ** kwargs )
202+ for i , _ in enumerate (residual_imagelist )]
199203
200204def deconvolve_list_arlexecute_workflow (dirty_list , psf_list , model_imagelist , prefix = '' , ** kwargs ):
201205 """Create a graph for deconvolution, adding to the model
@@ -207,48 +211,46 @@ def deconvolve_list_arlexecute_workflow(dirty_list, psf_list, model_imagelist, p
207211 :return: (graph for the deconvolution, graph for the flat)
208212 """
209213 nchan = len (dirty_list )
210-
214+ nmoments = get_parameter (kwargs , "nmoments" , 0 )
215+
211216 def deconvolve (dirty , psf , model , facet , gthreshold ):
212- import time
213- starttime = time .time ()
214217 if prefix == '' :
215218 lprefix = "facet %d" % facet
216219 else :
217220 lprefix = "%s, facet %d" % (prefix , facet )
218221
219- nmoments = get_parameter (kwargs , "nmoments" , 0 )
220-
221222 if nmoments > 0 :
222223 moment0 = calculate_image_frequency_moments (dirty )
223224 this_peak = numpy .max (numpy .abs (moment0 .data [0 , ...])) / dirty .data .shape [0 ]
224225 else :
225226 this_peak = numpy .max (numpy .abs (dirty .data [0 , ...]))
226227
227228 if this_peak > 1.1 * gthreshold :
228- log .info (
229- "deconvolve_list_arlexecute_workflow %s: cleaning - peak %.6f > 1.1 * threshold %.6f" % (lprefix , this_peak ,
230- gthreshold ))
229+ # log.info(
230+ # "deconvolve_list_arlexecute_workflow %s: cleaning - peak %.6f > 1.1 * threshold %.6f" % (
231+ # lprefix, this_peak,
232+ # gthreshold))
231233 kwargs ['threshold' ] = gthreshold
232234 result , _ = deconvolve_cube (dirty , psf , prefix = lprefix , ** kwargs )
233235
234236 if result .data .shape [0 ] == model .data .shape [0 ]:
235237 result .data += model .data
236- else :
237- log .warning (
238- "deconvolve_list_arlexecute_workflow %s: Initial model %s and clean result %s do not have the same shape" %
239- (lprefix , str (model .data .shape [0 ]), str (result .data .shape [0 ])))
240-
238+ # else:
239+ # log.warning(
240+ # "deconvolve_list_arlexecute_workflow %s: Initial model %s and clean result %s do not have the same shape" %
241+ # (lprefix, str(model.data.shape[0]), str(result.data.shape[0])))
242+ #
241243 flux = numpy .sum (result .data [0 , 0 , ...])
242- log .info ('### %s, %.6f, %.6f, True, %.3f # cycle, facet, peak, cleaned flux, clean, time? '
243- % (lprefix , this_peak , flux , time . time () - starttime ))
244-
244+ # log.info('### %s, %.6f, %.6f, True, # cycle, facet, peak, cleaned flux, clean'
245+ # % (lprefix, this_peak, flux[0] ))
246+ #
245247 return result
246248 else :
247- log .info ("deconvolve_list_arlexecute_workflow %s: Not cleaning - peak %.6f <= 1.1 * threshold %.6f" % (
248- lprefix , this_peak ,
249- gthreshold ))
250- log .info ('### %s, %.6f, %.6f, False, %.3f # cycle, facet, peak, cleaned flux, clean, time? '
251- % (lprefix , this_peak , 0.0 , time . time () - starttime ))
249+ # log.info("deconvolve_list_arlexecute_workflow %s: Not cleaning - peak %.6f <= 1.1 * threshold %.6f" % (
250+ # lprefix, this_peak,
251+ # gthreshold))
252+ # log.info('### %s, %.6f, %.6f, False, %.3f # cycle, facet, peak, cleaned flux, clean'
253+ # % (lprefix, this_peak, 0.0))
252254
253255 return copy_image (model )
254256
@@ -264,21 +266,21 @@ def deconvolve(dirty, psf, model, facet, gthreshold):
264266
265267 # Scatter the separate channel images into deconvolve facets and then gather channels for each facet.
266268 # This avoids constructing the entire spectral cube.
267- # dirty_list = arlexecute.execute(remove_sumwt, nout=nchan)(dirty_list)
269+ dirty_list_trimmed = arlexecute .execute (remove_sumwt , nout = nchan )(dirty_list )
268270 scattered_channels_facets_dirty_list = \
269- [arlexecute .execute (image_scatter_facets , nout = deconvolve_number_facets )(d [ 0 ] , facets = deconvolve_facets ,
271+ [arlexecute .execute (image_scatter_facets , nout = deconvolve_number_facets )(d , facets = deconvolve_facets ,
270272 overlap = deconvolve_overlap ,
271273 taper = deconvolve_taper )
272- for d in dirty_list ]
274+ for d in dirty_list_trimmed ]
273275
274276 # Now we do a transpose and gather
275277 scattered_facets_list = [
276278 arlexecute .execute (image_gather_channels , nout = 1 )([scattered_channels_facets_dirty_list [chan ][facet ]
277279 for chan in range (nchan )])
278280 for facet in range (deconvolve_number_facets )]
279281
280- psf_list = arlexecute .execute (remove_sumwt , nout = nchan )(psf_list )
281- psf_list = arlexecute .execute (image_gather_channels , nout = 1 )(psf_list )
282+ psf_list_trimmed = arlexecute .execute (remove_sumwt , nout = nchan )(psf_list )
283+ psf_list_trimmed = arlexecute .execute (image_gather_channels , nout = 1 )(psf_list_trimmed )
282284
283285 scattered_model_imagelist = \
284286 arlexecute .execute (image_scatter_facets , nout = deconvolve_number_facets )(model_imagelist ,
@@ -299,7 +301,7 @@ def deconvolve(dirty, psf, model, facet, gthreshold):
299301
300302 facet_list = numpy .arange (deconvolve_number_facets ).astype ('int' )
301303 scattered_results_list = [
302- arlexecute .execute (deconvolve , nout = 1 )(d , psf_list , m , facet , global_threshold )
304+ arlexecute .execute (deconvolve , nout = 1 )(d , psf_list_trimmed , m , facet , global_threshold )
303305 for d , m , facet in zip (scattered_facets_list , scattered_model_imagelist , facet_list )]
304306
305307 # Gather the results back into one image, correcting for overlaps as necessary. The taper function is is used to
0 commit comments