sysloss.diagram#

Power tree diagrams.

Graphviz is used to render power tree diagrams in sysLoss. The diagrams can be customized with the full range of Graphviz attributes.

Functions#

get_conf(→ dict)

Get default Graphviz configuration.

make_diag(sys, *[, fname, group, config])

Create power tree diagram.

make_hdiag(sys, *[, fname, group, config])

Create power tree heat diagram.

Module Contents#

get_conf() dict#

Get default Graphviz configuration.

The Graphviz attributes used by sysLoss to format the diagram are returned in a dictionary. By modifying the attributes in the dictionary or adding new ones, the rendered diagram can be customized. The modified dict is passed as an argument to sysloss.diagram.make_diag().

Returns:

Default Graphviz configuration.

Return type:

dict

Examples

>>> my_conf = get_conf()
>>> my_conf["graph"]["rankdir"] = 'LR' # use left-right orientation
>>> make_diag(my_sys, config=my_conf)
make_diag(sys: sysloss.system.System, *, fname: str = None, group: bool = True, config: dict = {})#

Create power tree diagram.

The default diagram is rendered as a top-bottom diagram with components represented as light-grey, square boxes. Shapes and colors can be configured using an attribute dict.

Parameters:
  • fname (str, optional) – Filename for output image. File extension defines image format.

  • group (bool, optional) – Cluster components based on group names, by default True.

  • config (dict, optional) – Graphviz configuration.

Returns:

  • None – If filename is given.

  • PIL.Image – If no filename is given

Examples

>>> img = make_diag(my_sys)
>>> make_diag(my_sys, fname="system.svg") # write to file
>>> # add custom colors to components
>>> my_conf = get_conf()
>>> my_conf["node"]["Source"] = {"fillcolor":"coral"}
>>> my_conf["node"]["Converter"] = {"fillcolor":"darkturquoise"}
>>> my_conf["node"]["ILoad"] = {"fillcolor":"darkgoldenrod1"}
>>> my_conf["node"]["RLoss"] = {"fillcolor":"deeppink"}
>>> my_conf["node"]["LinReg"] = {"fillcolor":"darkorchid1"}
>>> my_conf["node"]["PSwitch"] = {"fillcolor":"aquamarine"}
>>> make_diag(my_sys, fname="system.svg", config=my_conf)
make_hdiag(sys: sysloss.system.System, *, fname: str = None, group: bool = True, config: dict = {})#

Create power tree heat diagram.

The system is first solved to find the losses in each component. If the system has load phases defined, the time-weighted loss is used in the diagram. The default diagram is rendered as a top-bottom diagram with components represented as gradient-colored, square boxes. Shapes and colors can be configured using an attribute dict, although component (node) colors will be overridden by gradient color.

Parameters:
  • fname (str, optional) – Filename for output image. File extension defines image format.

  • group (bool, optional) – Cluster components based on group names, by default True.

  • config (dict, optional) – Graphviz configuration.

Returns:

  • None – If filename is given.

  • PIL.Image – If no filename is given

Examples

>>> img = make_hdiag(my_sys)
>>> make_hdiag(my_sys, fname="system.svg") # write to file