shyft.dashboard.time_series.axes_handler

Classes

BaseViewTimeAxis([logger])

This object represents the link between time axis handle and actual view time axis in the figures.

BokehViewTimeAxis(bokeh_document[, ...])

This object represents the link between time axis handle and actual view time axis in bokeh figures.

DsViewTimeAxisType(*values)

TimeAxisHandler(*, auto_dt_multiple, ...[, ...])

The TimeAxisHandler object calculates time axis for the current view.

TimePeriodSelectorTableViewTimeAxis(...[, ...])

Exceptions

exception shyft.dashboard.time_series.axes_handler.TimeAxisHandlerError[source]

Bases: RuntimeError

class shyft.dashboard.time_series.axes_handler.DsViewTimeAxisType(*values)[source]

Bases: Enum

padded_view_time_axis = 0
view_time_axis = 1
class shyft.dashboard.time_series.axes_handler.BaseViewTimeAxis(logger=None)[source]

Bases: Bindable

This object represents the link between time axis handle and actual view time axis in the figures.

Implemented as a Base object but now only one figure type from bokeh is used ..

receive_view_period
Type:

Port to receive UtcPeriod to set view to

trigger_update: triggers the update method of parent, a TimeAxisHandle should be used to

trigger update machinery of the time axis and all views, i.e. when the figure range changed

Abstract methods/properties
----------------
set_view_period: function to set the view of the figures and the time axis
view_range: a property to get the current view range as a shyft.time_series.UtcPeriod
Parameters:

logger (optional logger)

__init__(logger=None)[source]
Parameters:

logger (optional logger)

receive_view_period: Receiver
state_port: StatePorts
trigger_update()[source]

This function triggers the update method of the parent calls

on_change_view_range(obj, callback)[source]

This function can be used to add on change view range callbacks, which informs the obj that the view range was changed

Callback should have the form:

>>>    def callback():
>>>        ..
Return type:

None

remove_on_change_view_range(obj)[source]

This function removes an on change view range callback

Return type:

None

abstractmethod set_view_range(view_range, callback=True, padding=True)[source]

This function sets the view period of the view time axis and thus of all adjoint figures

Parameters:
  • view_range (UtcPeriod of start and end of view range)

  • callback (trigger update callback or not)

  • padding (add padding to the view range or not)

Return type:

None

abstract property view_range: UtcPeriod

This property returns current view as a shyft.time_series.UtcPeriod :return:

class shyft.dashboard.time_series.axes_handler.BokehViewTimeAxis(bokeh_document, init_view_range=None, zoom_in_interval=None, zoom_out_interval=None, x_range_padding=0.05, time_zone=None, logger=None)[source]

Bases: BaseViewTimeAxis

This object represents the link between time axis handle and actual view time axis in bokeh figures.

It has a periodic callback to check the figure view and triggers the update of data whenever the time axis is changed.

Notes

Times-resolution is seconds. Input with ms resolution is rounded.

shared_x_range
Type:

Range1d bokeh visual slider to select what to view

Parameters:
  • bokeh_document (the bokeh document where the ts viewer resides)

  • init_view_range (initial view range)

  • zoom_in_interval (range in UTC s of the minimal range (end-start) when zooming into a figure)

  • zoom_out_interval (range in UTC s of the maximal range (end-start) when zooming out of a figure)

  • x_range_padding (view padding added (extra_pad = (end - start)*x_range_padding) added to the range i.e. %)

  • time_zone (the time zone for applying a UTC offset in the view)

  • logger (logger)

__init__(bokeh_document, init_view_range=None, zoom_in_interval=None, zoom_out_interval=None, x_range_padding=0.05, time_zone=None, logger=None)[source]
Parameters:
  • bokeh_document (the bokeh document where the ts viewer resides)

  • init_view_range (initial view range)

  • zoom_in_interval (range in UTC s of the minimal range (end-start) when zooming into a figure)

  • zoom_out_interval (range in UTC s of the maximal range (end-start) when zooming out of a figure)

  • x_range_padding (view padding added (extra_pad = (end - start)*x_range_padding) added to the range i.e. %)

  • time_zone (the time zone for applying a UTC offset in the view)

  • logger (logger)

Return type:

None

sec_to_milli: float
utc_offset: time
shared_x_range: Range1d
x_rang_pad: float
set_x_range_start: Callable[[Any], None]
set_x_range_end: Callable[[Any], None]
x_range_callback(attrn, old, new)[source]

This callback triggers a reload on bokeh figure x-range changes. Note that it only set the ._current_view_range that is picked up by the timer-driven x_range_data_updater every 100ms

Parameters:
  • attrn (str)

  • old (int)

  • new (int)

Return type:

None

x_range_data_updater()[source]

This periodic callback is added to tornado event loop to trigger update of the hole TsViewer machinery

Return type:

None

set_view_range(view_range, callback=True, padding=True)[source]

This function sets the view period of the view time axis and thus of all adjoint figures

Parameters:
  • start (start view time point in UTC s)

  • end (end view time point in UTC s)

  • callback (trigger update callback or not)

  • padding (add padding to the view range or not)

  • view_range (UtcPeriod)

Return type:

None

property view_range: UtcPeriod

This property returns current view range as shyft.time_series.UtcPeriod

class shyft.dashboard.time_series.axes_handler.TimePeriodSelectorTableViewTimeAxis(time_period_selector, logger=None)[source]

Bases: BaseViewTimeAxis

Parameters:
  • logger (optional logger)

  • time_period_selector (shyft.dashboard.time_series.tools.figure_tools.TimePeriodSelector)

