-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switch from _linregress to da.polyfit? #177
Comments
Oeh, I found a bug, some years were all NaN, this means there no timeseries at all with no NaNs and then the linregress with return all NaNs as well. Maybe nice to add a check for this type of error. |
Hi Sem, not sure if I get it correctly. I just tested the old implementation of preprocess (still using |
Here is an example: import numpy as np
import urllib
import xarray as xr
from s2spy import preprocess
import matplotlib.pyplot as plt
# URL of the dataset from zenodo
sst_url = "https://zenodo.org/record/8186914/files/sst_daily_1959-2021_5deg_Pacific_175_240E_25_50N.nc"
sst_field = "sst_daily_1959-2021_5deg_Pacific_175_240E_25_50N.nc"
urllib.request.urlretrieve(sst_url, sst_field)
data = xr.open_dataset(sst_field)
# manually turn all values to np.nan for one time step.
data_subset['sst'].loc[dict(time="2020-12-20")] = np.ones(data_subset['sst'].isel(time=100).values.shape) * np.nan
preprocessor = preprocess.Preprocessor(
rolling_window_size=25,
timescale="daily",
detrend="linear",
subtract_climatology=True,
)
preprocessor.fit(data_subset)
preprocessor.trend["slope"].sst.plot() The values I got are not all nan: Slope: Intercept: |
This is the input data before it enters
preprocess._detrend()
:This is what I tried:
The slope & intercept is all NaN.
While:
coeffs.sel(degree=1).plot():
I don't know why this goes wrong..
It was able to fit at this floating precision before.
These are some trend values for daily soil moisture in EU:
The text was updated successfully, but these errors were encountered: