From e26c34b7f29936dedce1f0cfa962a79e66796733 Mon Sep 17 00:00:00 2001 From: chenyangkang Date: Mon, 3 Jun 2024 14:44:43 +0800 Subject: [PATCH 1/3] gif gridding debug --- stemflow/utils/plot_gif.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/stemflow/utils/plot_gif.py b/stemflow/utils/plot_gif.py index 8573276..09d6bfc 100644 --- a/stemflow/utils/plot_gif.py +++ b/stemflow/utils/plot_gif.py @@ -146,9 +146,15 @@ def animate(i, norm, log_scale=log_scale): sub = data[data["Temporal_indexer"] == i].copy() temporal_value = np.array(sub[Temporal1].values)[0] - sub.loc[:, f"{Spatio1}_grid"] = np.digitize(sub[Spatio1], lng_gird, right=True) - sub.loc[:, f"{Spatio2}_grid"] = np.digitize(sub[Spatio2], lat_gird, right=False) - sub = sub[(sub[f"{Spatio1}_grid"] <= lng_size + 1) & (sub[f"{Spatio2}_grid"] <= lat_size + 1)] + g1 = np.digitize(sub[Spatio1], lng_gird, right=True) + g1 = np.where(g1 >= np.max(lng_gird), np.max(lng_gird) - 1, g1) + + g2 = np.digitize(sub[Spatio2], lat_gird, right=True) + g2 = np.where(g2 >= np.max(lat_gird), np.max(lat_gird) - 1, g2) + + sub.loc[:, f"{Spatio1}_grid"] = g1 + sub.loc[:, f"{Spatio2}_grid"] = g2 + sub = sub[(sub[f"{Spatio1}_grid"] <= lng_size - 1) & (sub[f"{Spatio2}_grid"] <= lat_size - 1)] sub = sub.groupby([f"{Spatio1}_grid", f"{Spatio2}_grid"])[[col]].mean().reset_index(drop=False) From 7b8fd277b8a4056f5bb9fec20bad76c97c95fff6 Mon Sep 17 00:00:00 2001 From: chenyangkang Date: Mon, 3 Jun 2024 16:06:53 +0800 Subject: [PATCH 2/3] gif gridding debug --- stemflow/utils/plot_gif.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stemflow/utils/plot_gif.py b/stemflow/utils/plot_gif.py index 09d6bfc..13a3d20 100644 --- a/stemflow/utils/plot_gif.py +++ b/stemflow/utils/plot_gif.py @@ -147,10 +147,10 @@ def animate(i, norm, log_scale=log_scale): temporal_value = np.array(sub[Temporal1].values)[0] g1 = np.digitize(sub[Spatio1], lng_gird, right=True) - g1 = np.where(g1 >= np.max(lng_gird), np.max(lng_gird) - 1, g1) + g1 = np.where(g1 >= np.max(lng_gird), np.max(lng_gird) - 1, g1).astype("int") g2 = np.digitize(sub[Spatio2], lat_gird, right=True) - g2 = np.where(g2 >= np.max(lat_gird), np.max(lat_gird) - 1, g2) + g2 = np.where(g2 >= np.max(lat_gird), np.max(lat_gird) - 1, g2).astype("int") sub.loc[:, f"{Spatio1}_grid"] = g1 sub.loc[:, f"{Spatio2}_grid"] = g2 From d18af0e0b2fd73a6a599000c1ab3eea1ed34becb Mon Sep 17 00:00:00 2001 From: chenyangkang Date: Mon, 3 Jun 2024 16:53:43 +0800 Subject: [PATCH 3/3] gif gridding debug --- stemflow/utils/plot_gif.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stemflow/utils/plot_gif.py b/stemflow/utils/plot_gif.py index 13a3d20..7652218 100644 --- a/stemflow/utils/plot_gif.py +++ b/stemflow/utils/plot_gif.py @@ -147,10 +147,10 @@ def animate(i, norm, log_scale=log_scale): temporal_value = np.array(sub[Temporal1].values)[0] g1 = np.digitize(sub[Spatio1], lng_gird, right=True) - g1 = np.where(g1 >= np.max(lng_gird), np.max(lng_gird) - 1, g1).astype("int") + g1 = np.where(g1 >= lng_size, lng_size - 1, g1).astype("int") g2 = np.digitize(sub[Spatio2], lat_gird, right=True) - g2 = np.where(g2 >= np.max(lat_gird), np.max(lat_gird) - 1, g2).astype("int") + g2 = np.where(g2 >= lng_size, lng_size - 1, g2).astype("int") sub.loc[:, f"{Spatio1}_grid"] = g1 sub.loc[:, f"{Spatio2}_grid"] = g2