def setUp(self): self.persist = os.getenv("RASCIL_PERSIST", False) from rascil.data_models.parameters import rascil_path dec = -40.0 * u.deg self.lowcore = create_named_configuration('LOWBD2', rmax=300.0) self.dir = rascil_path('test_results') self.times = numpy.linspace(-10.0, 10.0, 3) * numpy.pi / (3600.0 * 12.0) self.frequency = numpy.array([1e8, 1.5e8, 2.0e8]) self.channel_bandwidth = numpy.array([5e7, 5e7, 5e7]) self.phasecentre = SkyCoord(ra=+0.0 * u.deg, dec=dec, frame='icrs', equinox='J2000') self.vis = create_blockvisibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI')) self.vis.data['vis'] *= 0.0 # Create model self.model = create_image( npixel=512, cellsize=0.000015, polarisation_frame=PolarisationFrame("stokesI"), frequency=self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre)
def setUp(self): from rascil.data_models.parameters import rascil_path self.doplot = False self.midcore = create_named_configuration('MID', rmax=300.0) self.nants = len(self.midcore.names) self.dir = rascil_path('test_results') self.ntimes = 30 self.times = numpy.linspace(-5.0, 5.0, self.ntimes) * numpy.pi / (12.0) self.frequency = numpy.array([1e9]) self.channel_bandwidth = numpy.array([1e7]) self.phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-45.0 * u.deg, frame='icrs', equinox='J2000') self.vis = create_blockvisibility( self.midcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI')) self.vis.data['vis'] *= 0.0 # Create model self.model = create_image( npixel=512, cellsize=0.00015, polarisation_frame=PolarisationFrame("stokesI"), frequency=self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre)
def test_partition_skycomponent_neighbours(self): all_components = create_low_test_skycomponents_from_gleam( flux_limit=0.1, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) bright_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) model = create_image(npixel=512, cellsize=0.001, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) beam = create_low_test_beam(model, use_local=False) all_components = apply_beam_to_skycomponent(all_components, beam) all_components = filter_skycomponents_by_flux(all_components, flux_min=0.1) bright_components = apply_beam_to_skycomponent(bright_components, beam) bright_components = filter_skycomponents_by_flux(bright_components, flux_min=2.0) comps_lists = partition_skycomponent_neighbours( all_components, bright_components) assert len(comps_lists) == len(bright_components) assert len(comps_lists[0]) > 0 assert len(comps_lists[-1]) > 0
def test_create_image_(self): newimage = create_image( npixel=1024, cellsize=0.001, polarisation_frame=PolarisationFrame("stokesIQUV"), frequency=numpy.linspace(0.8e9, 1.2e9, 5), channel_bandwidth=1e7 * numpy.ones([5])) assert newimage.shape == (5, 4, 1024, 1024)
def setUp(self): from rascil.data_models.parameters import rascil_path self.dir = rascil_path('test_results') self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000') self.image = create_image( npixel=512, cellsize=0.0005, phasecentre=self.phasecentre, polarisation_frame=PolarisationFrame("stokesI")) self.persist = os.getenv("RASCIL_PERSIST", False)
def test_create_w_term_image(self): newimage = create_image( npixel=1024, cellsize=0.001, polarisation_frame=PolarisationFrame("stokesIQUV"), frequency=numpy.linspace(0.8e9, 1.2e9, 5), channel_bandwidth=1e7 * numpy.ones([5])) im = create_w_term_like(newimage, w=2000.0, remove_shift=True, dopol=True) im.data = im.data.real for x in [256, 768]: for y in [256, 768]: self.assertAlmostEqual(im.data[0, 0, y, x], -0.46042631800538464, 7) export_image_to_fits(im, '%s/test_wterm.fits' % self.dir) assert im.data.shape == (5, 4, 1024, 1024), im.data.shape self.assertAlmostEqual(numpy.max(im.data.real), 1.0, 7)
def test_voronoi_decomposition(self): bright_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) model = create_image(npixel=512, cellsize=0.001, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) beam = create_low_test_beam(model, use_local=False) bright_components = apply_beam_to_skycomponent(bright_components, beam) bright_components = filter_skycomponents_by_flux(bright_components, flux_min=2.0) vor, vor_array = voronoi_decomposition(model, bright_components) assert len(bright_components) == (numpy.max(vor_array) + 1)
def test_expand_skymodel_voronoi(self): self.model = create_image( npixel=256, cellsize=0.001, polarisation_frame=PolarisationFrame("stokesI"), frequency=self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre) beam = create_low_test_beam(self.model, use_local=False) gleam_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.1) pb_gleam_components = apply_beam_to_skycomponent( gleam_components, beam) actual_components = filter_skycomponents_by_flux(pb_gleam_components, flux_min=1.0) _, actual_components = remove_neighbouring_components( actual_components, 0.05) for imask, mask in enumerate( image_voronoi_iter(self.model, actual_components)): mask.data *= beam.data assert isinstance(mask, Image) assert mask.data.dtype == "float" assert numpy.sum(mask.data) > 1 # import matplotlib.pyplot as plt # from rascil.processing_components.image.operations import show_image # show_image(mask) # plt.show(block=False) assert len(actual_components) == 9, len(actual_components) sm = SkyModel(image=self.model, components=actual_components) assert len(sm.components) == len(actual_components) scatter_sm = expand_skymodel_by_skycomponents(sm) assert len(scatter_sm) == len(actual_components) + 1 assert len(scatter_sm[0].components) == 1
def test_image_voronoi_iter(self): bright_components = create_low_test_skycomponents_from_gleam( flux_limit=1.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) model = create_image(npixel=512, cellsize=0.001, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) model.data[...] = 1.0 beam = create_low_test_beam(model, use_local=False) bright_components = apply_beam_to_skycomponent(bright_components, beam) bright_components = filter_skycomponents_by_flux(bright_components, flux_min=2.0) for im in image_voronoi_iter(model, bright_components): assert numpy.sum(im.data) > 1
def actualSetup(self, atmosphere="ionosphere"): dec = -40.0 * u.deg self.times = numpy.linspace(-10.0, 10.0, 3) * numpy.pi / (3600.0 * 12.0) self.phasecentre = SkyCoord(ra=+0.0 * u.deg, dec=dec, frame='icrs', equinox='J2000') if atmosphere == "ionosphere": self.core = create_named_configuration('LOWBD2', rmax=300.0) self.frequency = numpy.array([1.0e8]) self.channel_bandwidth = numpy.array([5e7]) self.cellsize = 0.000015 else: self.core = create_named_configuration('MID', rmax=300.0) self.frequency = numpy.array([1.36e9]) self.channel_bandwidth = numpy.array([1e8]) self.cellsize = 0.00015 self.vis = create_blockvisibility( self.core, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI')) self.vis.data['vis'] *= 0.0 # Create model self.model = create_image( npixel=512, cellsize=0.000015, polarisation_frame=PolarisationFrame("stokesI"), frequency=self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre)
def test_fill_vpterm_to_convolutionfunction(self): self.image = create_image( npixel=512, cellsize=0.0005, phasecentre=self.phasecentre, frequency=numpy.array([1.36e9]), polarisation_frame=PolarisationFrame("stokesIQUV")) make_vp = functools.partial(create_vp, telescope="MID_FEKO_B2") gcf, cf = create_vpterm_convolutionfunction(self.image, make_vp=make_vp, oversampling=16, support=32, use_aaf=True) cf_image = convert_convolutionfunction_to_image(cf) cf_image.data = numpy.real(cf_image.data) if self.persist: export_image_to_fits( cf_image, "%s/test_convolutionfunction_aterm_vp_cf.fits" % self.dir) # Tests for the VP convolution function are different because it does not peak # at the centre of the uv plane peak_location = numpy.unravel_index(numpy.argmax(numpy.abs(cf.data)), cf.shape) assert numpy.abs(cf.data[peak_location] - (0.005285675638650622 + 0.000494340010248879j) ) < 1e-7, cf.data[peak_location] assert peak_location == (0, 3, 0, 11, 8, 11, 16), peak_location u_peak, v_peak = cf.grid_wcs.sub([1, 2]).wcs_pix2world( peak_location[-2], peak_location[-1], 0) assert numpy.abs(u_peak - 19.53125) < 1e-7, u_peak assert numpy.abs(v_peak) < 1e-7, u_peak if self.persist: export_image_to_fits( gcf, "%s/test_convolutionfunction_aterm_vp_gcf.fits" % self.dir)
def test_remove_neighbouring_components(self): all_components = create_low_test_skycomponents_from_gleam( flux_limit=3.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.5) model = create_image(npixel=512, cellsize=0.001, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) beam = create_low_test_beam(model, use_local=False) all_components = apply_beam_to_skycomponent(all_components, beam) all_components = filter_skycomponents_by_flux(all_components, flux_min=0.1) idx, comps = remove_neighbouring_components(all_components, 0.1) assert idx == [ 0, 1, 3, 8, 12, 13, 17, 22, 25, 26, 29, 32, 35, 38, 41, 42, 46, 47, 50, 52, 53, 56, 57, 58, 61, 63, 66, 68, 70 ], idx assert comps[0].name == 'GLEAM J215739-661155', comps[0].name
def create_simulation_components(context, phasecentre, frequency, pbtype, offset_dir, flux_limit, pbradius, pb_npixel, pb_cellsize, show=False): """ Construct components for simulation :param context: :param phasecentre: :param frequency: :param pbtype: :param offset_dir: :param flux_limit: :param pbradius: :param pb_npixel: :param pb_cellsize: :return: """ HWHM_deg, null_az_deg, null_el_deg = find_pb_width_null(pbtype, frequency) dec = phasecentre.dec.deg ra = phasecentre.ra.deg if context == 'singlesource': log.info("create_simulation_components: Constructing single component") offset = [HWHM_deg * offset_dir[0], HWHM_deg * offset_dir[1]] log.info( "create_simulation_components: Offset from pointing centre = %.3f, %.3f deg" % (offset[0], offset[1])) # The point source is offset to approximately the halfpower point offset_direction = SkyCoord( ra=(ra + offset[0] / numpy.cos(numpy.pi * dec / 180.0)) * units.deg, dec=(dec + offset[1]) * units.deg, frame='icrs', equinox='J2000') original_components = [ Skycomponent(flux=[[1.0]], direction=offset_direction, frequency=frequency, polarisation_frame=PolarisationFrame('stokesI')) ] elif context == 'null': log.info( "create_simulation_components: Constructing single component at the null" ) offset = [null_az_deg * offset_dir[0], null_el_deg * offset_dir[1]] HWHM = HWHM_deg * numpy.pi / 180.0 log.info( "create_simulation_components: Offset from pointing centre = %.3f, %.3f deg" % (offset[0], offset[1])) # The point source is offset to approximately the null point offset_direction = SkyCoord( ra=(ra + offset[0] / numpy.cos(numpy.pi * dec / 180.0)) * units.deg, dec=(dec + offset[1]) * units.deg, frame='icrs', equinox='J2000') original_components = [ Skycomponent(flux=[[1.0]], direction=offset_direction, frequency=frequency, polarisation_frame=PolarisationFrame('stokesI')) ] else: offset = [0.0, 0.0] # Make a skymodel from S3 max_flux = 0.0 total_flux = 0.0 log.info("create_simulation_components: Constructing s3sky components") from rascil.processing_components.simulation import create_test_skycomponents_from_s3 original_components = create_test_skycomponents_from_s3( flux_limit=flux_limit / 100.0, phasecentre=phasecentre, polarisation_frame=PolarisationFrame("stokesI"), frequency=numpy.array(frequency), radius=pbradius) log.info( "create_simulation_components: %d components before application of primary beam" % (len(original_components))) pbmodel = create_image(npixel=pb_npixel, cellsize=pb_cellsize, phasecentre=phasecentre, frequency=frequency, polarisation_frame=PolarisationFrame("stokesI")) pb = create_pb(pbmodel, "MID_GAUSS", pointingcentre=phasecentre, use_local=False) pb_feko = create_pb(pbmodel, pbtype, pointingcentre=phasecentre, use_local=True) pb.data = pb_feko.data[:, 0, ...][:, numpy.newaxis, ...] pb_applied_components = [ copy_skycomponent(c) for c in original_components ] pb_applied_components = apply_beam_to_skycomponent( pb_applied_components, pb) filtered_components = [] for icomp, comp in enumerate(pb_applied_components): if comp.flux[0, 0] > flux_limit: total_flux += comp.flux[0, 0] if abs(comp.flux[0, 0]) > max_flux: max_flux = abs(comp.flux[0, 0]) filtered_components.append(original_components[icomp]) log.info( "create_simulation_components: %d components > %.3f Jy after application of primary beam" % (len(filtered_components), flux_limit)) log.info( "create_simulation_components: Strongest components is %g (Jy)" % max_flux) log.info( "create_simulation_components: Total flux in components is %g (Jy)" % total_flux) original_components = [ copy_skycomponent(c) for c in filtered_components ] if show: plt.clf() show_image(pb, components=original_components) plt.show(block=False) log.info("create_simulation_components: Created %d components" % len(original_components)) # Primary beam points to the phasecentre offset_direction = SkyCoord(ra=ra * units.deg, dec=dec * units.deg, frame='icrs', equinox='J2000') return original_components, offset_direction
def trial_case(results, seed=180555, context='wstack', nworkers=8, threads_per_worker=1, memory=8, processes=True, order='frequency', nfreqwin=7, ntimes=3, rmax=750.0, facets=1, wprojection_planes=1, use_dask=True, use_serial_imaging=True, flux_limit=0.3, nmajor=5, dft_threshold=1.0, use_serial_clean=True, write_fits=False): """ Single trial for performance-timings Simulates visibilities from GLEAM including phase errors Makes dirty image and PSF Runs ICAL pipeline The results are in a dictionary: 'context': input - a string describing concisely the purpose of the test 'time overall', overall execution time (s) 'time predict', time to execute GLEAM prediction graph 'time invert', time to make dirty image 'time invert graph', time to make dirty image graph 'time ICAL graph', time to create ICAL graph 'time ICAL', time to execute ICAL graph 'context', type of imaging e.g. 'wstack' 'nworkers', number of workers to create 'threads_per_worker', 'nnodes', Number of nodes, 'processes', 'order', Ordering of data_models 'nfreqwin', Number of frequency windows in simulation 'ntimes', Number of hour angles in simulation 'rmax', Maximum radius of stations used in simulation (m) 'facets', Number of facets in deconvolution and imaging 'wprojection_planes', Number of wprojection planes 'vis_slices', Number of visibility slices (per Visibbility) 'npixel', Number of pixels in image 'cellsize', Cellsize in radians 'seed', Random number seed 'dirty_max', Maximum in dirty image 'dirty_min', Minimum in dirty image 'restored_max', 'restored_min', 'deconvolved_max', 'deconvolved_min', 'residual_max', 'residual_min', 'git_info', GIT hash (not definitive since local mods are possible) :param results: Initial state :param seed: Random number seed (used in gain simulations) :param context: imaging context :param context: Type of context: '2d'|'timeslice'|'wstack' :param nworkers: Number of dask workers to use :param threads_per_worker: Number of threads per worker :param processes: Use processes instead of threads 'processes'|'threads' :param order: See simulate_list_list_rsexecute_workflow_workflowkflow :param nfreqwin: See simulate_list_list_rsexecute_workflow_workflowkflow :param ntimes: See simulate_list_list_rsexecute_workflow_workflowkflow :param rmax: See simulate_list_list_rsexecute_workflow_workflowkflow :param facets: Number of facets to use :param wprojection_planes: Number of wprojection planes to use :param use_dask: Use dask or immediate evaluation :return: results dictionary """ if use_dask: scheduler = os.getenv('RASCIL_DASK_SCHEDULER', None) if scheduler is not None: client = get_dask_client(n_workers=nworkers, memory_limit=memory * 1024 * 1024 * 1024, threads_per_worker=threads_per_worker) rsexecute.set_client(client=client) else: rsexecute.set_client(threads_per_worker=threads_per_worker, processes=threads_per_worker == 1, memory_limit=memory * 1024 * 1024 * 1024, n_workers=nworkers) print("Defined %d workers" % (nworkers)) else: rsexecute.set_client(use_dask=use_dask) results['nnodes'] = 1 def init_logging(): logging.basicConfig( filename='pipelines_rsexecute_timings.log', filemode='w', format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s', datefmt='%H:%M:%S', level=logging.INFO) init_logging() log = logging.getLogger() # Initialise logging on the workers. This appears to only work using the process scheduler. rsexecute.run(init_logging) def lprint(*args): log.info(*args) print(*args) lprint("Starting pipelines_rsexecute_timings") numpy.random.seed(seed) results['seed'] = seed start_all = time.time() results['context'] = context results['hostname'] = socket.gethostname() results['git_hash'] = git_hash() results['epoch'] = time.strftime("%Y-%m-%d %H:%M:%S") lprint("Context is %s" % context) results['nworkers'] = nworkers results['threads_per_worker'] = threads_per_worker results['processes'] = processes results['memory'] = memory results['order'] = order results['nfreqwin'] = nfreqwin results['ntimes'] = ntimes results['rmax'] = rmax results['facets'] = facets results['wprojection_planes'] = wprojection_planes results['dft threshold'] = dft_threshold results['use_dask'] = use_dask lprint("At start, configuration is:") lprint(sort_dict(results)) # Parameters determining scale of simulation. frequency = numpy.linspace(1.0e8, 1.2e8, nfreqwin) centre = nfreqwin // 2 if nfreqwin > 1: channel_bandwidth = numpy.array(nfreqwin * [frequency[1] - frequency[0]]) else: channel_bandwidth = numpy.array([1e6]) times = numpy.linspace(-numpy.pi / 4.0, numpy.pi / 4.0, ntimes) phasecentre = SkyCoord(ra=+0.0 * u.deg, dec=-40.0 * u.deg, frame='icrs', equinox='J2000') lprint("****** Visibility creation ******") # Create the empty BlockVisibility's and persist these on the cluster tmp_bvis_list = simulate_list_rsexecute_workflow( 'LOWBD2', frequency=frequency, channel_bandwidth=channel_bandwidth, times=times, phasecentre=phasecentre, order=order, format='blockvis', rmax=rmax) tmp_vis_list = [ rsexecute.execute(convert_blockvisibility_to_visibility)(bv) for bv in tmp_bvis_list ] tmp_vis_list = rsexecute.client.compute(tmp_vis_list, sync=True) vis_list = rsexecute.gather(tmp_vis_list) import matplotlib.pyplot as plt plt.clf() plt.hist(vis_list[0].w, bins=100) plt.title('Histogram of w samples: rms=%.1f (wavelengths)' % numpy.std(vis_list[0].w)) plt.xlabel('W (wavelengths)') #plt.show() plt.clf() plt.hist(vis_list[0].uvdist, bins=100) plt.title('Histogram of uvdistance samples') plt.xlabel('UV Distance (wavelengths)') #plt.show() rsexecute.client.cancel(tmp_vis_list) future_vis_list = rsexecute.scatter(vis_list) # Find the best imaging parameters but don't bring the vis_list back here print("****** Finding wide field parameters ******") future_advice = [ rsexecute.execute(advise_wide_field)( v, guard_band_image=6.0, delA=0.1, facets=facets, wprojection_planes=wprojection_planes, oversampling_synthesised_beam=4.0) for v in future_vis_list ] future_advice = rsexecute.compute(future_advice) advice = rsexecute.client.gather(future_advice)[-1] rsexecute.client.cancel(future_advice) # Deconvolution via sub-images requires 2^n npixel = advice['npixels2'] results['npixel'] = npixel cellsize = advice['cellsize'] results['cellsize'] = cellsize lprint("Image will have %d by %d pixels, cellsize = %.6f rad" % (npixel, npixel, cellsize)) # Create an empty model image tmp_model_list = [ rsexecute.execute(create_image)( npixel=npixel, cellsize=cellsize, frequency=[frequency[f]], channel_bandwidth=[channel_bandwidth[f]], phasecentre=phasecentre, polarisation_frame=PolarisationFrame("stokesI")) for f, freq in enumerate(frequency) ] model_list = rsexecute.compute(tmp_model_list, sync=True) future_model_list = rsexecute.scatter(model_list) lprint("****** Setting up imaging parameters ******") # Now set up the imaging parameters template_model = create_image( npixel=npixel, cellsize=cellsize, frequency=[frequency[centre]], phasecentre=phasecentre, channel_bandwidth=[channel_bandwidth[centre]], polarisation_frame=PolarisationFrame("stokesI")) gcfcf = [create_pswf_convolutionfunction(template_model)] if context == 'timeslice': vis_slices = ntimes lprint("Using timeslice with %d slices" % vis_slices) elif context == '2d': vis_slices = 1 elif context == "wprojection": wstep = advice['wstep'] nw = advice['wprojection_planes'] vis_slices = 1 support = advice['nwpixels'] results['wprojection_planes'] = nw lprint("****** Starting W projection kernel creation ******") lprint("Using wprojection with %d planes with wstep %.1f wavelengths" % (nw, wstep)) lprint("Support of wprojection = %d pixels" % support) gcfcf = [ create_awterm_convolutionfunction(template_model, nw=nw, wstep=wstep, oversampling=4, support=support, use_aaf=True) ] lprint("Size of W projection gcf, cf = %.2E bytes" % get_size(gcfcf)) else: context = 'wstack' vis_slices = advice['vis_slices'] lprint("Using wstack with %d slices" % vis_slices) gcfcf = rsexecute.scatter(gcfcf, broadcast=True) results['vis_slices'] = vis_slices # Make a skymodel from gleam, with bright sources as components and weak sources in an image lprint("****** Starting GLEAM skymodel creation ******") future_skymodel_list = [ rsexecute.execute(create_low_test_skymodel_from_gleam)( npixel=npixel, cellsize=cellsize, frequency=[frequency[f]], phasecentre=phasecentre, polarisation_frame=PolarisationFrame("stokesI"), flux_limit=flux_limit, flux_threshold=dft_threshold, flux_max=5.0) for f, freq in enumerate(frequency) ] # We use predict_skymodel so that we can use skycomponents as well as images lprint("****** Starting GLEAM skymodel prediction ******") predicted_vis_list = [ predict_skymodel_list_rsexecute_workflow(future_vis_list[f], [future_skymodel_list[f]], context=context, vis_slices=vis_slices, facets=facets, gcfcf=gcfcf)[0] for f, freq in enumerate(frequency) ] # Corrupt the visibility for the GLEAM model lprint("****** Visibility corruption ******") tmp_corrupted_vis_list = corrupt_list_rsexecute_workflow( predicted_vis_list, phase_error=1.0, seed=seed) lprint("****** Weighting and tapering ******") tmp_corrupted_vis_list = weight_list_rsexecute_workflow( tmp_corrupted_vis_list, future_model_list) tmp_corrupted_vis_list = taper_list_rsexecute_workflow( tmp_corrupted_vis_list, 0.003 * 750.0 / rmax) tmp_corrupted_vis_list = rsexecute.compute(tmp_corrupted_vis_list, sync=True) corrupted_vis_list = rsexecute.gather(tmp_corrupted_vis_list) # rsexecute.client.cancel(predicted_vis_list) rsexecute.client.cancel(tmp_corrupted_vis_list) future_corrupted_vis_list = rsexecute.scatter(corrupted_vis_list) # At this point the only futures are of scatter'ed data so no repeated calculations should be # incurred. lprint("****** Starting dirty image calculation ******") start = time.time() dirty_list = invert_list_rsexecute_workflow( future_corrupted_vis_list, future_model_list, vis_slices=vis_slices, context=context, facets=facets, use_serial_invert=use_serial_imaging, gcfcf=gcfcf) results['size invert graph'] = get_size(dirty_list) lprint('Size of dirty graph is %.3E bytes' % (results['size invert graph'])) end = time.time() results['time invert graph'] = end - start lprint("Construction of invert graph took %.3f seconds" % (end - start)) start = time.time() dirty, sumwt = rsexecute.compute(dirty_list, sync=True)[centre] end = time.time() results['time invert'] = end - start lprint("Dirty image invert took %.3f seconds" % (end - start)) lprint("Maximum in dirty image is %f, sumwt is %s" % (numpy.max(numpy.abs(dirty.data)), str(sumwt))) qa = qa_image(dirty) results['dirty_max'] = qa.data['max'] results['dirty_min'] = qa.data['min'] if write_fits: export_image_to_fits( dirty, "pipelines_rsexecute_timings-%s-dirty.fits" % context) lprint("****** Starting prediction ******") start = time.time() tmp_vis_list = predict_list_rsexecute_workflow( future_corrupted_vis_list, future_model_list, vis_slices=vis_slices, context=context, facets=facets, use_serial_predict=use_serial_imaging, gcfcf=gcfcf) result = rsexecute.compute(tmp_vis_list, sync=True) # rsexecute.client.cancel(tmp_vis_list) end = time.time() results['time predict'] = end - start lprint("Predict took %.3f seconds" % (end - start)) # Create the ICAL pipeline to run major cycles, starting selfcal at cycle 1. A global solution across all # frequencies (i.e. Visibilities) is performed. print("Using subimage clean") deconvolve_facets = 8 deconvolve_overlap = 16 deconvolve_taper = 'tukey' lprint("****** Starting ICAL graph creation ******") controls = create_calibration_controls() controls['T']['first_selfcal'] = 1 controls['T']['timeslice'] = 'auto' start = time.time() ical_list = ical_list_rsexecute_workflow( future_corrupted_vis_list, model_imagelist=future_model_list, context=context, vis_slices=vis_slices, scales=[0, 3, 10], algorithm='mmclean', nmoment=3, niter=1000, fractional_threshold=0.1, threshold=0.01, nmajor=nmajor, gain=0.25, psf_support=64, deconvolve_facets=deconvolve_facets, deconvolve_overlap=deconvolve_overlap, deconvolve_taper=deconvolve_taper, timeslice='auto', global_solution=True, do_selfcal=True, calibration_context='T', controls=controls, use_serial_predict=use_serial_imaging, use_serial_invert=use_serial_imaging, use_serial_clean=use_serial_clean, gcfcf=gcfcf) results['size ICAL graph'] = get_size(ical_list) lprint('Size of ICAL graph is %.3E bytes' % results['size ICAL graph']) end = time.time() results['time ICAL graph'] = end - start lprint("Construction of ICAL graph took %.3f seconds" % (end - start)) print("Current objects on cluster: ") pp.pprint(rsexecute.client.who_has()) # # Execute the graph lprint("****** Executing ICAL graph ******") start = time.time() deconvolved, residual, restored, gaintables = rsexecute.compute(ical_list, sync=True) end = time.time() results['time ICAL'] = end - start lprint("ICAL graph execution took %.3f seconds" % (end - start)) qa = qa_image(deconvolved[centre]) results['deconvolved_max'] = qa.data['max'] results['deconvolved_min'] = qa.data['min'] deconvolved_cube = image_gather_channels(deconvolved) if write_fits: export_image_to_fits( deconvolved_cube, "pipelines_rsexecute_timings-%s-ical_deconvolved.fits" % context) qa = qa_image(residual[centre][0]) results['residual_max'] = qa.data['max'] results['residual_min'] = qa.data['min'] residual_cube = remove_sumwt(residual) residual_cube = image_gather_channels(residual_cube) if write_fits: export_image_to_fits( residual_cube, "pipelines_rsexecute_timings-%s-ical_residual.fits" % context) qa = qa_image(restored[centre]) results['restored_max'] = qa.data['max'] results['restored_min'] = qa.data['min'] restored_cube = image_gather_channels(restored) if write_fits: export_image_to_fits( restored_cube, "pipelines_rsexecute_timings-%s-ical_restored.fits" % context) # rsexecute.close() end_all = time.time() results['time overall'] = end_all - start_all lprint("At end, results are:") results = sort_dict(results) lprint(results) return results