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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single-zone Grids can't be loaded from matfiles #597

Open
1 task done
danielolsen opened this issue Mar 10, 2022 · 0 comments
Open
1 task done

Single-zone Grids can't be loaded from matfiles #597

danielolsen opened this issue Mar 10, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@danielolsen
Copy link
Contributor

danielolsen commented Mar 10, 2022

馃

  • I have checked that this issue has not already been reported.

Bug summary

Trying to load a Grid from a matfile with a single zone causes a dimensional mismatch error.

Code for reproduction

A minimum code snippet required to reproduce the bug. Please make sure to minimize the
number of dependencies required.

>>> from powersimdata import Grid
>>> grid = Grid(source=PATH_TO_MATFILE, interconnect="ERCOT")
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading sub
Loading bus2sub
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python39\lib\site-packages\powersimdata\input\grid.py", line 57, in __init__
    data = FromREISE(source)
  File "C:\Python39\lib\site-packages\powersimdata\input\scenario_grid.py", line 25, in __init__
    super().__init__()
  File "C:\Python39\lib\site-packages\powersimdata\input\abstract_grid.py", line 34, in __init__
    self._build_network()
  File "C:\Python39\lib\site-packages\powersimdata\input\scenario_grid.py", line 132, in _build_network
    self._read_network()
  File "C:\Python39\lib\site-packages\powersimdata\input\scenario_grid.py", line 102, in _read_network
    zone = pd.DataFrame(mpc.zone, columns=["zone_id", "zone_name"])
  File "C:\Python39\lib\site-packages\pandas\core\frame.py", line 672, in __init__
    mgr = ndarray_to_mgr(
  File "C:\Python39\lib\site-packages\pandas\core\internals\construction.py", line 324, in ndarray_to_mgr
    _check_values_indices_shape_match(values, index, columns)
  File "C:\Python39\lib\site-packages\pandas\core\internals\construction.py", line 393, in _check_values_indices_shape_match
    raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
ValueError: Shape of passed values is (2, 1), indices imply (2, 2)

If we look at the matfile itself:

>>> from scipy.io import loadmat
>>> mpc = loadmat(PATH_TO_MATFILE, squeeze_me=True, struct_as_record=False)
>>> mpc["mdi"].mpc.zone
array([47, 'ERCOT'], dtype=object)

We can reproduce the same error with pandas and dummy data:

>>> import pandas as pd
>>> pd.DataFrame([1, 2], columns=[3, 4])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python39\lib\site-packages\pandas\core\frame.py", line 711, in __init__
    mgr = ndarray_to_mgr(
  File "C:\Python39\lib\site-packages\pandas\core\internals\construction.py", line 324, in ndarray_to_mgr
    _check_values_indices_shape_match(values, index, columns)
  File "C:\Python39\lib\site-packages\pandas\core\internals\construction.py", line 393, in _check_values_indices_shape_match
    raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
ValueError: Shape of passed values is (2, 1), indices imply (2, 2)

Passing engine="REISE.jl" to the Grid constructor doesn't solve the problem.

Environment

Please specify your platform and versions of the relevant libraries you are using:

  • Operating system: Windows
  • PowerSimData revision: 8357023827885b936fb1aef758a09e82fdc93004
  • Python version: 3.9.6
@danielolsen danielolsen added the bug Something isn't working label Mar 10, 2022
@danielolsen danielolsen removed their assignment May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants