Skip to content

Latest commit

 

History

History
87 lines (66 loc) · 3.65 KB

README.md

File metadata and controls

87 lines (66 loc) · 3.65 KB

Inpaintings.jl

License: MIT

Description

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 NaNs or any other values, thanks to the syntax described below and in the documentation.

Usage

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

Inpaint missing values

julia> inpaint(A) # will inpaint missing values

The array to be inpainted can be a vector, a matrix, or even an n-dimensional array.

Inpaint NaNs

If your array A has no missings, then

julia> inpaint(A) # will inpaint NaN values

Inpaint specified value

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.

Inpaint with a condition function

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.

Cyclic dimensions

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.)

Documentation

See the docs if you want to see more examples.

Contributions

Suggestions, ideas, issues, and PRs to improve the code or implement additional methods are welcome!