esmtools.stats.rm_trend

esmtools.stats.rm_trend(x, y=None, dim='time', nan_policy='none')[source]

Removes a linear fit from y regressed onto x.

Parameters:
  • x (xarray object) – Independent variable used in the linear fit. If y is None, treat x as dependent variable.
  • y (xarray object) – Dependent variable used in the linear fit. If None, treat x as the independent variable.
  • dim (str, optional) – Dimension to apply linear fit over. Defaults to “time”.
  • nan_policy (str, optional) –

    Policy to use when handling nans. Defaults to “none”.

    • ’none’, ‘propagate’: If a NaN exists anywhere on the given dimension,
      return nans for that whole dimension.
    • ’raise’: If a NaN exists at all in the datasets, raise an error.
    • ’omit’, ‘drop’: If a NaN exists in x or y, drop that index and
      compute the slope without it.
Returns:

y with linear fit removed.

Return type:

xarray object