Skip to content

Commit

Permalink
feat(sensitivity): divide_by_estimate colormap range
Browse files Browse the repository at this point in the history
- move divide_by_estimate changes to it's own callback
- set seperate colormap range for sensitivity ringmap
- keep track of both colormap ranges

closes #103
  • Loading branch information
nritsche committed Dec 5, 2020
1 parent 1c9c679 commit 118dfd2
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion bondia/plot/sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SensitivityPlot(RaHeatMapPlot, Reader):
ylim = (400, 800)
xlim = (0, 360)
zlim = (0.01, 0.1)
zlim_estimate = (0.88, 0.9)

# parameters
# Hide lsd, revision selectors by setting precedence < 0
Expand All @@ -56,6 +57,27 @@ def __init__(self, data, config, **params):
self.read_config(config)
self.logarithmic_colorscale = True

# Register callback for switching colormap range between normalized using estimate and normal
self.param.watch(self._changed_estimate, "divide_by_estimate", onlychanged=True)

def _changed_estimate(self, *events):
"""When the divide_by_estimate option is changed, we keep track of what the colormap range was."""
for event in events:
if event.old:
# divide_by_estimate was deactivated
self.zlim_estimate = self.colormap_range
# Make sure view is triggered also if the colormap stays the same
if self.zlim == self.colormap_range:
self.param.trigger("colormap_range")
self.colormap_range = self.zlim
else:
# dicide_by_estimate was activated
self.zlim = self.colormap_range
# Make sure view is triggered also if the colormap stays the same
if self.zlim_estimate == self.colormap_range:
self.param.trigger("colormap_range")
self.colormap_range = self.zlim_estimate

@param.depends("lsd", watch=True)
def update_pol(self):
if self.lsd is None:
Expand Down Expand Up @@ -84,7 +106,6 @@ def update_pol(self):
"flag_mask",
"flags",
"height",
"divide_by_estimate",
)
def view(self):
if self.lsd is None:
Expand Down

0 comments on commit 118dfd2

Please sign in to comment.