def test_calculate_image_frequency_moments(self): frequency = numpy.linspace(0.9e8, 1.1e8, 9) cube = create_low_test_image_from_gleam(npixel=512, cellsize=0.0001, frequency=frequency, flux_limit=1.0) log.debug( export_image_to_fits(cube, fitsfile='%s/test_moments_cube.fits' % (self.dir))) original_cube = copy_image(cube) moment_cube = calculate_image_frequency_moments(cube, nmoment=3) log.debug( export_image_to_fits(moment_cube, fitsfile='%s/test_moments_moment_cube.fits' % (self.dir))) reconstructed_cube = calculate_image_from_frequency_moments( cube, moment_cube) log.debug( export_image_to_fits( reconstructed_cube, fitsfile='%s/test_moments_reconstructed_cube.fits' % (self.dir))) error = numpy.std(reconstructed_cube.data - original_cube.data) assert error < 0.2
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_get_frequency_map_gleam(self): self.model = create_low_test_image_from_gleam( npixel=128, cellsize=0.001, frequency=self.frequency, channel_bandwidth=self.channel_bandwidth, flux_limit=10.0) spectral_mode, vfrequency_map = get_frequency_map(self.vis, self.model) assert numpy.max(vfrequency_map) == self.model.nchan - 1 assert spectral_mode == 'channel'
def test_create_low_test_image_from_gleam(self): im = create_low_test_image_from_gleam(npixel=256, cellsize=0.001, channel_bandwidth=self.channel_bandwidth, frequency=self.frequency, phasecentre=self.phasecentre, kind='cubic', flux_limit=0.3) assert im.data.shape[0] == 5 assert im.data.shape[1] == 1 assert im.data.shape[2] == 256 assert im.data.shape[3] == 256 export_image_to_fits(im, '%s/test_test_support_low_gleam.fits' % (self.dir))
polarisation_frame=PolarisationFrame("stokesI")) wprojection_planes = 1 advice = advise_wide_field(block_vis, guard_band_image=4.0, delA=0.02, wprojection_planes=wprojection_planes) vis_slices = advice['vis_slices'] npixel = advice['npixels2'] cellsize = advice['cellsize'] gleam_model = create_low_test_image_from_gleam( npixel=npixel, frequency=frequency, channel_bandwidth=channel_bandwidth, cellsize=cellsize, phasecentre=phasecentre, flux_limit=1.0, applybeam=True) predicted_vis = predict_function(block_vis, gleam_model, vis_slices=51, context='wstack') #print("np.sum(predicted_vis.data): ", numpy.sum(predicted_vis.data['vis'])) block_vis = convert_visibility_to_blockvisibility(predicted_vis) #print("np.sum(block_vis.data): ", numpy.sum(block_vis.data['vis'])) #print("nchan npol nants ", block_vis.nchan, block_vis.npol, block_vis.nants) #print("uvw", block_vis.uvw, numpy.sum(block_vis.uvw)) #print("vis", block_vis.vis, numpy.sum(block_vis.vis))