detrend

function of dascore.proc.detrend source

detrend(
    self ,
    dim: str ,
    type: Literal[‘linear’, ‘constant’] = linear,
)-> ‘Self’

Remove a constant or linear trend from the data along one dimension.

Parameters

Parameter Description
patch The patch to detrend.
dim Name of the dimension to detrend along.
type The trend to subtract: “linear” (the default) removes a least-squares
line, “constant” removes the mean.
Note

NaN samples are treated as missing: the trend is fit to the other samples of each trace and NaN samples stay NaN; a trace with too few samples for the fit comes back all NaN.

Examples

import dascore
pa = dascore.get_example_patch()
# Subtract the best-fitting line from each channel.
out = pa.detrend("time")
# Or only the mean.
demeaned = pa.detrend("time", type="constant")