Gridfill

Gridfill is a Python package for filling in missing values in gridded data. Missing values are filled by solving Poisson’s equation using an iterative relaxation scheme at the missing values, resulting in a smooth filling.

The core package runs on Python 3, on Linux and OSX (maybe on Windows too), and requires numpy. Gridfill has an optional interface for working with iris cubes.

How to Install

The easiest way to install is using the conda package manager:

conda install -c conda-forge gridfill

If you want to install from source you will need to have setuptools, cython, and numpy installed before you start. Once you have the dependencies installation should be as simple as entering the gridfill source directory and doing:

python setup.py install

Getting Started

Gridfill has one core function gridfill.fill. This function accepts a masked array array as input, as well as some parameters that control the numerical scheme, and returns a 2-tuple consisting of the filled in array and some convergence information:

import gridfill

# Fill an array where the y-dimension is first and the x-dimension is
# second, with the x-dimension being cyclic, using a tolerance of 0.01
# (tolerance depends on your data values, choose appropriately):
filled_array, converged = gridfill.fill(masked_array, 1, 0, 0.01, cyclic=True)

If you are working with iris.cube.Cube objects then the convenient gridfill.fill_cube function is probably the tool for the job:

import gridfill

# With a Cube as input we don't need to give dimension numbers:
filled_cube = gridfill.fill_cube(cube_with_missing, 0.01, cyclic=True)

Development and Contributing

Development is done through Github. Bug reports and feature requests should be made using the repository issues page. Pull requests for new features and bug fixes are welcome!