Ejemplo n.º 1
0
def create_w_term_like(im: Image,
                       w,
                       phasecentre=None,
                       remove_shift=False,
                       dopol=False) -> Image:
    """Create an image with a w term phase term in it:
    
    .. math::

    I(l,m) = e^{-2 \\pi j (w(\\sqrt{1-l^2-m^2}-1)}

    
    The vis phasecentre is used as the delay centre for the w term (i.e. where n==0)

    :param phasecentre:
    :param im: template image
    :param w: w value to evaluate (default is median abs)
    :param remove_shift:
    :param dopol: Do screen in polarisation?
    :return: Image
    """

    fim = copy_image(im)
    fim_shape = list(im.shape)
    if not dopol:
        fim_shape[1] = 1

    fim_array = numpy.zeros(fim_shape, dtype='complex')
    fim = create_image_from_array(fim_array,
                                  wcs=im.wcs,
                                  polarisation_frame=im.polarisation_frame)

    cellsize = abs(fim.wcs.wcs.cdelt[0]) * numpy.pi / 180.0
    nchan, npol, _, npixel = fim_shape
    if phasecentre is SkyCoord:
        wcentre = phasecentre.to_pixel(im.wcs, origin=1) - 1.0
    else:
        wcentre = [im.wcs.wcs.crpix[0] - 1.0, im.wcs.wcs.crpix[1] - 1.0]

    for chan in range(nchan):
        for pol in range(npol):
            fim.data[chan, pol, ...] = w_beam(npixel,
                                              npixel * cellsize,
                                              w=w,
                                              cx=wcentre[0],
                                              cy=wcentre[1],
                                              remove_shift=remove_shift)
    fov = npixel * cellsize
    fresnel = numpy.abs(w) * (0.5 * fov)**2
    log.debug(
        'create_w_term_image: For w = %.1f, field of view = %.6f, Fresnel number = %.2f'
        % (w, fov, fresnel))

    return fim
Ejemplo n.º 2
0
def create_w_term_like(im: Image, w, phasecentre=None, **kwargs) -> Image:
    """Create an image with a w term phase term in it:
    
    .. math::

    I(l,m) = e^{-2 \\pi j (w(\\sqrt{1-l^2-m^2}-1)}

    
    The vis phasecentre is used as the delay centre for the w term (i.e. where n==0)

    :param phasecentre:
    :param im: template image
    :param w: w value to evaluate (default is median abs)
    :return: Image
    """
    
    fim = copy_image(im)
    cellsize = abs(fim.wcs.wcs.cdelt[0]) * numpy.pi / 180.0
    nchan, npol, _, npixel = fim.data.shape
    if phasecentre is SkyCoord:
        wcentre = phasecentre.to_pixel(im.wcs, origin=1)
    else:
        wcentre=[im.wcs.wcs.crpix[0], im.wcs.wcs.crpix[1]]
        
    fim.data = numpy.zeros(fim.shape, dtype='complex')
    remove_shift=get_parameter(kwargs, "remove_shift", False)
    for chan in range(nchan):
        for pol in range(npol):
            fim.data[chan, pol,...] = w_beam(npixel, npixel * cellsize, w=w, cx=wcentre[0], cy=wcentre[1],
                                             remove_shift=remove_shift)
    
    fov = npixel * cellsize
    fresnel = numpy.abs(w) * (0.5 * fov) ** 2
    log.debug('create_w_term_image: For w = %.1f, field of view = %.6f, Fresnel number = %.2f' % (w, fov, fresnel))
    
    return fim
 def test_w_kernel_beam(self):
     assert_allclose(numpy.real(w_beam(5, 0.1, 0))[0, 0], 1.0)
     self.assertAlmostEqualScalar(w_beam(5, 0.1, 100)[2, 2], 1)
     self.assertAlmostEqualScalar(w_beam(10, 0.1, 100)[5, 5], 1)
     self.assertAlmostEqualScalar(w_beam(11, 0.1, 1000)[5, 5], 1)