Breakthrough-Energy / PowerSimData

Simulation framework
https://breakthrough-energy.github.io/docs/
MIT License
52 stars 40 forks source link

Fix roundtrip PyPSA -> PSD -> PyPSA #689

Closed FabianHofmann closed 2 years ago

FabianHofmann commented 2 years ago

This fixes the conversion for the roundtrip PyPSA -> PSD -> PyPSA.

Test it with

from powersimdata.input.converter.pypsa_to_grid import FromPyPSA
from powersimdata.network.europe_tub.model import TUB
from powersimdata.input.exporter.export_to_pypsa import export_to_pypsa
from pandas.testing import assert_frame_equal

tub = TUB("Europe", reduction=1024)
tub.build()

g = FromPyPSA(tub.network)

n = export_to_pypsa(g)

for c in n.iterate_components():
    if c.name in ['Carrier']:
        continue
    orig = tub.df(c.name)
    conv = c.df

    assert_frame_equal(conv[orig.columns].head(), orig.head())

Missing points: