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_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 = predict_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 shift_vis_to_image(vis: Visibility, im: Image, tangent: bool = True, inverse: bool = False) -> Visibility: """Shift visibility to the FFT phase centre of the image in place :param vis: Visibility data :param im: Image model used to determine phase centre :param tangent: Is the shift purely on the tangent plane True|False :param inverse: Do the inverse operation True|False :return: visibility with phase shift applied and phasecentre updated """ assert isinstance(vis, Visibility), "vis is not a Visibility: %r" % vis nchan, npol, ny, nx = im.data.shape # Convert the FFT definition of the phase center to world coordinates (1 relative) # This is the only place in ARL where the relationship between the image and visibility # frames is defined. image_phasecentre = pixel_to_skycoord(nx // 2 + 1, ny // 2 + 1, im.wcs, origin=1) if vis.phasecentre.separation(image_phasecentre).rad > 1e-15: if inverse: log.debug("shift_vis_from_image: shifting phasecentre from image phase centre %s to visibility phasecentre " "%s" % (image_phasecentre, vis.phasecentre)) else: log.debug("shift_vis_from_image: shifting phasecentre from vis phasecentre %s to image phasecentre %s" % (vis.phasecentre, image_phasecentre)) vis = phaserotate_visibility(vis, image_phasecentre, tangent=tangent, inverse=inverse) vis.phasecentre = im.phasecentre assert isinstance(vis, Visibility), "after phase_rotation, vis is not a Visibility" return vis
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=1e-7) assert_allclose(rotatedvis.uvw, vismodel2.uvw, rtol=1e-7)