From 15878e8036ce1d1b1532e40048e698fc7eda372e Mon Sep 17 00:00:00 2001
From: Niklas Selke <n.selke@fz-juelich.de>
Date: Mon, 14 Nov 2022 16:39:04 +0100
Subject: [PATCH] Finished the data deseasonalization code.

---
 toarstats/trends/utils.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/toarstats/trends/utils.py b/toarstats/trends/utils.py
index aaa0246..0a07989 100644
--- a/toarstats/trends/utils.py
+++ b/toarstats/trends/utils.py
@@ -22,4 +22,8 @@ def deseasonalize(data):
         "+np.cos(month*4*np.pi/12)+np.sin(month*4*np.pi/12)",
         pd.DataFrame({"value": data["value"], "month": data.index.month})
     ).fit(method="qr").predict(pd.DataFrame({"month": range(1, 13)}))
-    return data
+    idx = data.index
+    return pd.DataFrame({
+        "value": data["value"].values - seasonal_cycle[idx.month-1].values,
+        "datetime": (idx.year-2000)*12 + idx.month
+    })
-- 
GitLab