From 660fee270f506b99ef391abbb47f7f765fe13092 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Thu, 22 Jun 2023 15:57:30 +0200 Subject: [PATCH] mask mann kendall --- notebooks/wp5/xch4_xco2_satellite_lev3.ipynb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/notebooks/wp5/xch4_xco2_satellite_lev3.ipynb b/notebooks/wp5/xch4_xco2_satellite_lev3.ipynb index fb498f4..307ab41 100644 --- a/notebooks/wp5/xch4_xco2_satellite_lev3.ipynb +++ b/notebooks/wp5/xch4_xco2_satellite_lev3.ipynb @@ -96,6 +96,7 @@ "source": [ "transform_func_kwargs = {\"min_land_fraction\": min_land_fraction}\n", "\n", + "\n", "def get_da(ds, min_land_fraction):\n", " (varname,) = set(ds.data_vars) & {\"xch4\", \"xco2\"}\n", " da = ds[varname]\n", @@ -150,13 +151,13 @@ " return da_detrended.groupby(\"time.year\").map(diagnostics.seasonal_weighted_mean)\n", "\n", "\n", - "def compute_trends(ds, min_land_fraction):\n", + "def compute_anomaly_trends(ds, min_land_fraction):\n", " da_anomaly = compute_monthly_anomalies(ds, min_land_fraction)\n", "\n", " # Mann-Kendall\n", " ds_mann_kendall = compute_mann_kendall_trend(\n", " da_anomaly, alpha=0.05, method=\"theilslopes\"\n", - " )\n", + " ).where(da_anomaly.notnull().any(\"time\"))\n", " ds_mann_kendall[\"trend\"].attrs = {\n", " \"long_name\": f\"Trend of anomalies of {da_anomaly.attrs['long_name']}\",\n", " \"units\": f\"{da_anomaly.attrs['units']}/month\",\n", @@ -243,7 +244,9 @@ "outputs": [], "source": [ "ds_trend = download.download_and_transform(\n", - " *request, transform_func=compute_trends, transform_func_kwargs=transform_func_kwargs\n", + " *request,\n", + " transform_func=compute_anomaly_trends,\n", + " transform_func_kwargs=transform_func_kwargs,\n", ")\n", "\n", "plot.projected_map(ds_trend[\"trend\"], robust=True, projection=ccrs.Robinson())\n",