Notebook Utilities

The notebook module contains some utility functions that can be used to visualise pywr networks in a Juyter notebook

pywr.notebook.pywr_model_to_d3_json(model, attributes=False)

Convert a Pywr graph to a structure d3 can display

Parameters:
model : pywr.core.Model
attributes: bool (default=False)

If True, attribute data for each node is extract

pywr.notebook.pywr_json_to_d3_json(model, attributes=False)

Converts a JSON file or a JSON-derived dict into structure that d3js can use.

Parameters:
model : dict or str

str inputs should be a path to a json file containing the model.

pywr.notebook.draw_graph(model, width=500, height=400, labels=False, attributes=False, css=None)

Display a Pywr model using D3 in Jupyter

Parameters:
model : pywr.core.Model or json-dict that describes a model

The model to display

width : int

The width of the svg canvas to draw the graph on

height : int

The height of the svg canvas to draw the graph on

labels : bool

If True, each graph node is labelled with its name. If false, the node names are displayed during mouseover events

attributes : bool

If True, a table of node attributes is displayed during mouseover events

css : string

Stylesheet data to use instead of default