Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix roundtrip PyPSA -> PSD -> PyPSA #689

Merged
merged 1 commit into from
Sep 29, 2022

Conversation

FabianHofmann
Copy link
Contributor

@FabianHofmann FabianHofmann commented Sep 29, 2022

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:

  • The distinction between Stores and StorageUnits is not yet completed
  • The carrier roundtrip conversion is not complete as it depends on internal static data on PSD side.

@@ -7,6 +7,16 @@
from powersimdata.utility.helpers import _check_import


def restore_original_columns(df, overwrite=[]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is minor: we might what to avoid immutable defaults for kwargs, i.e. overwrite=None with the logic in the function if not overwrite: overwrite = [].

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be taken care of after it is merged

Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Collaborator

@rouille rouille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants