rguilcas commited on
Commit
3dae574
·
1 Parent(s): af120d9

add precursor plot

Browse files
Files changed (1) hide show
  1. app.py +37 -3
app.py CHANGED
@@ -8,7 +8,7 @@ import cartopy.crs as ccrs
8
  from bokeh.models import HoverTool
9
  import holoviews as hv
10
  from holoviews import streams
11
-
12
  pn.extension(design="material", sizing_mode="stretch_width")
13
 
14
 
@@ -24,7 +24,35 @@ def get_data():
24
  ds1, gdf_regions = get_data()
25
 
26
 
27
- def get_plot(model='CESM2', season='DJF', term='bias', source='dyn', vmax=50):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  """Plots the rolling average and the outliers"""
29
  ds_sel = (
30
  ds1
@@ -68,8 +96,14 @@ def get_plot(model='CESM2', season='DJF', term='bias', source='dyn', vmax=50):
68
  # series.index = series.index.reorder_levels([1,0])
69
 
70
  bars = series.hvplot.barh(title=term)
71
- return bars.opts(height=500,
 
 
 
 
72
  width=200)*hv.HLine(0).opts(color='k')#f"### You clicked on: \n{region_names}"
 
 
73
 
74
 
75
  layout = pn.Row(poly_plot, update_secondary_plot)
 
8
  from bokeh.models import HoverTool
9
  import holoviews as hv
10
  from holoviews import streams
11
+ import geoviews.feature as gf
12
  pn.extension(design="material", sizing_mode="stretch_width")
13
 
14
 
 
24
  ds1, gdf_regions = get_data()
25
 
26
 
27
+ def plot_precursor_map_gdf(variable='z500', season='SON',region='Egypt + East Libya', vmax = 1000):
28
+ return gdf_precursors.query("variable==@variable & season==@season & region ==@region").hvplot.polygons( crs=ccrs.PlateCarree(), color='variable_level')\
29
+ .opts(
30
+ # height=300,
31
+ frame_width=500,
32
+ # tools=['hover'],
33
+ tools=['hover'], # Ensure tap is here
34
+ cmap = 'RdBu',
35
+ color='variable_level',
36
+ colorbar=False,
37
+ clim=(-vmax, vmax),
38
+ projection=ccrs.Orthographic(0,40),
39
+ axiswise=False,
40
+ shared_axes=True,
41
+ )*gf.coastline
42
+
43
+
44
+ def get_precursor_plot(season='SON',region='Egypt + East Libya'):
45
+ return (plot_precursor_map_gdf(variable='u850', vmax = 5, region=region, season=season).opts(title='U850')
46
+ # +
47
+ # plot_precursor_map_gdf(variable='v850', vmax = 5, region=region, season=season).opts(title='V850')+
48
+ # plot_precursor_map_gdf(variable='z500', region=region, season=season).opts(title='Z500')
49
+ )#.cols(1)
50
+
51
+ get_precursor_plot(season='DJF')
52
+
53
+
54
+
55
+ def get_plot(model='CESM2', season='DJF', term='bias', source=['dyn'], vmax=50):
56
  """Plots the rolling average and the outliers"""
57
  ds_sel = (
58
  ds1
 
96
  # series.index = series.index.reorder_levels([1,0])
97
 
98
  bars = series.hvplot.barh(title=term)
99
+ precursor = get_precursor_plot(season=season, region=regions[0])
100
+ if len(regions>1):
101
+ for k in range(1,len(regions)):
102
+ precursor += get_precursor_plot(season=season, region=regions[k])
103
+ bars_out = bars.opts(height=500,
104
  width=200)*hv.HLine(0).opts(color='k')#f"### You clicked on: \n{region_names}"
105
+ final_plot = (bars_out+precursor).col(1)
106
+ return final_plot
107
 
108
 
109
  layout = pn.Row(poly_plot, update_secondary_plot)