Skip to content

Commit

Permalink
mask mann kendall
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Jun 22, 2023
1 parent d053c01 commit 660fee2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions notebooks/wp5/xch4_xco2_satellite_lev3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 660fee2

Please sign in to comment.