shyft.dashboard.time_series.axes_handler
Classes
|
This object represents the link between time axis handle and actual view time axis in the figures. |
|
This object represents the link between time axis handle and actual view time axis in bokeh figures. |
|
|
|
The TimeAxisHandler object calculates time axis for the current view. |
|
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: Logger | None = 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
- on_change_view_range(obj, callback) None [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(): >>> ..
- remove_on_change_view_range(obj) None [source]
This function removes an on change view range callback
- abstractmethod set_view_range(view_range: UtcPeriod, callback: bool = True, padding: bool = True) None [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)
- class shyft.dashboard.time_series.axes_handler.BokehViewTimeAxis(bokeh_document: bokeh.document.Document, init_view_range: UtcPeriod | None = None, zoom_in_interval: int | None = None, zoom_out_interval: int | None = None, x_range_padding: int = 0.05, time_zone: str | None = None, logger: logging.Logger | None = 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.
- Type:
Range1d bokeh visual slider to select what to view
- __init__(bokeh_document: bokeh.document.Document, init_view_range: UtcPeriod | None = None, zoom_in_interval: int | None = None, zoom_out_interval: int | None = None, x_range_padding: int = 0.05, time_zone: str | None = None, logger: logging.Logger | None = None) 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)
- x_range_callback(attrn: str, old: int, new: int) None [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
- x_range_data_updater() None [source]
This periodic callback is added to tornado event loop to trigger update of the hole TsViewer machinery
- set_view_range(view_range: UtcPeriod, callback: bool = True, padding: bool = True) None [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)
- class shyft.dashboard.time_series.axes_handler.TimePeriodSelectorTableViewTimeAxis(time_period_selector: shyft.dashboard.time_series.tools.figure_tools.TimePeriodSelector, logger: logging.Logger | None = None)[source]
Bases:
BaseViewTimeAxis
- __init__(time_period_selector: shyft.dashboard.time_series.tools.figure_tools.TimePeriodSelector, logger: logging.Logger | None = None)[source]
- Parameters:
logger (optional logger)
- set_view_range(view_range: UtcPeriod, callback: bool = True, padding: bool = True) None [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)
- class shyft.dashboard.time_series.axes_handler.TimeAxisHandler(*, auto_dt_multiple: int, view_time_axis: BaseViewTimeAxis, estimate_default_view: bool | None = True, time_step_restrictions: List[int | float] | ndarray | None = None, add_dt_selector: bool | None = True, title: str | None = None, width: int = 130, height: int | None = None, padding: int | None = None, sizing_mode: str | None = None, logger: Logger | None = None, tools: List[ViewTimeAxisTool] | None = None, full_view: bool | None = False, time_zone: str | None = 'Europe/Oslo', historical_mode: bool | None = 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.
- __init__(*, auto_dt_multiple: int, view_time_axis: BaseViewTimeAxis, estimate_default_view: bool | None = True, time_step_restrictions: List[int | float] | ndarray | None = None, add_dt_selector: bool | None = True, title: str | None = None, width: int = 130, height: int | None = None, padding: int | None = None, sizing_mode: str | None = None, logger: Logger | None = None, tools: List[ViewTimeAxisTool] | None = None, full_view: bool | None = False, time_zone: str | None = 'Europe/Oslo', historical_mode: bool | None = False) None [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)
----------
Notes
in _calculate_auto_dt() smallest dt is 1 hour … this should be changed to 1 s bound by auto_dt_multiple
- property auto_dt_figure_width: float
- set_default_view_period(min_max_range: UtcPeriod, reset_view: bool = True) None [source]
This function sets the time axis handler to a default view, the one with all data visible
- initialize(reset_view: bool = True) None [source]
This function resets the view to its initial range
- 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: UtcPeriod, callback=False, padding=True)[source]
This function sets the actual view period
- 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: int) int [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: ViewTimeAxisTool) None [source]
This function adds a ViewTimeAxisTool to the axes handler