Gridding and Degridding

This section contains routines for

  1. Gridding complex visibilities onto an image.
  2. Degridding complex visibilities from an image.

Simple

Gridding with no correction for the W-term.

Numpy

grid(vis, uvw, flags, weights, ref_wave, …) Convolutional gridder which grids visibilities vis at the specified uvw coordinates and ref_wave reference wavelengths using the specified convolution_filter.
degrid(grid, uvw, weights, ref_wave, …[, …]) Convolutional degridder (continuum)
africanus.gridding.simple.grid(vis, uvw, flags, weights, ref_wave, convolution_filter, cell_size, nx=1024, ny=1024, grid=None)[source]

Convolutional gridder which grids visibilities vis at the specified uvw coordinates and ref_wave reference wavelengths using the specified convolution_filter.

Variable numbers of correlations are supported.

  • (row, chan, corr_1, corr_2) vis will result in a (ny, nx, corr_1, corr_2) grid.
  • (row, chan, corr_1) vis will result in a (ny, nx, corr_1) grid.
Parameters:

vis : np.ndarray

complex visibility array of shape (row, chan, corr_1, corr_2)

uvw : np.ndarray

float64 array of UVW coordinates of shape (row, 3) in wavelengths.

weights : np.ndarray

float32 or float64 array of weights of shape (row, chan, corr_1, corr_2). Set this to np.ones_like(vis, dtype=np.float32) as default.

flags : np.ndarray

flagged array of shape (row, chan, corr_1, corr_2). Any positive quantity will indicate that the corresponding visibility should be flagged. Set to np.zeros_like(vis, dtype=np.bool) as default.

ref_wave : np.ndarray

float64 array of wavelengths of shape (chan,)

convolution_filter : ConvolutionFilter

Convolution filter

cell_size : float

Cell size in arcseconds.

nx : integer, optional

Size of the grid’s X dimension

ny : integer, optional

Size of the grid’s Y dimension

grid : np.ndarray, optional

complex64/complex128 array of shape (ny, nx, corr_1, corr_2) If supplied, this array will be used as the gridding target, and nx and ny will be derived from this grid’s dimensions.

Returns:

np.ndarray

(ny, nx, corr_1, corr_2) complex ndarray of gridded visibilities. The number of correlations may vary, depending on the shape of vis.

africanus.gridding.simple.degrid(grid, uvw, weights, ref_wave, convolution_filter, cell_size, dtype=<MagicMock id='140362076956152'>)[source]

Convolutional degridder (continuum)

Variable numbers of correlations are supported.

  • (ny, nx, corr_1, corr_2) grid will result in a (row, chan, corr_1, corr_2) vis
  • (ny, nx, corr_1) grid will result in a (row, chan, corr_1) vis
Parameters:

grid : np.ndarray

float or complex grid of visibilities of shape (ny, nx, corr_1, corr_2)

uvw : np.ndarray

float64 array of UVW coordinates of shape (row, 3) in wavelengths.

weights : np.ndarray

float32 or float64 array of weights of shape (row, chan, corr_1, corr_2). Set this to np.ones_like(vis, dtype=np.float32) as default.

ref_wave : np.ndarray

float64 array of wavelengths of shape (chan,)

convolution_filter : ConvolutionFilter

Convolution Filter

cell_size : float

Cell size in arcseconds.

dtype : numpy.dtype

Data type of the visibilities

Returns:

np.ndarray

(row, chan, corr_1, corr_2) complex ndarray of visibilities

Dask

grid(vis, uvw, flags, weights, ref_wave, …) Convolutional gridder which grids visibilities vis at the specified uvw coordinates and ref_wave reference wavelengths using the specified convolution_filter.
degrid(grid, uvw, weights, ref_wave, …) Convolutional degridder (continuum)
africanus.gridding.simple.dask.grid(vis, uvw, flags, weights, ref_wave, convolution_filter, cell_size, nx=1024, ny=1024)[source]

Convolutional gridder which grids visibilities vis at the specified uvw coordinates and ref_wave reference wavelengths using the specified convolution_filter.

