rguilcas commited on
Commit
cf3c061
·
verified ·
1 Parent(s): 915357d

happy version

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -90,6 +90,11 @@ def get_cached_precursor_map(variable_name, season, region, vmax):
90
  xlim = (plot_bounds[0], plot_bounds[2])
91
  ylim = (plot_bounds[1], plot_bounds[3])
92
 
 
 
 
 
 
93
  plot = (filtered.hvplot.polygons(
94
  crs=ccrs.PlateCarree(),
95
  color='variable_level',
@@ -104,7 +109,7 @@ def get_cached_precursor_map(variable_name, season, region, vmax):
104
  # frame_height=300,
105
  responsive=True,
106
  aspect=0.75,
107
- tools=['hover'],
108
  title=variable_name
109
  ) * gf.coastline * gf.grid()).opts(
110
  axiswise=True
@@ -398,8 +403,8 @@ class CMIPApp(param.Parameterized):
398
  plot.state.y_range = self._shared_y_range
399
 
400
  # 1. Manually set the selection indices on the plot's data source if available
401
- if self._selection_index and 'source' in plot.handles:
402
- plot.handles['source'].selected.indices = self._selection_index
403
 
404
  # Style legend if this is a qualitative map (Type map)
405
  if plot.state.legend:
@@ -528,7 +533,7 @@ class CMIPApp(param.Parameterized):
528
 
529
  # Add labels
530
  labels = [
531
- hv.Text(0, 0, 'minimal bias', fontsize=8),
532
  hv.Text(90, 0, 'Conversion', fontsize=9),
533
  hv.Text(-90, 0, 'Conversion', fontsize=9),
534
  hv.Text(0, 90, 'Dynamical', fontsize=9, rotation=90),
@@ -640,8 +645,8 @@ class CMIPApp(param.Parameterized):
640
  return plot
641
 
642
  def hook_scatter_selection(self, plot, element):
643
- if self._selection_index and 'source' in plot.handles:
644
- plot.handles['source'].selected.indices = self._selection_index
645
 
646
  @param.depends('_selection_index', 'season', 'term')
647
  def get_bar_plot(self):
@@ -691,7 +696,7 @@ class CMIPApp(param.Parameterized):
691
  # Component (bias type) as primary dimension on y-axis, Region as grouping
692
  bar_plot = hv.Bars(melted, kdims=['Component', 'Region'], vdims='Value').opts(
693
  # frame_width=800,
694
- height=300,
695
  responsive=True,
696
  title=f"{self.term.capitalize()} Breakdown for Selected Regions ({self.season})",
697
  xlabel="Region",
 
90
  xlim = (plot_bounds[0], plot_bounds[2])
91
  ylim = (plot_bounds[1], plot_bounds[3])
92
 
93
+ unit = 'm²/s²' if variable_name == 'Z500' else 'm/s'
94
+ hover = HoverTool(tooltips=[
95
+ (f"{variable_name} anomaly", f"@variable_level{{0.0}} {unit}")
96
+ ])
97
+
98
  plot = (filtered.hvplot.polygons(
99
  crs=ccrs.PlateCarree(),
100
  color='variable_level',
 
109
  # frame_height=300,
110
  responsive=True,
111
  aspect=0.75,
112
+ tools=[hover],
113
  title=variable_name
114
  ) * gf.coastline * gf.grid()).opts(
115
  axiswise=True
 
403
  plot.state.y_range = self._shared_y_range
404
 
405
  # 1. Manually set the selection indices on the plot's data source if available
406
+ if 'source' in plot.handles:
407
+ plot.handles['source'].selected.indices = self._selection_index or []
408
 
409
  # Style legend if this is a qualitative map (Type map)
410
  if plot.state.legend:
 
533
 
534
  # Add labels
535
  labels = [
536
+ hv.Text(0, 0, f'minimal {self.term}', fontsize=8),
537
  hv.Text(90, 0, 'Conversion', fontsize=9),
538
  hv.Text(-90, 0, 'Conversion', fontsize=9),
539
  hv.Text(0, 90, 'Dynamical', fontsize=9, rotation=90),
 
645
  return plot
646
 
647
  def hook_scatter_selection(self, plot, element):
648
+ if 'source' in plot.handles:
649
+ plot.handles['source'].selected.indices = self._selection_index or []
650
 
651
  @param.depends('_selection_index', 'season', 'term')
652
  def get_bar_plot(self):
 
696
  # Component (bias type) as primary dimension on y-axis, Region as grouping
697
  bar_plot = hv.Bars(melted, kdims=['Component', 'Region'], vdims='Value').opts(
698
  # frame_width=800,
699
+ height=400,
700
  responsive=True,
701
  title=f"{self.term.capitalize()} Breakdown for Selected Regions ({self.season})",
702
  xlabel="Region",