Inpaintings.jl provides a Julia version of MATLAB’s
inpaint_nans function (originally written by John d’Errico, available on the MathWorks File Exchange website and ported here with his authorization by personal communication).
Simply put, Inpaintings.jl provides a simple
inpaint function, which takes an array
A as input and inpaints its
missing values by solving a simple n-dimensional PDE.
inpaint function can also be used to inpaint
NaNs or any other values, thanks to the syntax described below and in the documentation.
Like every Julia package you must first add it via
And every time you want to use Inpaintings.jl, you must start with
julia> using Inpaintings
In order to
inpaint an array
missing values, simply apply
inpaint to your array:
julia> inpaint(A) # will inpaint missing values
The array to be inpainted can be a vector, a matrix, or even an n-dimensional array.
If your array
A has some
NaN values and is filled with floats otherwise, then
julia> inpaint(A) # will inpaint NaN values
Inpaintings.jl provides a syntax to inpaint any specified value via
julia> inpaint(A, -999) # will inpaint -999 values
(The value to inpaint can be specified as
Alternatively, Inpaintings.jl also provides a syntax taking a boolean function
f as an argument before the array (
f will be applied to all the elements of the array and must return a boolean).
julia> inpaint(f, A)
In this case, the values of
A for which
true will be inpainted.
f can be, e.g.,
isnan, but it can also be
x -> x < 0.)
Finally, Inpaintings.jl provides a syntax to allow some dimensions to be assumed cyclic:
julia> inpaint(A, cycledims=) # will inpaint A with dimension 1 as cyclic
(The cyclic dimensions must be an array of
Int64 that contains the dimension number of cyclic dimensions.)
See the docs if you want to see more examples.