Beispiel #1
0
 def test_calculate_image_frequency_moments_1(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_1_cube.fits' %
                              (self.dir)))
     original_cube = copy_image(cube)
     moment_cube = calculate_image_frequency_moments(cube, nmoment=1)
     log.debug(
         export_image_to_fits(
             moment_cube,
             fitsfile='%s/test_moments_1_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_1_reconstructed_cube.fits' %
             (self.dir)))
     error = numpy.std(reconstructed_cube.data - original_cube.data)
     assert error < 0.2
Beispiel #2
0
 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
     if self.persist:
         export_image_to_fits(
             im, '%s/test_test_support_low_gleam.fits' % (self.dir))
 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_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'