Interpolation¶
The scikits.timeseries.lib.interpolate submodule contains functions for interpolating and filling missing values in MaskedArray’s and TimeSeries objects.
- forward_fill(marr, maxgap=None)¶
Forward fills masked values in a 1-d array when there are less maxgap consecutive masked values.
Parameters: marr : MaskedArray
Series to fill
maxgap : {int}, optional
Maximum gap between consecutive masked values. If maxgap is not specified, all masked values are forward-filled.
Examples
>>> x = ma.arange(20) >>> x[(x%5)!=0] = ma.masked >>> print x [0 -- -- -- -- 5 -- -- -- -- 10 -- -- -- -- 15 -- -- -- --] >>> print forward_fill(x) [0 0 0 0 0 5 5 5 5 5 10 10 10 10 10 15 15 15 15 15]
- backward_fill(marr, maxgap=None)¶
Backward fills masked values in a 1-d array when there are less than maxgap consecutive masked values.
Parameters: marr : MaskedArray
Series to fill
maxgap : {int}, optional
Maximum gap between consecutive masked values. If maxgap is not specified, all masked values are backward-filled.
Examples
>>> x = ma.arange(20) >>> x[(x%5)!=0] = ma.masked >>> print x [0 -- -- -- -- 5 -- -- -- -- 10 -- -- -- -- 15 -- -- -- --] >>> print backward_fill(x) [0 5 5 5 5 5 10 10 10 10 10 15 15 15 15 15 0 0 0 0]
- interp_masked1d(marr, kind='linear')¶
Interpolates masked values in an array according to the given method.
Parameters: marr : MaskedArray
Array to fill
kind : {‘constant’, ‘linear’, ‘cubic’, quintic’}, optional
Type of interpolation