__init__(time_period_selector, logger=None)[source]
Parameters:
  • logger (optional logger)

  • time_period_selector (shyft.dashboard.time_series.tools.figure_tools.TimePeriodSelector)

set_view_range(view_range, callback=True, padding=True)[source]

This function sets the view period of the view time axis and thus of all adjoint figures

Parameters:
  • view_range (UtcPeriod of start and end of view range)

  • callback (trigger update callback or not)

  • padding (add padding to the view range or not)

Return type:

None

property view_range: UtcPeriod

This property returns current view as a shyft.time_series.UtcPeriod :return:

class shyft.dashboard.time_series.axes_handler.TimeAxisHandler(*, auto_dt_multiple, view_time_axis, estimate_default_view=True, time_step_restrictions=None, add_dt_selector=True, title=None, width=130, height=None, padding=None, sizing_mode=None, logger=None, tools=None, full_view=False, time_zone='Europe/Oslo', historical_mode=False)[source]

Bases: Bindable

The TimeAxisHandler object calculates time axis for the current view. The time axis handler uses seconds s since epoch in utc.

It provides two methods to request the current time axes:
  • current view time axis (shyft.time_series.TimeAxis)

  • current data padded time axis (shyft.time_series.TimeAxis), time axis with extra padding to the left and right

DataSources will use these methods to get the current time axis when they update the data.

The minimal dt which is reasonable to view on the figures based on the plot_width is applied.

Time step restrictions can be provided to ensure only certain time steps are chosen (round up/down)

A dt selector can be connected to the TimeAxisHandler to take user defined dt input.

Parameters:
  • auto_dt_multiple (sets the lowest resolution of the time series)

  • view_time_axis (The bokeh view time axis it should be connected to)

  • estimate_default_view (switch to allow for changing the default view range)

  • time_step_restrictions (which time steps should be available)

  • add_dt_selector (switch to add a time step selector tool)

  • title (title often passed from TsViewer and is passed to the time step selector tool)

  • logger (python logger)

  • tools (list of tools to be added)

  • full_view (switch to create time axis for the whole data set and not the cropped)

  • time_zone (not in use)

  • historical_mode (if set true, fiddle clip time-axis rhs to utctime_now)

  • ----------

  • width (int)

  • height (int | None)

  • padding (int | None)

  • sizing_mode (str | None)

Notes

in _calculate_auto_dt() smallest dt is 1 hour … this should be changed to 1 s bound by auto_dt_multiple

__init__(*, auto_dt_multiple, view_time_axis, estimate_default_view=True, time_step_restrictions=None, add_dt_selector=True, title=None, width=130, height=None, padding=None, sizing_mode=None, logger=None, tools=None, full_view=False, time_zone='Europe/Oslo', historical_mode=False)[source]
Parameters:
  • auto_dt_multiple (sets the lowest resolution of the time series)

  • view_time_axis (The bokeh view time axis it should be connected to)

  • estimate_default_view (switch to allow for changing the default view range)

  • time_step_restrictions (which time steps should be available)

  • add_dt_selector (switch to add a time step selector tool)

  • title (title often passed from TsViewer and is passed to the time step selector tool)

  • logger (python logger)

  • tools (list of tools to be added)

  • full_view (switch to create time axis for the whole data set and not the cropped)

  • time_zone (not in use)

  • historical_mode (if set true, fiddle clip time-axis rhs to utctime_now)

  • ----------

  • width (int)

  • height (int | None)

  • padding (int | None)

  • sizing_mode (str | None)

Return type:

None

Notes

in _calculate_auto_dt() smallest dt is 1 hour … this should be changed to 1 s bound by auto_dt_multiple

estimate_default_view: bool
default_view_range: UtcPeriod
full_view: bool
view_time_axis: BaseViewTimeAxis
cal: Calendar
view_range: UtcPeriod
zoom_threshold_factor: float
pan_threshold_factor: float
padded_view_range: UtcPeriod
snap_time_to: time
dt_restriction: list
dt_options: List[time]
historical_view_range: UtcPeriod
historical_mode: bool
default_auto_dt_width: int
auto_dt_multiple: time
user_selected_dt: time
send_dt_options: Sender
receive_dt: Receiver
state_port: StatePorts
dt_selector: DeltaTSelectorTool
tools: List[DeltaTSelectorTool]
property auto_dt_figure_width: float
set_default_view_period(min_max_range, reset_view=True)[source]

This function sets the time axis handler to a default view, the one with all data visible

Parameters:
  • min_max_range (UtcPeriod)

  • reset_view (bool)

Return type:

None

initialize(reset_view=True)[source]

This function resets the view to its initial range

Parameters:

reset_view (bool)

Return type:

None

reset_view()[source]

This function resets the time axis handler

set_figure_width(figure_width)[source]

TODO: .figure_width is NOT used inside this class, check if there is any other use of it(and move/remove it)

set_view_range(view_range, callback=False, padding=True)[source]

This function sets the actual view period

Parameters:

view_range (UtcPeriod)

trigger_time_axis_update()[source]

This function triggers the update process: - updating the view time axis and padded view time axis - trigger data update of the TsViewer parent

evaluate_view_range()[source]

This function evaluates the current view range and calculates new data padding.

calculate_restriction(dt)[source]

This function evaluates the dt from the dt_restrictions

Parameters:

dt (time step)

Return type:

returns the lowest time step from the time step restrictions list or the inputted time step

property view_time_axis_properties: ViewTimeAxisProperties

parameters that describe the current view-port time-axis

Type:

return

add_tool(tool)[source]

This function adds a ViewTimeAxisTool to the axes handler

Parameters:

tool (ViewTimeAxisTool)

Return type:

None