pywatershed.analysis.ModelGraph#
- class pywatershed.analysis.ModelGraph(model, show_params=False, process_colors=None, node_penwidth=2, edge_penwidth=1.5, edge_arrowsize=1.2, default_edge_color='black', from_file_edge_color=None, hide_variables=True)[source]#
Visualize a pywatershed Model as a directed graph.
Creates a GraphViz visualization showing processes, their inputs/variables, and the data flow between them. Uses the dot layout engine with left-to-right orientation.
- Parameters:
model (
Model) – The pywatershed Model to visualizeshow_params (
bool) – Whether to display parameters in process nodesprocess_colors (
dict[str,str] |None) – Dictionary mapping process names to colors for node bordersnode_penwidth (
int) – Width of node borders (default: 2)edge_penwidth (
float) – Width of edges/arrows (default: 1.5)edge_arrowsize (
float) – Size of arrowheads (default: 1.2)default_edge_color (
str) – Color for edges between processes (default: “black”)from_file_edge_color (
str|None) – Color for edges from file inputs (default: same as default_edge_color)hide_variables (
bool) – If True, hide individual variable names and only show process-to-process connections (default: True)
Example
>>> import pywatershed as pws >>> model = pws.Model(process_list, control=control, parameters=params) >>> mg = pws.analysis.ModelGraph(model, hide_variables=False) >>> mg.SVG()
- __init__(model, show_params=False, process_colors=None, node_penwidth=2, edge_penwidth=1.5, edge_arrowsize=1.2, default_edge_color='black', from_file_edge_color=None, hide_variables=True)[source]#
Methods
SVG([verbose, dpi, show_legend])Render and display the graph as SVG in a Jupyter notebook.
__init__(model[, show_params, ...])Build the GraphViz graph structure.
Display a complete legend for the ModelGraph visualization.
- SVG(verbose=False, dpi=45, show_legend=False)[source]#
Render and display the graph as SVG in a Jupyter notebook.
- build_graph()[source]#
Build the GraphViz graph structure.
Creates nodes for all processes and files, establishes connections between them, and sets up invisible ordering edges to enforce left-to-right layout according to model.process_order.
The graph uses the dot layout engine with: - Left-to-right orientation (rankdir=”LR”) - Invisible edges to control node ordering - constraint=false on data edges so they don’t affect layout
- Return type: