HoloviewsDashboardL1#

class dtcg.interface.plotting.HoloviewsDashboardL1[source]#

Bases: HoloviewsDashboard

Holoviews dashboard for runoff data.

plot_map#
Type:

BokehMap

plot_graph#
Type:

BokehGraph

title#
Type:

str

figures#
Type:

list

dashboard#
Type:

hv.Layout

Methods

__init__()

check_holoviews()

Check holoviews is installed to prevent silent failures.

decode_datacube(datacube)

Get a dataset decoded into CF conventions.

get_all_palettes()

Get all valid preset colour palettes.

get_color_palette(name)

Get a preset palette.

get_default_opts()

Default options for Bokeh figures.

get_help_button(text[, position, add_colors])

Get an interactive help button from a list of fields.

get_hover_tool([mode, tooltips, attachment])

Get the hover tool attribute.

get_title(title[, suffix, timestamp, location])

Get a title including optional parameters.

get_tooltip_format([tooltips])

Get a tooltip formatter from the tooltips attribute.

initialise_formatting(figure)

Initialise default formatting for Bokeh figures.

set_dashboard(figures)

Set dashboard from a sequence of figures.

set_dashboard_title([name, subregion_name])

set_defaults(updated_options)

Set and overwrite default options for Bokeh figures.

set_formatting_kwargs(figure, **kwargs)

Set kwargs for generic formatting.

set_hover_tool([mode])

Set the hover tool attribute.

set_layout(figures)

Compose Layout from a sequence of overlays or layouts.

set_overlay_options(overlay, xlabel, ylabel, ...)

Set plot options for Holoviews overlays.

set_tooltips(tooltips[, mode])

Set the tooltips attribute and update the hover tool.

to_layout(overlay[, cols, sizing_mode, ...])

Convert overlay to layout.

__init__()[source]#
check_holoviews()#

Check holoviews is installed to prevent silent failures.

Raises:

ImportError – If Holoviews is not installed.

Return type:

None

decode_datacube(datacube)#

Get a dataset decoded into CF conventions.

This should be called after data processing to avoid changing the datacube’s metadata.

Parameters:

datacube (GeoZarrHandler or xr.Dataset) – CryoTEMPO-EOLIS observations for elevation change.

Returns:

Dataset decoded into CF conventions.

Return type:

xr.Dataset

get_all_palettes()#

Get all valid preset colour palettes.

These are custom presets and do not include those accessible via Bokeh or Holoviews.

These are:

  • brown_blue_pastel

  • brown_blue_vivid

  • hillshade_glacier

  • lines_jet_r

Returns:

Preset colour palettes.

Return type:

dict[tuple[str]]

get_color_palette(name)#

Get a preset palette.

Parameters:

name (str) – Name of palette.

Returns:

Palette of hex colours.

Return type:

list[str]

Raises:

KeyError – If no matching palette is found.

get_default_opts()#

Default options for Bokeh figures.

Returns:

Default options for Bokeh figures. Not necessarily compatible with Holoviews or Geoviews objects.

Return type:

dict

get_help_button(
text,
position='right',
add_colors=None,
)#

Get an interactive help button from a list of fields.

Parameters:
  • text (list[str]) – Help text.

  • position (str, default "right") – Help button position.

  • add_colors (hv.Cycle or None, default None) – Add coloured boxes next to text. Used for legend entries.

Returns:

An interactive help button that displays text on hover and click.

Return type:

bokeh.models.HelpButton

get_hover_tool(
mode='vline',
tooltips=None,
attachment='horizontal',
)#

Get the hover tool attribute.

Parameters:
  • mode (str, default "vline") – Hover mode for hover tool, e.g. “mouse”, “hline”, “vline”.

  • tooltips (list[tuple[str,str]], optional) – Hover tooltips.

  • attachment (str, default "horizontal") – Position of hover tooltip relative to cursor. Can be “horizontal”, “vertical”, “above”, or “below”.

Returns:

Hover tool with tooltips and formatter.

Return type:

