This package 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).
Warning
Out of the methods available in MATLAB's inpaint_nans
, Inpaintings.jl currently only implements MATLAB's method 1
.
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.
The inpaint
function can also be used to inpaint NaN
s or any other values, thanks to the syntax described below and in the documentation.
Tip
Like every Julia package you must first add it via ]add Inpaintings
.
And every time you want to use Inpaintings.jl, you must start with
julia> using Inpaintings
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 no missing
s, then
julia> inpaint(A) # will inpaint NaN values
To inpaint any specified value, use
julia> inpaint(A, -999) # will inpaint -999 values
Tip
The value to inpaint can be specified as NaN
or missing
, too, if you want to have explicit code.
Use a function f
as a first argument (f
will be applied to all the elements of the array and must return a boolean), to inpaint those values:
julia> inpaint(f, A)
In this case, the values of A
for which f
returns true
will be inpainted.
Tip
f
can be ismissing
or isnan
, but it can also be something like x -> x < 0
for example.
To allow cyclic dimensions, use
julia> inpaint(A, cycledims=[1]) # 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.
Suggestions, ideas, issues, and PRs to improve the code or implement additional methods are welcome!