def test_phase_rotation(self): self.vis = create_visibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) self.vismodel = predict_skycomponent_visibility(self.vis, self.comp) # Predict visibilities with new phase centre independently ha_diff = -(self.compabsdirection.ra - self.phasecentre.ra).to( u.rad).value vispred = create_visibility( self.lowcore, self.times + ha_diff, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.compabsdirection, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) vismodel2 = predict_skycomponent_visibility(vispred, self.comp) # Should yield the same results as rotation rotatedvis = phaserotate_visibility( self.vismodel, newphasecentre=self.compabsdirection, tangent=False) assert_allclose(rotatedvis.vis, vismodel2.vis, rtol=3e-6) assert_allclose(rotatedvis.uvw, vismodel2.uvw, rtol=3e-6)
def test_elevation(self): self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=+15.0 * u.deg, frame='icrs', equinox='J2000') self.times = (numpy.pi / 43200.0) * numpy.arange( -43200, +43200, 3600.0) self.vis = create_visibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV"), elevation_limit=numpy.pi * 15.0 / 180.0) n_elevation_limit = len(numpy.unique(self.vis.time)) self.vis = create_visibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV"), elevation_limit=None) assert len(numpy.unique(self.vis.time)) >= n_elevation_limit
def test_phase_rotation_stokesi(self): # Define the component and give it some spectral behaviour f = numpy.array([100.0]) self.flux = numpy.array([f, 0.8 * f, 0.6 * f]) # The phase centre is absolute and the component is specified relative (for now). # This means that the component should end up at the position phasecentre+compredirection self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000') self.compabsdirection = SkyCoord(ra=+181.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000') pcof = self.phasecentre.skyoffset_frame() self.compreldirection = self.compabsdirection.transform_to(pcof) self.comp = Skycomponent(direction=self.compreldirection, frequency=self.frequency, flux=self.flux, polarisation_frame=PolarisationFrame("stokesI")) 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.vismodel = predict_skycomponent_visibility(self.vis, self.comp) # Predict visibilities with new phase centre independently ha_diff = -(self.compabsdirection.ra - self.phasecentre.ra).to(u.rad).value vispred = create_visibility(self.lowcore, self.times + ha_diff, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.compabsdirection, weight=1.0, polarisation_frame=PolarisationFrame("stokesI")) vismodel2 = predict_skycomponent_visibility(vispred, self.comp) # Should yield the same results as rotation rotatedvis = phaserotate_visibility(self.vismodel, newphasecentre=self.compabsdirection, tangent=False) assert_allclose(rotatedvis.vis, vismodel2.vis, rtol=3e-6) assert_allclose(rotatedvis.uvw, vismodel2.uvw, rtol=3e-6)
def test_append_visibility(self): self.vis = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0) othertimes = (numpy.pi / 43200.0) * numpy.arange(300.0, 600.0, 30.0) self.othervis = create_visibility(self.lowcore, othertimes, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0) self.vis = append_visibility(self.vis, self.othervis) assert self.vis.nvis == len(self.vis.time) assert self.vis.nvis == len(self.vis.frequency)
def test_subtract(self): vis1 = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) vis1.data['vis'][...] = 1.0 vis2 = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) vis2.data['vis'][...] = 1.0 zerovis = subtract_visibility(vis1, vis2) qa = qa_visibility(zerovis, context='test_qa') self.assertAlmostEqual(qa.data['maxabs'], 0.0, 7)
def ingest_unittest_visibility(config, frequency, channel_bandwidth, times, vis_pol, phasecentre, block=False, zerow=False): if block: vt = create_blockvisibility(config, times, frequency, channel_bandwidth=channel_bandwidth, phasecentre=phasecentre, weight=1.0, polarisation_frame=vis_pol, zerow=zerow) else: vt = create_visibility(config, times, frequency, channel_bandwidth=channel_bandwidth, phasecentre=phasecentre, weight=1.0, polarisation_frame=vis_pol, zerow=zerow) vt.data['vis'][...] = 0.0 return vt
def setUp(self): from rascil.data_models.parameters import rascil_path self.lowcore = create_named_configuration('LOWBD2-CORE') self.dir = rascil_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 createVis(self, config='MID', dec=-35.0, rmax=1e3, freq=1e9): self.frequency = numpy.linspace(freq, 1.5 * freq, 3) self.channel_bandwidth = numpy.array([2.5e7, 2.5e7, 2.5e7]) self.flux = numpy.array([[100.0], [100.0], [100.0]]) self.phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000') self.config = create_named_configuration(config) self.times = numpy.linspace(-300.0, 300.0, 3) * numpy.pi / 43200.0 nants = self.config.xyz.shape[0] assert nants > 1 assert len(self.config.names) == nants assert len(self.config.mount) == nants self.config = create_named_configuration(config, rmax=rmax) self.phasecentre = SkyCoord(ra=+15 * u.deg, dec=dec * u.deg, frame='icrs', equinox='J2000') self.vis = create_visibility( self.config, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI'))
def test_phase_rotation_identity(self): self.vis = create_visibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) self.vismodel = predict_skycomponent_visibility(self.vis, self.comp) newphasecenters = [ SkyCoord(182, -35, unit=u.deg), SkyCoord(182, -30, unit=u.deg), SkyCoord(177, -30, unit=u.deg), SkyCoord(176, -35, unit=u.deg), SkyCoord(216, -35, unit=u.deg), SkyCoord(180, -70, unit=u.deg) ] for newphasecentre in newphasecenters: # Phase rotating back should not make a difference original_vis = self.vismodel.vis original_uvw = self.vismodel.uvw rotatedvis = phaserotate_visibility(phaserotate_visibility( self.vismodel, newphasecentre, tangent=False), self.phasecentre, tangent=False) assert_allclose(rotatedvis.uvw, original_uvw, rtol=1e-7) assert_allclose(rotatedvis.vis, original_vis, rtol=1e-7)
def test_fit_visibility(self): # Sum the visibilities in the correct_visibility direction. This is limited by numerical precision methods = [ 'CG', 'BFGS', 'Powell', 'trust-ncg', 'trust-exact', 'trust-krylov' ] for method in methods: self.actualSetup() 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.vismodel = dft_skycomponent_visibility(self.vis, self.comp) initial_comp = Skycomponent( direction=self.comp_start_direction, frequency=self.frequency, flux=2.0 * self.flux, polarisation_frame=PolarisationFrame("stokesI")) sc, res = fit_visibility(self.vismodel, initial_comp, niter=200, tol=1e-5, method=method, verbose=False) assert sc.direction.separation(self.comp_actual_direction).to('rad').value < 1e-6, \ sc.direction.separation(self.comp_actual_direction).to('rad')
def test_create_visibility_from_rows_makecopy(self): self.vis = create_visibility(self.lowcore, self.times, self.frequency, phasecentre=self.phasecentre, weight=1.0, channel_bandwidth=self.channel_bandwidth) rows = self.vis.time > 150.0 for makecopy in [True, False]: selected_vis = create_visibility_from_rows(self.vis, rows, makecopy=makecopy) assert selected_vis.nvis == numpy.sum(numpy.array(rows))
def test_create_visibility_polarisation(self): self.vis = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("linear")) assert self.vis.nvis == len(self.vis.time) assert self.vis.nvis == len(self.vis.frequency)
def test_create_visibility1(self): self.vis = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0) assert self.vis.nvis == len(self.vis.time) assert self.vis.nvis == len(self.vis.frequency)
def setUp(self): from rascil.data_models.parameters import rascil_path self.dir = rascil_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 actualSetUp(self, time=None, frequency=None, dospectral=False, dopol=False): self.lowcore = create_named_configuration('LOWBD2', rmax=600) self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 5) if time is not None: self.times = time log.info("Times are %s" % (self.times)) if dospectral: self.nchan = 3 self.frequency = numpy.array([0.9e8, 1e8, 1.1e8]) self.channel_bandwidth = numpy.array([1e7, 1e7, 1e7]) else: self.frequency = numpy.array([1e8]) self.channel_bandwidth = numpy.array([1e7]) if dopol: self.vis_pol = PolarisationFrame('linear') self.image_pol = PolarisationFrame('stokesIQUV') else: self.vis_pol = PolarisationFrame('stokesI') self.image_pol = PolarisationFrame('stokesI') if dopol: f = numpy.array([100.0, 20.0, -10.0, 1.0]) else: f = numpy.array([100.0]) if dospectral: numpy.array([f, 0.8 * f, 0.6 * f]) else: numpy.array([f]) self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000') self.componentvis = create_visibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=self.vis_pol) self.uvw = self.componentvis.data['uvw'] self.componentvis.data['vis'] *= 0.0 # Create model self.model = create_image_from_visibility( self.componentvis, npixel=self.npixel, cellsize=0.0005, nchan=len(self.frequency), polarisation_frame=self.image_pol)
def actualSetUp(self, times=None): if times is not None: self.times = times self.vis = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0) self.vis.data['vis'][:, 0] = self.vis.time
def test_copy_visibility(self): self.vis = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) vis = copy_visibility(self.vis) self.vis.data['vis'] = 0.0 vis.data['vis'] = 1.0 assert (vis.data['vis'][0, 0].real == 1.0) assert (self.vis.data['vis'][0, 0].real == 0.0)
def test_convert_visibility_stokes(self): for pol in ['linear', 'circular']: vis = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame(pol)) visi = convert_visibility_to_stokes(vis) assert visi.polarisation_frame.type == 'stokesIQUV' assert visi.npol == 4
def test_qa(self): self.vis = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) self.vismodel = dft_skycomponent_visibility(self.vis, self.comp) qa = qa_visibility(self.vis, context='test_qa') self.assertAlmostEqual(qa.data['maxabs'], 100.0, 7) self.assertAlmostEqual(qa.data['medianabs'], 11.0, 7) assert qa.context == 'test_qa'
def test_sum_visibility(self): self.vis = create_visibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, polarisation_frame=PolarisationFrame("linear"), weight=1.0) self.vis = predict_skycomponent_visibility(self.vis, self.comp) flux, weight = sum_visibility(self.vis, self.comp.direction) assert numpy.max(numpy.abs(flux - self.flux)) < 1e-7
def test_addnoise_visibility(self): self.vis = create_visibility( self.config, self.times, self.frequency, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesIQUV'), channel_bandwidth=self.channel_bandwidth) original = copy_visibility(self.vis) self.vis = addnoise_visibility(self.vis) actual = numpy.std(numpy.abs(self.vis.vis - original.vis)) assert abs(actual - 0.010786973492702846) < 1e-4, actual
def createVis(self, config, dec=-35.0, rmax=None): self.config = create_named_configuration(config, rmax=rmax) self.phasecentre = SkyCoord(ra=+15 * u.deg, dec=dec * u.deg, frame='icrs', equinox='J2000') self.vis = create_visibility( self.config, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI'))
def actualSetup(self, dopol=False): if dopol: self.vis_pol = PolarisationFrame("linear") self.image_pol = PolarisationFrame("stokesIQUV") self.pol_flux = numpy.array([1.0, -0.8, 0.2, 0.01]) else: self.vis_pol = PolarisationFrame("stokesI") self.image_pol = PolarisationFrame("stokesI") self.pol_flux = numpy.array([1.0]) self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7) self.image_frequency = numpy.linspace(0.9e8, 1.1e8, 5) self.image_channel_bandwidth = numpy.array(5 * [5e6]) self.component_frequency = numpy.linspace(0.8e8, 1.2e8, 7) 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.image_channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=self.vis_pol, zerow=True) self.vis.data['vis'] *= 0.0 # Create model self.model = create_image( npixel=256, cellsize=0.0015, phasecentre=self.vis.phasecentre, frequency=self.image_frequency, channel_bandwidth=self.image_channel_bandwidth, polarisation_frame=self.image_pol) dphasecentre = SkyCoord(ra=+181.0 * u.deg, dec=-58.0 * u.deg, frame='icrs', equinox='J2000') flux_scale = numpy.power(self.component_frequency / 1e8, -0.7) self.flux = numpy.outer(flux_scale, self.pol_flux) self.sc = create_skycomponent(direction=dphasecentre, flux=self.flux, frequency=self.component_frequency, polarisation_frame=self.image_pol)
def test_phase_rotation_inverse(self): self.vis = create_visibility(self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) self.vismodel = dft_skycomponent_visibility(self.vis, self.comp) there = SkyCoord(ra=+250.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000') # Phase rotating back should not make a difference original_vis = self.vismodel.vis original_uvw = self.vismodel.uvw rotatedvis = phaserotate_visibility(phaserotate_visibility(self.vismodel, there, tangent=False, inverse=True), self.phasecentre, tangent=False, inverse=True) assert_allclose(rotatedvis.uvw, original_uvw, rtol=1e-7) assert_allclose(rotatedvis.vis, original_vis, rtol=1e-7)
def setUp(self): from rascil.data_models.parameters import rascil_path, rascil_data_path self.dir = rascil_path('test_results') self.vnchan = 7 self.lowcore = create_named_configuration('LOWBD2', rmax=300.0) self.times = (numpy.pi / 12.0) * numpy.linspace(-3.0, 3.0, 7) self.frequency = numpy.linspace(8e7, 1.2e8, self.vnchan) self.startfrequency = numpy.array([8e7]) self.channel_bandwidth = numpy.array(self.vnchan * [(1.0 - 1.0e-7) * (self.frequency[1] - self.frequency[0])]) self.phasecentre = SkyCoord(ra=+180.0 * u.deg, dec=-60.0 * u.deg, frame='icrs', equinox='J2000') self.vis = create_visibility(self.lowcore, times=self.times, frequency=self.frequency, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI'), channel_bandwidth=self.channel_bandwidth) self.model = create_image_from_visibility(self.vis, npixel=128, cellsize=0.001, nchan=self.vnchan, frequency=self.startfrequency)
def setUp(self): self.lowcore = create_named_configuration('LOWBD2', rmax=1000.0) self.times = numpy.linspace(-300.0, 300.0, 11) * numpy.pi / 43200.0 self.frequency = numpy.array([1e8]) self.channel_bandwidth = numpy.array([1e8]) self.phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-35.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)
def test_dft_idft_stokesiquv_visibility(self): for vpol in [ PolarisationFrame("linear"), PolarisationFrame("circular") ]: self.vis = create_visibility( self.lowcore, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, weight=1.0, polarisation_frame=PolarisationFrame("stokesIQUV")) self.vismodel = dft_skycomponent_visibility(self.vis, self.comp) rcomp, weights = idft_visibility_skycomponent( self.vismodel, self.comp) assert_allclose(self.comp.flux, numpy.real(rcomp[0].flux), rtol=1e-11)
def setUp(self): from rascil.data_models.parameters import rascil_path self.dir = rascil_path('test_results') self.persist = os.getenv("RASCIL_PERSIST", False) 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) if self.persist: export_image_to_fits(beam, "%s/test_deconvolve_mmclean_beam.fits" % self.dir) self.test_model.data *= beam.data if self.persist: 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) if self.persist: export_image_to_fits(self.dirty, "%s/test_deconvolve_mmclean-dirty.fits" % self.dir) if self.persist: 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_readwritevisibility(self): self.vis = create_visibility(self.mid, self.times, self.frequency, channel_bandwidth=self.channel_bandwidth, phasecentre=self.phasecentre, polarisation_frame=PolarisationFrame("linear"), weight=1.0) self.vis = predict_skycomponent_visibility(self.vis, self.comp) export_visibility_to_hdf5(self.vis, '%s/test_data_model_helpers_visibility.hdf' % self.dir) newvis = import_visibility_from_hdf5('%s/test_data_model_helpers_visibility.hdf' % self.dir) assert str(newvis) == str(self.vis), "Original %s, import %s" % (str(newvis), str(self.vis)) for key in self.vis.data.dtype.fields: assert numpy.max(numpy.abs(newvis.data[key]-self.vis.data[key])) < 1e-15 assert numpy.array_equal(newvis.frequency, self.vis.frequency) assert newvis.data.shape == self.vis.data.shape assert numpy.array_equal(newvis.frequency, self.vis.frequency) assert numpy.max(numpy.abs(self.vis.vis - newvis.vis)) < 1e-15 assert numpy.max(numpy.abs(self.vis.uvw - newvis.uvw)) < 1e-15 assert numpy.abs(newvis.configuration.location.x.value - self.vis.configuration.location.x.value) < 1e-15 assert numpy.abs(newvis.configuration.location.y.value - self.vis.configuration.location.y.value) < 1e-15 assert numpy.abs(newvis.configuration.location.z.value - self.vis.configuration.location.z.value) < 1e-15 assert numpy.max(numpy.abs(newvis.configuration.xyz - self.vis.configuration.xyz)) < 1e-15
rmax = 1e3 freq = 1.4e9 frequency = numpy.linspace(freq, 1.5 * freq, 3) channel_bandwidth = numpy.array([2.5e7, 2.5e7, 2.5e7]) flux = numpy.array([[100.0], [100.0], [100.0]]) phasecentre = SkyCoord(ra=+15.0 * u.deg, dec=-35.0 * u.deg, frame='icrs', equinox='J2000') config = create_named_configuration('MIDR5', rmax=rmax) times = numpy.linspace(-300.0, 300.0, 3) * numpy.pi / 43200.0 nants = config.xyz.shape[0] assert nants > 1 assert len(config.names) == nants assert len(config.mount) == nants phasecentre = SkyCoord(ra=+15 * u.deg, dec=dec * u.deg, frame='icrs', equinox='J2000') vis = create_visibility(config, times, frequency, channel_bandwidth=channel_bandwidth, phasecentre=phasecentre, weight=1.0, polarisation_frame=PolarisationFrame('stokesI')) cellsize = 8 * numpy.pi / 180.0 / 280 model = create_image_from_visibility(vis, npixel=512, cellsize=cellsize, override_cellsize=False) # These are the nolls that maintain left-right symmetry plt.clf() fig, axs = plt.subplots(4, 4, gridspec_kw={'hspace': 0, 'wspace': 0}) ntrials = 16 zernikes = list() default_vp = create_vp_generic_numeric(model, pointingcentre=None, diameter=15.0, blockage=0.0, taper='gaussian', edge=0.03162278, padding=2, use_local=True) key_nolls = [3, 5, 6, 7]