def setUp(self): self.dir = './test_results' os.makedirs(self.dir, exist_ok=True) 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')) 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) beam = create_low_test_beam(self.test_model) export_image_to_fits(beam, "%s/test_deconvolve_msmfsclean_beam.fits" % self.dir) self.test_model.data *= beam.data export_image_to_fits(self.test_model, "%s/test_deconvolve_msmfsclean_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_msmfsclean_dirty.fits" % self.dir) export_image_to_fits(self.psf, "%s/test_deconvolve_msmfsclean_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)
def actualSetUp(self, time=None, frequency=None, dospectral=False, dopol=False): self.lowcore = create_named_configuration('LOWBD2-CORE') 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=512, cellsize=0.001, nchan=len(self.frequency), polarisation_frame=self.image_pol)
def create_empty_handle(vis_graph_list, npixel, cellsize, frequency, channel_bandwidth, polarisation_frame): return vis_graph_list.map( lambda vis: (vis[0], create_image_from_visibility( vis[1], npixel=npixel, cellsize=cellsize, frequency=[frequency[vis[0][2]]], channel_bandwidth=[channel_bandwidth[vis[0][2]]], polarisation_frame=PolarisationFrame("stokesI"))))
def setUp(self): self.dir = './test_results' os.makedirs(self.dir, exist_ok=True) 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 # 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) window = numpy.zeros(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_create_primary_beams_vla(self): self.createVis(config='LOWBD2', rmax=1000.0) model = create_image_from_visibility(self.vis, cellsize=0.00001, override_cellsize=True) beam=create_pb_vla(model) assert numpy.max(beam.data) > 0.0 export_image_to_fits(beam, "%s/primary_beam_vla.fits" % self.dir)