Skip to content

Commit

Permalink
Merge pull request #6 from danhooke/ploomber_v0
Browse files Browse the repository at this point in the history
Ploomber v0
  • Loading branch information
danhooke authored Mar 10, 2024
2 parents 0ccb3d1 + 1c992cc commit 871f9c9
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 248 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# CSE_dashboards
Exploratory dashboards for gridded data from https://www.climate-solutions-explorer.eu/ (Werning et al. 2023)[https://zenodo.org/record/8134869].
Exploratory dashboards for gridded data from Werning et al. (2023).

<a href="https://zenodo.org/doi/10.5281/zenodo.7971429" target="_blank"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.7971429.svg" alt="DOI"/></a>

Using *Panel, Xarray, hvPlot, Bokeh and Ploomber*.

View the 👉 [**deployment**](https://cold-voice-5221.ploomberapp.io/app) 👈 (using [Ploomber](https://ploomber.io/)).

<img src="./images/preview1.png" alt="preview of the dashboard" width="100%">
80 changes: 53 additions & 27 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,36 @@
precip_inds = ["cdd", "pr_r10", "pr_r20", "pr_r95p", "pr_r99p", "sdii"]

names = dict(
dri_dis="Drought severity (discharge)",
dri_qtot="Drought severity (runoff)",
iavar_dis="Interannual variability (discharge)",
iavar_qtot="Interannual variability (runoff)",
seas_dis="Seasonality (discharge)",
seas_qtot="Seasonality (runoff)",
wsi="Water stress index",
hw_97_3="Heat wave events", # (97th percentile, 3 days)
dri_dis="Drought severity", # (discharge)
# dri_qtot="Drought severity (runoff)",
# iavar_dis="Interannual variability (discharge)",
# iavar_qtot="Interannual variability (runoff)",
# seas_dis="Seasonality (discharge)",
# seas_qtot="Seasonality (runoff)",
wsi="Water Stress Index",
cdd="Consecutive dry days",
pr_r10="Heavy precipitation days",
pr_r20="Very heavy precipitation days",
pr_r95p="Wet days",
pr_r99p="Very wet days",
sdii="Precipitation intensity index",
hw_95_10="Heat wave events (95th percentile, 10 days)",
hw_95_3="Heat wave events (95th percentile, 3 days)",
hw_95_5="Heat wave events (95th percentile, 5 days)",
hw_95_7="Heat wave events (95th percentile, 7 days)",
hw_97_10="Heat wave events (97th percentile, 10 days)",
hw_97_3="Heat wave events (97th percentile, 3 days)",
hw_97_5="Heat wave events (97th percentile, 5 days)",
hw_97_7="Heat wave events (97th percentile, 7 days)",
hw_99_10="Heat wave events (99th percentile, 10 days)",
hw_99_3="Heat wave events (99th percentile, 3 days)",
hw_99_5="Heat wave events (99th percentile, 5 days)",
hw_99_7="Heat wave events (99th percentile, 7 days)",
# pr_r20="Very heavy precipitation days",
# pr_r95p="Wet days",
# pr_r99p="Very wet days",
# sdii="Precipitation intensity index",
# hw_95_10="Heat wave events (95th percentile, 10 days)",
# hw_95_3="Heat wave events (95th percentile, 3 days)",
# hw_95_5="Heat wave events (95th percentile, 5 days)",
# hw_95_7="Heat wave events (95th percentile, 7 days)",
# hw_97_10="Heat wave events (97th percentile, 10 days)",
# hw_97_5="Heat wave events (97th percentile, 5 days)",
# hw_97_7="Heat wave events (97th percentile, 7 days)",
# hw_99_10="Heat wave events (99th percentile, 10 days)",
# hw_99_3="Heat wave events (99th percentile, 3 days)",
# hw_99_5="Heat wave events (99th percentile, 5 days)",
# hw_99_7="Heat wave events (99th percentile, 7 days)",
tr20="Tropical nights",
sdd_c_24p0="Cooling degree days (24°C)",
sdd_c_24p0="Cooling degree days", # (24°C)
# sdd_c="Cooling degree days (26°C)",
sdd_c_18p3="Cooling degree days (18.3°C)",
sdd_c_20p0="Cooling degree days (20°C)",
# sdd_c_18p3="Cooling degree days (18.3°C)",
# sdd_c_20p0="Cooling degree days (20°C)",
)


Expand Down Expand Up @@ -145,6 +145,32 @@ def make_ds(
return ds


def make_ds_local(l_name):
ind = match_name(l_name)
vars = ["abs", "diff", "score"]
fp = "data/"
ds = xr.merge(
[
xr.concat(
[
xr.open_dataarray(f).rename(f"{var}")
for f in glob.glob(fp + rf"\*{ind}*{var}*")
],
dim="threshold",
)
for var in vars
]
)
ds = ds.rename({"diff": "difference", "lon": "Longitude", "lat": "Latitude"})
return ds


def make_ds_combined(l_name):
ind = match_name(l_name)
ds = xr.open_dataset(f"data/{ind}_combined.nc4")
return ds


info = dfs.get_info()


Expand Down Expand Up @@ -182,7 +208,7 @@ def get_ind_text(ind):


def make_score_map_test(ind, t):
ds = make_ds(ind)
ds = make_ds_combined(ind)
ind_info = get_plot_info(ind)
score_map = (
ds["score"]
Expand Down
Binary file added data/cdd_combined.nc4
Binary file not shown.
Binary file added data/dri_dis_combined.nc4
Binary file not shown.
Binary file added data/hw_97_3_combined.nc4
Binary file not shown.
Binary file added data/pr_r10_combined.nc4
Binary file not shown.
Binary file added data/sdd_c_24p0_combined.nc4
Binary file not shown.
Binary file added data/tr20_combined.nc4
Binary file not shown.
Binary file added data/wsi_combined.nc4
Binary file not shown.
147 changes: 0 additions & 147 deletions demo_notebook.ipynb

This file was deleted.

Binary file added images/preview1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions indicator_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ indicators:
diff_max: 140
diff_cmap: 'Reds'
score_range: [7676, 1638, 561, 0]
description: 'Maximum number of consecutive days per year with a minimum surface air temperature above 20 °C.'
description: 'Maximum number of consecutive days per year with a minimum surface air temperature above 20C.'
# yields_cereals:
# SimU_yields:
# short_name: 'yld_crls'
Expand Down Expand Up @@ -365,6 +365,6 @@ indicators:
diff: relative
diff_min: -1910
diff_max: 1910
diff_cmap: 'PuRd'
diff_cmap: 'coolwarm'
score_range: [0.4, 0.3, 0.2, 0.1]
description: 'Water stress index compares water demands to available water supply. High water stress means that a high proportion of the available water is being used.'
71 changes: 0 additions & 71 deletions test/cdd_dashboard.html

This file was deleted.

0 comments on commit 871f9c9

Please sign in to comment.