def _predict_base(self, fluxthreshold=1.0, gcf=None, cf=None, name='predict_2d', gcfcf=None, **kwargs): vis = predict_2d(self.vis, self.model, gcfcf=gcfcf, **kwargs) vis.data['vis'] = self.vis.data['vis'] - vis.data['vis'] dirty = invert_2d(vis, self.model, dopsf=False, normalize=True, gcfcf=gcfcf) if self.persist: export_image_to_fits( dirty[0], '%s/test_imaging_%s_residual.fits' % (self.dir, name)) assert numpy.max(numpy.abs(dirty[0].data)), "Residual image is empty" maxabs = numpy.max(numpy.abs(dirty[0].data)) assert maxabs < fluxthreshold, "Error %.3f greater than fluxthreshold %.3f " % ( maxabs, fluxthreshold)
def setUp(self): from data_models.parameters import arl_path self.dir = arl_path('test_results') self.lowcore = create_named_configuration('LOWBD2-CORE') self.times = (numpy.pi / (12.0)) * numpy.linspace(-3.0, 3.0, 7) self.frequency = numpy.array([1e8]) self.channel_bandwidth = numpy.array([1e6]) self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000') self.vis = create_visibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI'), zerow=True) self.vis.data['vis'] *= 0.0 # Create model self.test_model = create_test_image(cellsize=0.001, phasecentre=self.vis.phasecentre, frequency=self.frequency) self.vis = predict_2d(self.vis, self.test_model) assert numpy.max(numpy.abs(self.vis.vis)) > 0.0 self.model = create_image_from_visibility( self.vis, npixel=512, cellsize=0.001, polarisation_frame=PolarisationFrame('stokesI')) self.dirty, sumwt = invert_2d(self.vis, self.model) self.psf, sumwt = invert_2d(self.vis, self.model, dopsf=True)
def setUp(self): from data_models.parameters import arl_path self.lowcore = create_named_configuration('LOWBD2-CORE') self.dir = arl_path('test_results') self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7) self.image_frequency = numpy.linspace(0.9e8, 1.1e8, 5) self.component_frequency = numpy.linspace(0.8e8, 1.2e8, 7) self.channel_bandwidth = numpy.array(5*[1e7]) self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000') self.vis = create_visibility(self.lowcore, self.times, self.image_frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI'), zerow=True) self.vis.data['vis'] *= 0.0 # Create model self.model = create_test_image(cellsize=0.0015, phasecentre=self.vis.phasecentre, frequency=self.image_frequency) self.model.data[self.model.data > 1.0] = 1.0 self.vis = predict_2d(self.vis, self.model) assert numpy.max(numpy.abs(self.vis.vis)) > 0.0 dphasecentre = SkyCoord(ra=+181.0 * u.deg, dec=-58.0 * u.deg, frame='icrs', equinox='J2000') flux = [[numpy.power(f/1e8, -0.7)] for f in self.component_frequency] self.sc = create_skycomponent(direction=dphasecentre, flux=flux, frequency=self.component_frequency, polarisation_frame=PolarisationFrame('stokesI'))
def setUp(self): from data_models.parameters import arl_path self.dir = arl_path('test_results') self.niter = 1000 self.lowcore = create_named_configuration('LOWBD2-CORE') self.nchan = 5 self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7) self.frequency = numpy.linspace(0.9e8, 1.1e8, self.nchan) self.channel_bandwidth = numpy.array( self.nchan * [self.frequency[1] - self.frequency[0]]) self.phasecentre = SkyCoord(ra=+0.0 * u.deg, dec=-45.0 * u.deg, frame='icrs', equinox='J2000') self.vis = create_visibility( self.lowcore, self.times, self.frequency, self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI'), zerow=True) self.vis.data['vis'] *= 0.0 # Create model self.test_model = create_low_test_image_from_gleam( npixel=512, cellsize=0.001, phasecentre=self.vis.phasecentre, frequency=self.frequency, channel_bandwidth=self.channel_bandwidth, flux_limit=1.0) beam = create_low_test_beam(self.test_model) export_image_to_fits(beam, "%s/test_deconvolve_mmclean_beam.fits" % self.dir) self.test_model.data *= beam.data export_image_to_fits( self.test_model, "%s/test_deconvolve_mmclean_model.fits" % self.dir) self.vis = predict_2d(self.vis, self.test_model) assert numpy.max(numpy.abs(self.vis.vis)) > 0.0 self.model = create_image_from_visibility( self.vis, npixel=512, cellsize=0.001, polarisation_frame=PolarisationFrame('stokesI')) self.dirty, sumwt = invert_2d(self.vis, self.model) self.psf, sumwt = invert_2d(self.vis, self.model, dopsf=True) export_image_to_fits( self.dirty, "%s/test_deconvolve_mmclean-dirty.fits" % self.dir) export_image_to_fits(self.psf, "%s/test_deconvolve_mmclean-psf.fits" % self.dir) window = numpy.ones(shape=self.model.shape, dtype=numpy.bool) window[..., 129:384, 129:384] = True self.innerquarter = create_image_from_array( window, self.model.wcs, polarisation_frame=PolarisationFrame('stokesI'))
def test_insert_skycomponent_FFT(self): self.model.data *= 0.0 self.sc = create_skycomponent(direction=self.phasecentre, flux=self.sc.flux, frequency=self.component_frequency, polarisation_frame=PolarisationFrame('stokesI')) insert_skycomponent(self.model, self.sc) npixel = self.model.shape[3] # WCS is 1-relative rpix = numpy.round(self.model.wcs.wcs.crpix).astype('int') - 1 assert rpix[0] == npixel // 2 assert rpix[1] == npixel // 2 # The phase centre is at rpix[0], rpix[1] in 0-relative pixels assert self.model.data[2, 0, rpix[1], rpix[0]] == 1.0 # If we predict the visibility, then the imaginary part must be zero. This is determined entirely # by shift_vis_to_image in libs.imaging.base self.vis.data['vis'][...] = 0.0 self.vis = predict_2d(self.vis, self.model) # The actual phase centre of a numpy FFT is at nx //2, nx //2 (0 rel). assert numpy.max(numpy.abs(self.vis.vis.imag)) <1e-3
def setUp(self): from data_models.parameters import arl_path self.dir = arl_path('test_results') self.lowcore = create_named_configuration('LOWBD2-CORE') self.times = (numpy.pi / (12.0)) * numpy.linspace(-3.0, 3.0, 7) self.frequency = numpy.array([1e8]) self.channel_bandwidth = numpy.array([1e6]) self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000') self.vis = create_visibility( 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 self.vis.data['uvw'][:, 2] = 0.0 # Create model self.model = create_test_image(cellsize=0.0015, phasecentre=self.vis.phasecentre, frequency=self.frequency) self.model.data[self.model.data > 1.0] = 1.0 self.vis = predict_2d(self.vis, self.model) assert numpy.max(numpy.abs(self.vis.vis)) > 0.0 export_image_to_fits( self.model, '%s/test_solve_skycomponent_model.fits' % (self.dir)) self.bigmodel = create_image_from_visibility(self.vis, cellsize=0.0015, npixel=512) residual, sumwt = invert_2d(self.vis, self.bigmodel) export_image_to_fits( residual, '%s/test_solve_skycomponent_msclean_dirty.fits' % (self.dir))