bokeh.models.HoverTool

get_title(
title,
suffix='',
timestamp='',
location='',
)#

Get a title including optional parameters.

Parameters:
  • title (str) – Title of figure.

  • suffix (str) – Comment appended to returned title. Default empty string.

  • timestamp (str or datetime.datetime, optional) – Timestamp. Default empty string.

  • location (str) – Location. Default empty string.

Returns:

A title optionally including location, timestamp, and a suffix.

Return type:

str

get_tooltip_format(tooltips=None)#

Get a tooltip formatter from the tooltips attribute.

This ensures all tooltips with a format string (in curly braces) are formatted as fstrings. Skips tooltips without a format string.

Parameters:

tooltips (list[tuple[str,str]], optional.) – List of Bokeh figure tooltips.

Returns:

Tooltip field names with an associated “printf” or “datetime” value.

Return type:

dict

initialise_formatting(figure)#

Initialise default formatting for Bokeh figures.

Called separately from other plotting functions in this module to avoid overwriting on-the-fly formatting changes.

Parameters:

figure (bokeh.plotting.figure) – An unformatted Bokeh plot.

Returns:

Figure with default options applied.

Return type:

bokeh.plotting.figure

set_dashboard(figures)[source]#

Set dashboard from a sequence of figures.

Parameters:

figures (list[hv.Overlay|hv.Layout]) – A sequence of figures.

set_defaults(updated_options)#

Set and overwrite default options for Bokeh figures.

Parameters:

updated_options (dict) – New key/value pairs which will overwrite the default options.

Return type:

None

set_formatting_kwargs(figure, **kwargs)#

Set kwargs for generic formatting.

Applies annotations, titles, labels.

Parameters:
  • figure (bokeh.plotting.figure) – An unformatted Bokeh plot.

  • kwargs – Additional arguments passed to Bokeh figures.

Returns:

Figure with default options applied.

Return type:

bokeh.plotting.figure

set_hover_tool(mode='vline')#

Set the hover tool attribute.

Parameters:

mode (str, default "vline") – Hover mode for hover tool, e.g. “mouse”, “hline”, “vline”.

set_layout(figures)[source]#

Compose Layout from a sequence of overlays or layouts.

Dynamically adds a sequence of overlays to a layout.

Parameters:

figures (list[hv.Overlay|hv.Layout]) – A sequence of figures.

Return type:

Layout

set_overlay_options(
overlay,
xlabel,
ylabel,
title,
aspect=2,
legend_position='top_left',
**kwargs,
)#

Set plot options for Holoviews overlays.

Parameters:
  • overlay (hv.Overlay) – Holoviews plot.

  • xlabel (str) – X-axis label.

  • ylabel (str) – Y-axis label.

  • title (str) – Plot title.

  • aspect (int, default 2) – Aspect ratio. Currently disabled due to several Holoviews bugs.

  • legend_position (str, default "top_left") – Location of legend box.

  • kwargs – Additional parameters passed to hv.Overlay objects.

Returns:

Holoviews plot with updated options.

Return type:

hv.Overlay

set_tooltips(tooltips, mode='vline')#

Set the tooltips attribute and update the hover tool.

Parameters:
  • tooltips (list[tuple[str,str]]) – List of Bokeh figure tooltips. The tooltips should only contain printf formatters.

  • mode (str, default "vline") – Hover mode for hover tool, e.g. “mouse”, “hline”, “vline”.

Return type:

None

to_layout(
overlay,
cols=1,
sizing_mode='stretch_width',
shared_axes=False,
**kwargs,
)#

Convert overlay to layout.

Parameters:
  • overlay (list or hv.Overlay) – Either an Overlay object or a list of overlays.

  • cols (int, default 1) – Force the number of allowed columns in the layout.

  • sizing_mode (str, default "stretch_width".) – Layout responsiveness to screen dimensions.

  • shared_axes (bool, default False) – Whether the overlays should share data axes.

  • **kwargs – Extra arguments passed to hv.Layout options.

Return type:

Layout