Variable numbers of correlations are supported.

  • (row, chan, corr_1, corr_2) vis will result in a (ny, nx, corr_1, corr_2) grid.
  • (row, chan, corr_1) vis will result in a (ny, nx, corr_1) grid.
Parameters:

vis : np.ndarray

complex visibility array of shape (row, chan, corr_1, corr_2)

uvw : np.ndarray

float64 array of UVW coordinates of shape (row, 3) in wavelengths.

weights : np.ndarray

float32 or float64 array of weights of shape (row, chan, corr_1, corr_2). Set this to da.ones_like(vis, dtype=np.float32) as default.

flags : np.ndarray

flagged array of shape (row, chan, corr_1, corr_2). Any positive quantity will indicate that the corresponding visibility should be flagged. Set to da.zeros_like(vis, dtype=np.bool) as default.

ref_wave : np.ndarray

float64 array of wavelengths of shape (chan,)

convolution_filter : ConvolutionFilter

Convolution filter

cell_size : float

Cell size in arcseconds.

nx : integer, optional

Size of the grid’s X dimension

ny : integer, optional

Size of the grid’s Y dimension

grid : np.ndarray, optional

complex64/complex128 array of shape (ny, nx, corr_1, corr_2) If supplied, this array will be used as the gridding target, and nx and ny will be derived from this grid’s dimensions.

Returns:

np.ndarray

(ny, nx, corr_1, corr_2) complex ndarray of gridded visibilities. The number of correlations may vary, depending on the shape of vis.

africanus.gridding.simple.dask.degrid(grid, uvw, weights, ref_wave, convolution_filter, cell_size)[source]

Convolutional degridder (continuum)

Variable numbers of correlations are supported.

  • (ny, nx, corr_1, corr_2) grid will result in a (row, chan, corr_1, corr_2) vis
  • (ny, nx, corr_1) grid will result in a (row, chan, corr_1) vis
Parameters:

grid : np.ndarray

float or complex grid of visibilities of shape (ny, nx, corr_1, corr_2)

uvw : np.ndarray

float64 array of UVW coordinates of shape (row, 3) in wavelengths.

weights : np.ndarray

float32 or float64 array of weights of shape (row, chan, corr_1, corr_2). Set this to da.ones_like(vis, dtype=np.float32) as default.

ref_wave : np.ndarray

float64 array of wavelengths of shape (chan,)

convolution_filter : ConvolutionFilter

Convolution Filter

cell_size : float

Cell size in arcseconds.

dtype : numpy.dtype

Data type of the visibilities

Returns:

np.ndarray

(row, chan, corr_1, corr_2) complex ndarray of visibilities

Nifty

Dask wrappers around Nifty’s Gridder.

Dask

grid_config([nx, ny, eps, cell_size_x, …]) Returns a wrapper around a NIFTY GridderConfiguration object.
grid(vis, uvw, flags, weights, frequencies, …) Grids the supplied visibilities in parallel.
dirty(grid, grid_config) Computes the dirty image from gridded visibilities and the gridding configuration.
degrid(grid, uvw, flags, weights, …[, …]) Degrids the visibilities from the supplied grid in parallel.
model(image, grid_config) Computes model visibilities from an image and a gridding configuration.
africanus.gridding.nifty.dask.grid_config(nx=1024, ny=1024, eps=2e-13, cell_size_x=2.0, cell_size_y=2.0)[source]

Returns a wrapper around a NIFTY GridderConfiguration object.

Parameters:

nx : int, optional

Number of X pixels in the grid. Defaults to 1024.

ny : int, optional

Number of Y pixels in the grid. Defaults to 1024.

cell_size_x : float, optional

Cell size of the X pixel in arcseconds. Defaults to 2.0.

cell_size_y : float, optional

Cell size of the Y pixel in arcseconds. Defaults to 2.0.

eps : float

Gridder accuracy error. Defaults to 2e-13

Returns:

grid_config : GridderConfigWrapper

The NIFTY Gridder Configuration

africanus.gridding.nifty.dask.grid(vis, uvw, flags, weights, frequencies, grid_config, wmin=-1e+30, wmax=1e+30, streams=None)[source]

