processing_components/griddata/kernels.py
def create_pswf_convolutionfunction(im, oversampling=8, support=6):
    """ Fill an Anti-Aliasing filter into a ConvolutionFunction

    Fill the Prolate Spheroidal Wave Function into a GriData with the specified oversampling. Only the inner
    non-zero part is retained

    Also returns the griddata correction function as an image

    :param im: Image template
    :param oversampling: Oversampling of the convolution function in uv space
    :return: griddata correction Image, griddata kernel as ConvolutionFunction
    """
    assert isinstance(im, Image), im
    # Calculate the convolution kernel. We oversample in u,v space by the factor oversampling
    cf = create_convolutionfunction_from_image(im, oversampling=oversampling, support=support)
    
    kernel = numpy.zeros([oversampling, support])
    for grid in range(support):
        for subsample in range(oversampling):
            nu = ((grid - support // 2) - (subsample - oversampling // 2) / oversampling)
            kernel[subsample, grid] = grdsf([nu / (support // 2)])[1]
    
    kernel /= numpy.sum(numpy.real(kernel[oversampling // 2, :]))
    
    nchan, npol, _, _ = im.shape
    
    cf.data = numpy.zeros([nchan, npol, 1, oversampling, oversampling, support, support]).astype('complex')
    for y in range(oversampling):
        for x in range(oversampling):
            cf.data[:, :, 0, y, x, :, :] = numpy.outer(kernel[y, :], kernel[x, :])[numpy.newaxis, numpy.newaxis, ...]
    norm = numpy.sum(numpy.real(cf.data[0, 0, 0, 0, 0, :, :]))
    cf.data /= norm
    
    # Now calculate the griddata correction function as an image with the same coordinates as the image
    # which is necessary so that the correction function can be applied directly to the image
    nchan, npol, ny, nx = im.data.shape
    nu = numpy.abs(2.0 * coordinates(nx))
    gcf1d = grdsf(nu)[0]
    gcf = numpy.outer(gcf1d, gcf1d)
    gcf[gcf > 0.0] = gcf.max() / gcf[gcf > 0.0]
    
    gcf_data = numpy.zeros_like(im.data)
    gcf_data[...] = gcf[numpy.newaxis, numpy.newaxis, ...]
    gcf_image = create_image_from_array(gcf_data, cf.projection_wcs, im.polarisation_frame)
    
    return gcf_image, cf
 Fill an Anti-Aliasing filter into a ConvolutionFunction

    Fill the Prolate Spheroidal Wave Function into a GriData with the specified oversampling. Only the inner
    non-zero part is retained

    Also returns the griddata correction function as an image

    :param im: Image template
    :param oversampling: Oversampling of the convolution function in uv space
    :return: griddata correction Image, griddata kernel as ConvolutionFunction
    
Fill an Anti-Aliasing filter into a ConvolutionFunction
Fill the Prolate Spheroidal Wave Function into a GriData with the specified oversampling. Only the inner
non-zero part is retained

Also returns the griddata correction function as an image
Fill an Anti - Aliasing filter into a ConvolutionFunction Fill the Prolate Spheroidal Wave Function into a GriData with the specified oversampling . Only the inner non - zero part is retained Also returns the griddata correction function as an image
def create_pswf_convolutionfunction(im, oversampling=8, support=6):
    assert isinstance(im, Image), im
    cf = create_convolutionfunction_from_image(im, oversampling=oversampling, support=support)
    kernel = numpy.zeros([oversampling, support])
    for grid in range(support):
        for subsample in range(oversampling):
            nu = ((grid - support // 2) - (subsample - oversampling // 2) / oversampling)
            kernel[subsample, grid] = grdsf([nu / (support // 2)])[1]
    kernel /= numpy.sum(numpy.real(kernel[oversampling // 2, :]))
    nchan, npol, _, _ = im.shape
    cf.data = numpy.zeros([nchan, npol, 1, oversampling, oversampling, support, support]).astype('complex')
    for y in range(oversampling):
        for x in range(oversampling):
            cf.data[:, :, 0, y, x, :, :] = numpy.outer(kernel[y, :], kernel[x, :])[numpy.newaxis, numpy.newaxis, ...]
    norm = numpy.sum(numpy.real(cf.data[0, 0, 0, 0, 0, :, :]))
    cf.data /= norm
    nchan, npol, ny, nx = im.data.shape
    nu = numpy.abs(2.0 * coordinates(nx))
    gcf1d = grdsf(nu)[0]
    gcf = numpy.outer(gcf1d, gcf1d)
    gcf[gcf > 0.0] = gcf.max() / gcf[gcf > 0.0]
    gcf_data = numpy.zeros_like(im.data)
    gcf_data[...] = gcf[numpy.newaxis, numpy.newaxis, ...]
    gcf_image = create_image_from_array(gcf_data, cf.projection_wcs, im.polarisation_frame)
    return gcf_image, cf
def create_pswf_convolutionfunction ( im , oversampling = 8 , support = 6 ) : assert isinstance ( im , Image ) , im cf = create_convolutionfunction_from_image ( im , oversampling = oversampling , support = support ) kernel = numpy . zeros ( [ oversampling , support ] ) for grid in range ( support ) : for subsample in range ( oversampling ) : nu = ( ( grid - support // 2 ) - ( subsample - oversampling // 2 ) / oversampling ) kernel [ subsample , grid ] = grdsf ( [ nu / ( support // 2 ) ] ) [ 1 ] kernel /= numpy . sum ( numpy . real ( kernel [ oversampling // 2 , : ] ) ) nchan , npol , _ , _ = im . shape cf . data = numpy . zeros ( [ nchan , npol , 1 , oversampling , oversampling , support , support ] ) . astype ( 'complex' ) for y in range ( oversampling ) : for x in range ( oversampling ) : cf . data [ : , : , 0 , y , x , : , : ] = numpy . outer ( kernel [ y , : ] , kernel [ x , : ] ) [ numpy . newaxis , numpy . newaxis , ... ] norm = numpy . sum ( numpy . real ( cf . data [ 0 , 0 , 0 , 0 , 0 , : , : ] ) ) cf . data /= norm nchan , npol , ny , nx = im . data . shape nu = numpy . abs ( 2.0 * coordinates ( nx ) ) gcf1d = grdsf ( nu ) [ 0 ] gcf = numpy . outer ( gcf1d , gcf1d ) gcf [ gcf > 0.0 ] = gcf . max ( ) / gcf [ gcf > 0.0 ] gcf_data = numpy . zeros_like ( im . data ) gcf_data [ ... ] = gcf [ numpy . newaxis , numpy . newaxis , ... ] gcf_image = create_image_from_array ( gcf_data , cf . projection_wcs , im . polarisation_frame ) return gcf_image , cf
Fill an Anti-Aliasing filter into a ConvolutionFunction
Fill the Prolate Spheroidal Wave Function into a GriData with the specified oversampling.
Fill an Anti - Aliasing filter into a ConvolutionFunction Fill the Prolate Spheroidal Wave Function into a GriData with the specified oversampling .
""" Fill an Anti-Aliasing filter into a ConvolutionFunction

    Fill the Prolate Spheroidal Wave Function into a GriData with the specified oversampling. Only the inner
    non-zero part is retained

    Also returns the griddata correction function as an image

    :param im: Image template
    :param oversampling: Oversampling of the convolution function in uv space
    :return: griddata correction Image, griddata kernel as ConvolutionFunction
    """ # Calculate the convolution kernel. We oversample in u,v space by the factor oversampling # Now calculate the griddata correction function as an image with the same coordinates as the image # which is necessary so that the correction function can be applied directly to the image
griddata correction Image, griddata kernel as ConvolutionFunction
griddata correction Image griddata kernel as ConvolutionFunction
im
None
oversampling
Oversampling of the convolution function in uv space
Oversampling of the convolution function in uv space
support