Skip to content

cubic_spline_interp

Classes:

Name Description
CubicSplineInterp

Classes#

CubicSplineInterp #

Bases: QualityHandler


Interpolate over mask values in timeseries data using the specified method

Parameters#

variable_name : xarray.DataArray The dataArray to clean. mask : bool Logical tensor of elements to "nan" out and replace npt : int The number of points on either side of the bad values that interpolation occurs over method : string Interpolation scheme to use (linear, cubic, pchip, etc) max_gap : int Max number of consective nan's to interpolate across, must be <= npt/2

Returns#

da : xarray.DataArray The dataArray with nan's filled in


Classes:

Name Description
Parameters

Methods:

Name Description
run

Attributes:

Name Type Description
parameters Parameters

Attributes#

parameters class-attribute instance-attribute #
parameters: Parameters = Parameters()

Classes#

Parameters #

Bases: BaseModel

Attributes:

Name Type Description
max_gap int
method str
n_points int
Attributes#
max_gap class-attribute instance-attribute #
max_gap: int = 6
method class-attribute instance-attribute #
method: str = 'cubic'
n_points class-attribute instance-attribute #
n_points: int = 12

Functions#

run #
run(
    dataset: xr.Dataset,
    variable_name: str,
    failures: NDArray[np.bool_],
) -> xr.Dataset
Source code in tsdat/qc/handlers/cubic_spline_interp.py
def run(
    self, dataset: xr.Dataset, variable_name: str, failures: NDArray[np.bool_]
) -> xr.Dataset:
    from mhkit.dolfyn.adv.clean import clean_fill

    if failures.any():
        dataset[variable_name] = clean_fill(
            dataset[variable_name],
            mask=failures,
            npt=self.parameters.n_points,
            method=self.parameters.method,
            maxgap=self.parameters.max_gap,
        )
    return dataset