Grids the supplied visibilities in parallel. Note that a grid is create for each visibility chunk.

Parameters:

vis : dask.array.Array

visibilities of shape (row, chan, corr)

uvw : dask.array.Array

uvw coordinates of shape (row, 3)

flags : dask.array.Array

flags of shape (row, chan, corr)

weights : dask.array.Array

weights of shape (row, chan, corr).

frequencies : dask.array.Array

frequencies of shape (chan,)

grid_config : GridderConfigWrapper

Gridding Configuration

wmin : float

Minimum W coordinate to grid. Defaults to -1e30.

wmax : float

Maximum W coordinate to grid. Default to 1e30.

streams : int, optional

Number of parallel gridding operations. Default to None, in which case as many grids as visibility chunks will be created.

Returns:

grid : dask.array.Array

grid of shape (ny, nx, corr)

africanus.gridding.nifty.dask.dirty(grid, grid_config)[source]

Computes the dirty image from gridded visibilities and the gridding configuration.

Parameters:

grid : dask.array.Array

Gridded visibilities of shape (nv, nu, ncorr)

grid_config : GridderConfigWrapper

Gridding configuration

Returns:

dirty : dask.array.Array

dirty image of shape (ny, nx, corr)

africanus.gridding.nifty.dask.degrid(grid, uvw, flags, weights, frequencies, grid_config, wmin=-1e+30, wmax=1e+30)[source]

Degrids the visibilities from the supplied grid in parallel.

Parameters:

grid : dask.array.Array

gridded visibilities of shape (ny, nx, corr)

uvw : dask.array.Array

uvw coordinates of shape (row, 3)

flags : dask.array.Array

flags of shape (row, chan, corr)

weights : dask.array.Array

weights of shape (row, chan, corr). Currently unsupported and ignored.

frequencies : dask.array.Array

frequencies of shape (chan,)

grid_config : GridderConfigWrapper

Gridding Configuration

wmin : float

Minimum W coordinate to grid. Defaults to -1e30.

wmax : float

Maximum W coordinate to grid. Default to 1e30.

Returns:

grid : dask.array.Array

grid of shape (ny, nx, corr)

africanus.gridding.nifty.dask.model(image, grid_config)[source]

Computes model visibilities from an image and a gridding configuration.

Parameters:

image : dask.array.Array

Image of shape (ny, nx, corr).

grid_config : GridderConfigWrapper

nifty gridding configuration object

Returns:

model_vis : dask.array.Array

Model visibilities of shape (nu, nv, corr).

Utilities

estimate_cell_size(u, v, wavelength[, …]) Estimate the cell size in arcseconds given baseline u and v coordinates, as well as the wavelengths, \(\lambda\).
africanus.gridding.util.estimate_cell_size(u, v, wavelength, factor=3.0, ny=None, nx=None)[source]

Estimate the cell size in arcseconds given baseline u and v coordinates, as well as the wavelengths, \(\lambda\).

The cell size is computed as:

\[ \begin{align}\begin{aligned}\Delta u = 1.0 / \left( 2 \times \text{ factor } \times \max (\vert u \vert) / \min( \lambda) \right)\\\Delta v = 1.0 / \left( 2 \times \text{ factor } \times \max (\vert v \vert) / \min( \lambda) \right)\end{aligned}\end{align} \]

If ny and nx are provided the following checks are performed and exceptions are raised on failure:

\[ \begin{align}\begin{aligned}\Delta u * \text{ ny } \leq \min (\lambda) / \min (\vert u \vert)\\\Delta v * \text{ nx } \leq \min (\lambda) / \min (\vert v \vert)\end{aligned}\end{align} \]
Parameters:

u : numpy.ndarray or float

Maximum u coordinate in metres.

v : numpy.ndarray or float

Maximum v coordinate in metres.

wavelength : numpy.ndarray or float

Wavelengths, in metres.

factor : float, optional

Scaling factor

ny : int, optional

Grid y dimension

nx : int, optional

Grid x dimension

Returns:

numpy.ndarray

Cell size of u and v in arcseconds with shape (2,)

Raises:

ValueError

If the cell size criteria are not matched.