Esempio n. 1
0
 def test_tapering_Gaussian(self):
     self.actualSetUp()
     size_required = 0.010
     self.componentvis = weight_visibility(self.componentvis,
                                           self.model,
                                           algoritm='uniform')
     self.componentvis = taper_visibility_gaussian(self.componentvis,
                                                   beam=size_required)
     psf, sumwt = invert_2d(self.componentvis, self.model, dopsf=True)
     export_image_to_fits(
         psf, '%s/test_weighting_gaussian_taper_psf.fits' % self.dir)
     xfr = fft_image(psf)
     xfr.data = xfr.data.real.astype('float')
     export_image_to_fits(
         xfr, '%s/test_weighting_gaussian_taper_xfr.fits' % self.dir)
     npixel = psf.data.shape[3]
     sl = slice(npixel // 2 - 7, npixel // 2 + 8)
     fit = fit_2dgaussian(psf.data[0, 0, sl, sl])
     # if fit.x_stddev <= 0.0 or fit.y_stddev <= 0.0:
     #     raise ValueError('Error in fitting to psf')
     # fit_2dgaussian returns sqrt of variance. We need to convert that to FWHM.
     # https://en.wikipedia.org/wiki/Full_width_at_half_maximum
     scale_factor = numpy.sqrt(8 * numpy.log(2.0))
     size = numpy.sqrt(fit.x_stddev * fit.y_stddev) * scale_factor
     # Now we need to convert to radians
     size *= numpy.pi * self.model.wcs.wcs.cdelt[1] / 180.0
     # Very impressive! Desired 0.01 Acheived 0.0100006250829
     assert numpy.abs(size - size_required) < 0.01 * size_required, \
         "Fit should be %f, actually is %f" % (size_required, size)
Esempio n. 2
0
 def test_tapering_Tukey(self):
     self.actualSetUp()
     self.componentvis = weight_visibility(self.componentvis,
                                           self.model,
                                           algoritm='uniform')
     self.componentvis = taper_visibility_tukey(self.componentvis,
                                                tukey=1.0)
     psf, sumwt = invert_2d(self.componentvis, self.model, dopsf=True)
     export_image_to_fits(
         psf, '%s/test_weighting_tukey_taper_psf.fits' % self.dir)
     xfr = fft_image(psf)
     xfr.data = xfr.data.real.astype('float')
     export_image_to_fits(
         xfr, '%s/test_weighting_tukey_taper_xfr.fits' % self.dir)
Esempio n. 3
0
 def test_convert_weight(self):
     cvis = convert_blockvisibility_to_visibility(self.blockvis)
     model = create_image_from_visibility(
         vis=cvis,
         npixel=256,
         cellsize=0.001,
         phasecentre=self.phasecentre,
         polarisation_frame=PolarisationFrame('stokesI'))
     cvis = weight_visibility(cvis, model)
     assert numpy.mean(cvis.data['imaging_weight']) < 1.0
     assert numpy.std(cvis.data['imaging_weight']) > 0.0
     dvis = decoalesce_visibility(cvis)
     assert numpy.mean(dvis.data['imaging_weight']) < 1.0
     assert numpy.std(dvis.data['imaging_weight']) > 0.0
     assert dvis.nvis == self.blockvis.nvis