Spaces:
Sleeping
Sleeping
add checkboxes for source
Browse files
app.py
CHANGED
|
@@ -17,7 +17,7 @@ def get_data():
|
|
| 17 |
ds1= xr.open_dataset("data/LENS_precomputed_terms_combined.nc")
|
| 18 |
gdf_regions = gpd.read_file('data/rainfall_regions.geojson',).set_index('index')
|
| 19 |
ds1 = ds1.assign_coords(region_id = gdf_regions.index.values)
|
| 20 |
-
ds1 = xr.concat([ds1,ds1.sum('source').assign_coords(source='all')], dim='source')
|
| 21 |
return ds1, gdf_regions
|
| 22 |
|
| 23 |
ds1, gdf_regions = get_data()
|
|
@@ -29,7 +29,7 @@ def get_plot(model='CESM2', season='DJF', term='bias', source='dyn', vmax=50):
|
|
| 29 |
ds1
|
| 30 |
.sel(model=model, season=season, term=term, source=source)
|
| 31 |
.sum("synoptic_bin") / 0.05 * 100
|
| 32 |
-
)
|
| 33 |
|
| 34 |
gdf = gdf_regions.copy()
|
| 35 |
gdf[term] = ds_sel.individual_term.to_series()
|
|
@@ -89,22 +89,29 @@ term_widget = pn.widgets.RadioButtonGroup(
|
|
| 89 |
name="Term",
|
| 90 |
options=['bias','trend'],
|
| 91 |
)
|
| 92 |
-
source_widget = pn.widgets.RadioButtonGroup(
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
name="Source",
|
| 95 |
options=list(ds1.source.values),
|
|
|
|
| 96 |
)
|
|
|
|
| 97 |
vmax_widget = pn.widgets.IntSlider(name="Colormap max value", value=50, start=1, end=150)
|
| 98 |
|
| 99 |
|
| 100 |
bound_plot = pn.bind(
|
| 101 |
-
get_plot, model=model_widget, season=season_widget, term=term_widget, source=
|
| 102 |
)
|
| 103 |
|
| 104 |
app = pn.template.MaterialTemplate(
|
| 105 |
site="Panel",
|
| 106 |
title="CMIP European rainfall decomposition - interactive",
|
| 107 |
-
sidebar=[term_widget,
|
| 108 |
main=[bound_plot],
|
| 109 |
)
|
| 110 |
|
|
|
|
| 17 |
ds1= xr.open_dataset("data/LENS_precomputed_terms_combined.nc")
|
| 18 |
gdf_regions = gpd.read_file('data/rainfall_regions.geojson',).set_index('index')
|
| 19 |
ds1 = ds1.assign_coords(region_id = gdf_regions.index.values)
|
| 20 |
+
# ds1 = xr.concat([ds1,ds1.sum('source').assign_coords(source='all')], dim='source')
|
| 21 |
return ds1, gdf_regions
|
| 22 |
|
| 23 |
ds1, gdf_regions = get_data()
|
|
|
|
| 29 |
ds1
|
| 30 |
.sel(model=model, season=season, term=term, source=source)
|
| 31 |
.sum("synoptic_bin") / 0.05 * 100
|
| 32 |
+
).sum('source')
|
| 33 |
|
| 34 |
gdf = gdf_regions.copy()
|
| 35 |
gdf[term] = ds_sel.individual_term.to_series()
|
|
|
|
| 89 |
name="Term",
|
| 90 |
options=['bias','trend'],
|
| 91 |
)
|
| 92 |
+
# source_widget = pn.widgets.RadioButtonGroup(
|
| 93 |
+
# description="Source selection",
|
| 94 |
+
# name="Source",
|
| 95 |
+
# options=list(ds1.source.values),
|
| 96 |
+
# )
|
| 97 |
+
source_checkboxes = pn.widgets.CheckBoxGroup(
|
| 98 |
+
inline=True,
|
| 99 |
name="Source",
|
| 100 |
options=list(ds1.source.values),
|
| 101 |
+
value=['therm']
|
| 102 |
)
|
| 103 |
+
|
| 104 |
vmax_widget = pn.widgets.IntSlider(name="Colormap max value", value=50, start=1, end=150)
|
| 105 |
|
| 106 |
|
| 107 |
bound_plot = pn.bind(
|
| 108 |
+
get_plot, model=model_widget, season=season_widget, term=term_widget, source=source_checkboxes, vmax=vmax_widget
|
| 109 |
)
|
| 110 |
|
| 111 |
app = pn.template.MaterialTemplate(
|
| 112 |
site="Panel",
|
| 113 |
title="CMIP European rainfall decomposition - interactive",
|
| 114 |
+
sidebar=[term_widget, source_checkboxes, season_widget,model_widget, vmax_widget],
|
| 115 |
main=[bound_plot],
|
| 116 |
)
|
| 117 |
|