def test_simulate_gaintable_from_voltage_patterns(self): numpy.random.seed(18051955) offset_phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-44.58 * u.deg, frame='icrs', equinox='J2000') component = [Skycomponent(frequency=self.frequency, direction=offset_phasecentre, polarisation_frame=PolarisationFrame("stokesI"), flux=[[1.0]])] key_nolls = [3, 5, 6, 7] vp_list = list() vp_list.append(create_vp(self.model, 'MID_GAUSS', use_local=True)) vp_coeffs = numpy.ones([self.nants, len(key_nolls)+1]) for inoll, noll in enumerate(key_nolls): zernike = {'coeff': 1.0, 'noll': noll} vp_coeffs[:, inoll+1] = numpy.random.normal(0.0, 0.03, self.nants) vp_list.append(create_vp_generic_numeric(self.model, pointingcentre=None, diameter=15.0, blockage=0.0, taper='gaussian', edge=0.03162278, zernikes=[zernike], padding=2, use_local=True)) gt = simulate_gaintable_from_zernikes(self.vis, component, vp_list, vp_coeffs) import matplotlib.pyplot as plt assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1, 1), gt[0].gain.shape plt.clf() for ant in range(self.nants): plt.plot(gt[0].time, 1.0 / numpy.real(gt[0].gain[:, ant, 0, 0, 0]), '.') plt.xlabel('Time (s)') plt.ylabel('Gain') plt.show(block=False)
def test_create_gaintable_from_pointingtable(self): s3_components = create_test_skycomponents_from_s3( flux_limit=0.3, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=1.5 * numpy.pi / 180.0) s3_components = filter_skycomponents_by_flux(s3_components, 0.0, 10.0) pt = create_pointingtable_from_blockvisibility(self.vis) pt = simulate_pointingtable(pt, pointing_error=0.01, static_pointing_error=[0.001, 0.0001]) vp = create_vp(self.model, 'MID') gt = simulate_gaintable_from_pointingtable(self.vis, s3_components, pt, vp) if self.doplot: import matplotlib.pyplot as plt plt.clf() plt.plot(gt[0].time, numpy.real(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') plt.plot(gt[0].time, numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') plt.title('test_create_gaintable_from_pointingtable') plt.show(block=False) assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1, 1), gt[0].gain.shape
def test_create_gaintable_from_pointingtable_GRASP(self): self.vis = create_blockvisibility( self.midcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('linear')) comp = create_skycomponent( direction=self.phasecentre, flux=[[1.0, 0.0, 0.0, 0.0]], frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesIQUV')) pt = create_pointingtable_from_blockvisibility(self.vis) pt = simulate_pointingtable(pt, pointing_error=0.0, static_pointing_error=None, global_pointing_error=[0.0, 0.01]) vp = create_vp(self.model, 'MID_GRASP') gt = simulate_gaintable_from_pointingtable(self.vis, [comp], pt, vp) if self.doplot: import matplotlib.pyplot as plt plt.clf() plt.plot(gt[0].time, numpy.real(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') plt.plot(gt[0].time, numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') plt.title( 'test_create_gaintable_from_pointingtable_global_dynamic') plt.show(block=False) assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 2, 2), gt[0].gain.shape
def test_create_gaintable_from_pointingtable_global(self): comp = create_skycomponent( direction=self.phasecentre, flux=[[1.0]], frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) import matplotlib.pyplot as plt pt = create_pointingtable_from_blockvisibility(self.vis) pt = simulate_pointingtable(pt, pointing_error=0.0, static_pointing_error=None, global_pointing_error=[0.0, 0.01]) vp = create_vp(self.model, 'MID') gt = simulate_gaintable_from_pointingtable(self.vis, [comp], pt, vp) if self.doplot: plt.clf() plt.plot(gt[0].time, numpy.real(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') plt.plot(gt[0].time, numpy.imag(1.0 / gt[0].gain[:, 0, 0, 0, 0]), '.') plt.title('test_create_gaintable_from_pointingtable_global') plt.show(block=False) assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1, 1), gt[0].gain.shape
def test_simulate_gaintable_from_time_series(self): numpy.random.seed(18051955) offset_phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-44.58 * u.deg, frame='icrs', equinox='J2000') component = [ Skycomponent(frequency=self.frequency, direction=offset_phasecentre, polarisation_frame=PolarisationFrame("stokesI"), flux=[[1.0]]) ] for type in ['wind']: pt = create_pointingtable_from_blockvisibility(self.vis) import matplotlib.pyplot as plt ant = 15 plt.clf() plt.plot(pt.time, pt.nominal[:, ant, 0, 0, 0], '.') plt.plot(pt.time, pt.nominal[:, ant, 0, 0, 1], '.') plt.xlabel('Time (s)') plt.ylabel('Nominal (rad)') plt.title("Nominal pointing for %s" % (type)) plt.show() for reference_pointing in [False, True]: pt = simulate_pointingtable_from_timeseries( pt, type=type, reference_pointing=reference_pointing) import matplotlib.pyplot as plt ant = 15 plt.clf() r2a = 180.0 * 3600.0 / numpy.pi plt.plot(pt.time, r2a * pt.pointing[:, ant, 0, 0, 0], '.') plt.plot(pt.time, r2a * pt.pointing[:, ant, 0, 0, 1], '.') plt.xlabel('Time (s)') plt.ylabel('Pointing (arcsec)') plt.title("Pointing for %s, reference pointing %s" % (type, reference_pointing)) plt.show() vp = create_vp(self.model, 'MID') gt = simulate_gaintable_from_pointingtable( self.vis, component, pt, vp) assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1, 1), gt[0].gain.shape plt.clf() plt.plot(gt[0].time, 1.0 / numpy.real(gt[0].gain[:, ant, 0, 0, 0]), '.') plt.xlabel('Time (s)') plt.ylabel('Gain') plt.title("Gain for %s, reference pointing %s" % (type, reference_pointing)) plt.show()
def test_create_voltage_patterns(self): self.createVis() for telescope in ['VLA', 'ASKAP', 'LOW']: model = create_image_from_visibility(self.vis, cellsize=self.cellsize, npixel=self.npixel, override_cellsize=False) beam = create_vp(model, telescope=telescope) assert numpy.max(numpy.abs(beam.data.real)) > 0.0 assert numpy.max(numpy.abs(beam.data.imag)) < 1e-15, numpy.max( numpy.abs(beam.data.imag))
def test_create_pointingtable(self): beam = create_test_image(cellsize=0.0015, phasecentre=self.vis.phasecentre, frequency=self.frequency) for telescope in ['MID', 'LOW', 'ASKAP']: vp = create_vp(beam, telescope) pt = create_pointingtable_from_blockvisibility(self.vis, vp) pt = simulate_pointingtable(pt, 0.1, static_pointing_error=[0.01, 0.001]) assert pt.pointing.shape == (self.ntimes, self.nants, 1, 1, 2), pt.pointing.shape
def find_vp_actual(telescope, normalise=True): vp = create_vp(telescope=telescope) if test_vp: vp.data[:, 0, ...] = 1.0 vp.data[:, 1, ...] = 0.0 vp.data[:, 2, ...] = 0.0 vp.data[:, 3, ...] = 1.0 if normalise: g = numpy.zeros([4]) g[0] = numpy.max(numpy.abs(vp.data[:, 0, ...])) g[3] = numpy.max(numpy.abs(vp.data[:, 3, ...])) g[1] = g[2] = numpy.sqrt(g[0] * g[3]) for chan in range(4): vp.data[:, chan, ...] /= g[chan] return vp
def test_create_voltage_patterns_MID(self): self.createVis(freq=1.4e9) model = create_image_from_visibility(self.vis, npixel=self.npixel, cellsize=self.cellsize, override_cellsize=False) for telescope in ['MID', 'MID_FEKO_B1', 'MID_FEKO_B2', 'MID_FEKO_Ku']: beam = create_vp(model, telescope=telescope, padding=4) beam_data = beam.data beam.data = numpy.real(beam_data) beam.wcs.wcs.crval[0] = 0.0 beam.wcs.wcs.crval[1] = 90.0 if self.persist: export_image_to_fits( beam, "%s/test_voltage_pattern_real_zenith_%s.fits" % (self.dir, telescope))
def test_create_gaintable_from_pointingtable(self): s3_components = create_test_skycomponents_from_s3( flux_limit=5.0, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=0.2) pt = create_pointingtable_from_blockvisibility(self.vis) pt = simulate_pointingtable(pt, pointing_error=0.01, static_pointing_error=[0.001, 0.0001]) vp = create_vp(self.model, 'MID') gt = simulate_gaintable_from_pointingtable(self.vis, s3_components, pt, vp) assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1, 1), gt[0].gain.shape
def test_create_voltage_patterns_MID_GAUSS(self): self.createVis() model = create_image_from_visibility(self.vis, npixel=self.npixel, cellsize=self.cellsize, override_cellsize=False) for telescope in ['MID_GAUSS']: beam = create_vp(model, telescope=telescope, padding=4) beam_data = beam.data beam.data = numpy.real(beam_data) if self.persist: export_image_to_fits( beam, "%s/test_voltage_pattern_real_%s.fits" % (self.dir, telescope)) beam.data = numpy.imag(beam_data) if self.persist: export_image_to_fits( beam, "%s/test_voltage_pattern_imag_%s.fits" % (self.dir, telescope))
def create_voltage_patterns_coeffs(model, zsigma=0.03): key_nolls = [3, 5, 6, 7] vp_list = list() vp_list.append(create_vp(model, 'MID_GAUSS', use_local=True)) vp_coeffs = numpy.ones([nants, len(key_nolls) + 1]) for inoll, noll in enumerate(key_nolls): zernike = {'coeff': 1.0, 'noll': noll} vp_coeffs[:, inoll + 1] = numpy.random.normal(0.0, zsigma, nants) vp_list.append( create_vp_generic_numeric(model, pointingcentre=None, diameter=15.0, blockage=0.0, taper='gaussian', edge=0.03162278, zernikes=[zernike], padding=2, use_local=True)) vp_coeffs = numpy.array(vp_coeffs) return vp_list, vp_coeffs
def test_create_gaintable_from_pointingtable_circlecut_stokesI(self): self.sidelobe = SkyCoord(ra=+15.0 * u.deg, dec=-49.4 * u.deg, frame='icrs', equinox='J2000') comp = create_skycomponent( direction=self.sidelobe, flux=[[1.0]], frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI')) telescopes = ['MID', 'MID_GAUSS'] for telescope in telescopes: pt = create_pointingtable_from_blockvisibility(self.vis) pt = simulate_pointingtable(pt, pointing_error=0.0, global_pointing_error=[0.0, 0.0]) vp = create_vp(self.model, telescope) gt = simulate_gaintable_from_pointingtable(self.vis, [comp], pt, vp) if self.doplot: import matplotlib.pyplot as plt plt.clf() plt.plot(gt[0].time, numpy.real(gt[0].gain[:, 0, 0, 0, 0]), '.', label='stokesI Real') plt.plot(gt[0].time, numpy.imag(gt[0].gain[:, 0, 0, 0, 0]), '.', label='stokesI Imaginary') plt.legend() plt.xlabel('Time (s)') plt.ylabel('Gain') plt.title('test_create_gaintable_from_pointingtable_%s' % telescope) plt.show(block=False) assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 1, 1), gt[0].gain.shape
def test_create_voltage_patterns_MID_rotate(self): self.createVis(freq=1.4e9) model = create_image_from_visibility( self.vis, npixel=self.npixel, cellsize=self.cellsize, polarisation_frame=PolarisationFrame("stokesIQUV"), override_cellsize=False) for telescope in ['MID_FEKO_B1', 'MID_FEKO_B2', 'MID_FEKO_Ku']: beam = create_vp(telescope=telescope) beam = scale_and_rotate_image(beam, scale=[1.2, 0.8]) self.persist = True if self.persist: export_image_to_fits( beam, "%s/test_voltage_pattern_real_prerotate_%s.fits" % (self.dir, telescope)) beam_radec = convert_azelvp_to_radec(beam, model, numpy.pi / 4.0) beam_data = beam_radec.data beam_radec.data = numpy.real(beam_data) if self.persist: export_image_to_fits( beam_radec, "%s/test_voltage_pattern_real_rotate_%s.fits" % (self.dir, telescope))
def test_apply_voltage_pattern_dft(self): self.createVis() nfailures = 0 telescope = 'MID_FEKO_B2' for flux in (numpy.array([[100.0, 0.0, 0.0, 0.0]]), numpy.array([[100.0, 100.0, 0.0, 0.0]]), numpy.array([[100.0, 0.0, 100.0, 0.0]]), numpy.array([[100.0, 0.0, 0.0, 100.0]]), numpy.array([[100.0, 1.0, -10.0, +60.0]])): vpol = PolarisationFrame("linear") try: bvis = create_blockvisibility( self.config, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=vpol) component_centre = SkyCoord(ra=+16.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000') component = create_skycomponent( direction=component_centre, flux=flux, frequency=self.frequency, polarisation_frame=PolarisationFrame("stokesIQUV")) model = create_image_from_visibility( bvis, cellsize=self.cellsize, npixel=self.npixel, override_cellsize=False, polarisation_frame=PolarisationFrame("stokesIQUV")) vpbeam = create_vp(model, telescope=telescope, use_local=False) vpbeam.wcs.wcs.ctype[0] = 'RA---SIN' vpbeam.wcs.wcs.ctype[1] = 'DEC--SIN' vpbeam.wcs.wcs.crval[0] = model.wcs.wcs.crval[0] vpbeam.wcs.wcs.crval[1] = model.wcs.wcs.crval[1] assert component.polarisation_frame == PolarisationFrame( "stokesIQUV") vpcomp = apply_voltage_pattern_to_skycomponent( component, vpbeam) assert vpcomp.polarisation_frame == vpbeam.polarisation_frame bvis = dft_skycomponent_visibility(bvis, vpcomp) vpcomp = idft_visibility_skycomponent(bvis, vpcomp)[0][0] assert vpcomp.polarisation_frame == bvis.polarisation_frame inv_vpcomp = apply_voltage_pattern_to_skycomponent( vpcomp, vpbeam, inverse=True) assert vpcomp.polarisation_frame == PolarisationFrame( "stokesIQUV") # print("After application of primary beam {}".format(str(vpcomp.flux))) # print("After correction of primary beam {}".format(str(inv_vpcomp.flux))) # print("{0} {1} succeeded".format(vpol, str(flux))) assert_array_almost_equal(flux, numpy.real(inv_vpcomp.flux), 9) except AssertionError as e: print(e) print("{0} {1} failed".format(vpol, str(flux))) nfailures += 1 assert nfailures == 0, "{} tests failed".format(nfailures)
def test_apply_voltage_pattern_skycomponent(self): self.createVis() telescope = 'MID_FEKO_B2' vpbeam = create_vp(telescope=telescope, use_local=False) vpol = PolarisationFrame("linear") bvis = create_blockvisibility(self.config, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=vpol) cellsize = advise_wide_field(bvis)['cellsize'] component_centre = SkyCoord(ra=+15.25 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000') model = create_image_from_visibility( bvis, cellsize=cellsize, npixel=1024, phasecentre=component_centre, override_cellsize=False, polarisation_frame=PolarisationFrame("linear")) bvis = weight_blockvisibility(bvis, model) pbmodel = create_image_from_visibility( bvis, cellsize=self.cellsize, npixel=self.npixel, override_cellsize=False, polarisation_frame=PolarisationFrame("stokesIQUV")) vpbeam = create_vp(pbmodel, telescope=telescope, use_local=False) vpbeam.wcs.wcs.ctype[0] = 'RA---SIN' vpbeam.wcs.wcs.ctype[1] = 'DEC--SIN' vpbeam.wcs.wcs.crval[0] = pbmodel.wcs.wcs.crval[0] vpbeam.wcs.wcs.crval[1] = pbmodel.wcs.wcs.crval[1] for case, flux in enumerate( (numpy.array([[100.0, 0.0, 0.0, 0.0]]), numpy.array([[100.0, 100.0, 0.0, 0.0]]), numpy.array([[100.0, 0.0, 100.0, 0.0]]), numpy.array([[100.0, 0.0, 0.0, 100.0]]), numpy.array([[100.0, 1.0, -10.0, +60.0]]))): component = create_skycomponent( direction=component_centre, flux=flux, frequency=self.frequency, polarisation_frame=PolarisationFrame("stokesIQUV")) vpcomp = apply_voltage_pattern_to_skycomponent(component, vpbeam) bvis.data['vis'][...] = 0.0 + 0.0j bvis = dft_skycomponent_visibility(bvis, vpcomp) polimage, sumwt = invert_2d(bvis, model, dopsf=False) export_image_to_fits( polimage, "{0}/test_primary_beams_pol_case{1}.fits".format( self.dir, case)) # Check out the path via components found_components = find_skycomponents(polimage, threshold=20.0, npixels=5) assert len(found_components) == 1 inv_vpcomp = apply_voltage_pattern_to_skycomponent( found_components[0], vpbeam, inverse=True) assert_array_almost_equal(flux, numpy.real(inv_vpcomp.flux), 1) # Now check out the path via images vpbeam.wcs.wcs.ctype[0] = polimage.wcs.wcs.ctype[0] vpbeam.wcs.wcs.ctype[1] = polimage.wcs.wcs.ctype[1] vpbeam.wcs.wcs.crval[0] = polimage.wcs.wcs.crval[0] vpbeam.wcs.wcs.crval[1] = polimage.wcs.wcs.crval[1] vpbeam_regrid, footprint = reproject_image(vpbeam, polimage.wcs, polimage.shape) polimage_corrected = apply_voltage_pattern_to_image(polimage, vpbeam_regrid, inverse=True, min_det=0.3) export_image_to_fits( polimage_corrected, "{0}/test_primary_beams_pol_corrected_case{1}.fits".format( self.dir, case)) found_components = find_skycomponents(polimage_corrected, threshold=20.0, npixels=5) assert len(found_components) == 1
def test_create_gaintable_from_pointingtable_circlecut_stokesIQUV(self): self.vis = create_blockvisibility( self.midcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('linear')) self.sidelobe = SkyCoord(ra=+15.0 * u.deg, dec=-49.3 * u.deg, frame='icrs', equinox='J2000') comp = create_skycomponent( direction=self.sidelobe, flux=[[1.0, 0.0, 0.0, 0.0]], frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesIQUV')) telescopes = ['MID_FEKO_B2'] for telescope in telescopes: pt = create_pointingtable_from_blockvisibility(self.vis) pt = simulate_pointingtable(pt, pointing_error=0.0, global_pointing_error=[0.0, 0.0]) vp = create_vp(self.model, telescope) gt = simulate_gaintable_from_pointingtable(self.vis, [comp], pt, vp) if self.doplot: import matplotlib.pyplot as plt plt.clf() plt.plot(gt[0].time, numpy.real(gt[0].gain[:, 0, 0, 0, 0]), '.', label='XX') plt.plot(gt[0].time, numpy.real(gt[0].gain[:, 0, 0, 1, 1]), '.', label='YY') plt.legend() plt.xlabel('Time (s)') plt.ylabel('Gain') plt.title( 'test_create_gaintable_from_pointingtable_parallel_%s' % telescope) plt.show(block=False) plt.clf() plt.plot(gt[0].time, numpy.real(gt[0].gain[:, 0, 0, 0, 1]), '.', label='XY') plt.plot(gt[0].time, numpy.real(gt[0].gain[:, 0, 0, 1, 0]), '.', label='YX') plt.legend() plt.xlabel('Time (s)') plt.ylabel('Gain') plt.title('test_create_gaintable_from_pointingtable_cross_%s' % telescope) plt.show(block=False) assert gt[0].gain.shape == (self.ntimes, self.nants, 1, 2, 2), gt[0].gain.shape
def test_apply_voltage_pattern_image_pointsource(self): self.createVis(rmax=1e3) telescope = 'MID_FEKO_B2' vpol = PolarisationFrame("linear") self.times = numpy.linspace(-4, +4, 8) * numpy.pi / 12.0 bvis = create_blockvisibility(self.config, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=vpol, zerow=True) cellsize = advise_wide_field(bvis)['cellsize'] pbmodel = create_image_from_visibility( bvis, cellsize=self.cellsize, npixel=self.npixel, override_cellsize=False, polarisation_frame=PolarisationFrame("stokesIQUV")) vpbeam = create_vp(pbmodel, telescope=telescope, use_local=False) vpbeam.wcs.wcs.ctype[0] = 'RA---SIN' vpbeam.wcs.wcs.ctype[1] = 'DEC--SIN' vpbeam.wcs.wcs.crval[0] = pbmodel.wcs.wcs.crval[0] vpbeam.wcs.wcs.crval[1] = pbmodel.wcs.wcs.crval[1] s3_components = create_test_skycomponents_from_s3( flux_limit=0.1, phasecentre=self.phasecentre, frequency=self.frequency, polarisation_frame=PolarisationFrame('stokesI'), radius=1.5 * numpy.pi / 180.0) for comp in s3_components: comp.polarisation_frame = PolarisationFrame('stokesIQUV') comp.flux = numpy.array([[comp.flux[0, 0], 0.0, 0.0, 0.0]]) s3_components = filter_skycomponents_by_flux(s3_components, 0.0, 10.0) from rascil.processing_components.image import show_image import matplotlib.pyplot as plt plt.clf() show_image(vpbeam, components=s3_components) plt.show(block=False) vpcomp = apply_voltage_pattern_to_skycomponent(s3_components, vpbeam) bvis.data['vis'][...] = 0.0 + 0.0j bvis = dft_skycomponent_visibility(bvis, vpcomp) rec_comp = idft_visibility_skycomponent(bvis, vpcomp)[0] stokes_comp = list() for comp in rec_comp: stokes_comp.append( convert_pol_frame(comp.flux[0], PolarisationFrame("linear"), PolarisationFrame("stokesIQUV"))) stokesI = numpy.abs( numpy.array([comp_flux[0] for comp_flux in stokes_comp]).real) stokesQ = numpy.abs( numpy.array([comp_flux[1] for comp_flux in stokes_comp]).real) stokesU = numpy.abs( numpy.array([comp_flux[2] for comp_flux in stokes_comp]).real) stokesV = numpy.abs( numpy.array([comp_flux[3] for comp_flux in stokes_comp]).real) plt.clf() plt.loglog(stokesI, stokesQ, '.', label='Q') plt.loglog(stokesI, stokesU, '.', label='U') plt.loglog(stokesI, stokesV, '.', label='V') plt.xlabel("Stokes Flux I (Jy)") plt.ylabel("Flux (Jy)") plt.legend() plt.savefig('%s/test_primary_beams_pol_rsexecute_stokes_errors.png' % self.dir) plt.show(block=False) split_times = False if split_times: bvis_list = list() for rows in vis_timeslice_iter(bvis, vis_slices=8): bvis_list.append(create_visibility_from_rows(bvis, rows)) else: bvis_list = [bvis] bvis_list = rsexecute.scatter(bvis_list) model_list = \ [rsexecute.execute(create_image_from_visibility, nout=1)(bv, cellsize=cellsize, npixel=4096, phasecentre=self.phasecentre, override_cellsize=False, polarisation_frame=PolarisationFrame("stokesIQUV")) for bv in bvis_list] model_list = rsexecute.persist(model_list) bvis_list = weight_list_rsexecute_workflow(bvis_list, model_list) continuum_imaging_list = \ continuum_imaging_list_rsexecute_workflow(bvis_list, model_list, context='2d', algorithm='hogbom', facets=1, niter=1000, fractional_threshold=0.1, threshold=1e-4, nmajor=5, gain=0.1, deconvolve_facets=4, deconvolve_overlap=32, deconvolve_taper='tukey', psf_support=64, restore_facets=4, psfwidth=1.0) clean, residual, restored = rsexecute.compute(continuum_imaging_list, sync=True) centre = 0 if self.persist: export_image_to_fits( clean[centre], '%s/test_primary_beams_pol_rsexecute_clean.fits' % self.dir) export_image_to_fits( residual[centre][0], '%s/test_primary_beams_pol_rsexecute_residual.fits' % self.dir) export_image_to_fits( restored[centre], '%s/test_primary_beams_pol_rsexecute_restored.fits' % self.dir) plt.clf() show_image(restored[centre]) plt.show(block=False) qa = qa_image(restored[centre]) assert numpy.abs(qa.data['max'] - 0.9953017707113947) < 1.0e-7, str(qa) assert numpy.abs(qa.data['min'] + 0.0036396480874570846) < 1.0e-7, str(qa)