The release 0.5.3 of oemof.network (GitHub, Zenodo, PyPI, RTD) brings some fixes (mostly concerning subnodes) and two quality of life improvements:
EnergySystem.from_file(filename)
Instead of creating an EnergySystem that is then overwritten based on the file contents, you can now get load a new energy system from a file.
# Deprecated way to load energy system dumps
es_old = EnergySystem()
es_old.restore(dpath="./", filename="es_dump.oemof")
# 0.5.3+ way to load energy system dumps
es_new = EnergySystem.from_file("./es_dump.oemof")
As a plus, you won’t get a warning anymore that your EnergySystem is overwritten. So you have cleaner code and a cleaner output.
EnergySystem.to_networkx()
For rendering, to create a networkx representation of the EnergySystem, the way to go was using the function nx_graph = to_nx_graph(energy_system). The preferred way is now to use nx_graph = , which also includes a better handling of subnodes. You can set energy_system.to_networkx()max_depth to hide subnodes, and we addressed the lacking support for nested structures in networkx (it only supports flat graphs). If you select add_implicit_edges=True, every subnode will “hand up” copies of its edges to their parent nodes. This way, edges do not vanish when you limit the depth of you graph and you will no longer have free floating container nodes.
Bugfixes
- Every
Nodecan only be member of oneEnergySystem. Internally, it holds a reference to it. However,node._energy_systemmight be unset or set incorrectly. This caused problems when adding subnodes (or if child classes wanted to access theEnergySystemfor other reasons). If you have been using subnodes in past versions, you might want to check if all of them were part of yourEnergySystem. - It was not clear that setting
Node.parentis no supported way of adding subnodes. You have to either usenode.add(subnode)ornode.subnode(Node(label="sn_label")). If you changed the parent manually, results might have been wrong (because of missingNodes).
