Пример #1
0
 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_block(self):
     self.vis = create_blockvisibility(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 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)
Пример #4
0
    def test_phase_rotation_block(self):
        self.vis = create_blockvisibility(
            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_blockvisibility(
            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)
Пример #5
0
def shift_vis_to_image(vis: Union[Visibility, BlockVisibility], im: Image, tangent: bool = True, inverse: bool = False) \
        -> Union[Visibility, BlockVisibility]:
    """Shift visibility in place to the phase centre of the Image

    :param vis: Visibility or BlockVisibility
    :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) or isinstance(vis, BlockVisibility), "vis is not a Visibility or " \
                                                                            "BlockVisibility: %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 RASCIL 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

    return vis