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: enable MATReader to import single DC line from case.mat #125

Merged
merged 1 commit into from
Apr 3, 2020

Conversation

danielolsen
Copy link
Contributor

@danielolsen danielolsen commented Apr 3, 2020

Purpose

Fix a bug where scenarios with a single DC line (e.g. Scenarios 97 and 109, TexasWestern) are not loaded properly by the MATReader object.

What is the code doing

Detect if mpc.dcline is an int, and if so set n_dcline to 1. Later, if n_dcline == 1, expand mpc.dclineid from int to a 1D array, and mpc.dcline from 1D to 2D, so that they're processed properly by frame().

Testing

Before:

>>> from powersimdata.scenario.scenario import Scenario
>>> scenario = Scenario('109')
SCENARIO: base | TexasWestern

--> State
analyze
>>> grid = scenario.state.get_grid()
--> Loading grid
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading sub
Loading bus2sub
>>> grid.dcline
Empty DataFrame
Columns: []
Index: []

After:

>>> from powersimdata.scenario.scenario import Scenario
>>> scenario = Scenario('109')
SCENARIO: base | TexasWestern

--> State
analyze
>>> grid = scenario.state.get_grid()
--> Loading grid
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading dcline
Loading sub
Loading bus2sub
>>> grid.dcline
           from_bus_id  to_bus_id  ...  from_interconnect  to_interconnect
dcline_id                          ...
5          2080048      3001079    ...  Western            Texas

[1 rows x 25 columns]

Scenarios with multiple DC lines continue to be loaded properly:

>>> from powersimdata.scenario.scenario import Scenario
>>> scenario = Scenario('400')
SCENARIO: test | EasternBase_2020_2

--> State
analyze
100%|#####################################| 7.63k/7.63k [00:00<00:00, 72.6kb/s]
>>> grid = scenario.state.get_grid()
--> Loading grid
400_grid.mat not found in C:\Users\dolsen\ScenarioData\ on local machine
Transferring 400_grid.mat from server
100%|#####################################| 15.2M/15.2M [00:02<00:00, 5.76Mb/s]
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading dcline
Loading sub
Loading bus2sub
>>> grid.dcline
           from_bus_id  to_bus_id  ...  from_interconnect  to_interconnect
dcline_id                          ...
11         69748        51390      ...  Eastern            Eastern
12         11613        6132       ...  Eastern            Eastern
13         6171         6219       ...  Eastern            Eastern
14         69731        49734      ...  Eastern            Eastern
16         5423         7280       ...  Eastern            Eastern

[5 rows x 25 columns]

Scenarios with no DC lines continue to be loaded properly:

>>> from powersimdata.scenario.scenario import Scenario
>>> scenario = Scenario('87')
SCENARIO: base | WesternBase_2016_noHVDC_Final_2019Sep

--> State
analyze
>>> grid = scenario.state.get_grid()
--> Loading grid
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading sub
Loading bus2sub
>>> grid.dcline
Empty DataFrame
Columns: []
Index: []

Time Estimate

Half an hour. Changes are minor, unit tests all pass, and integration tests have covered all major use cases.

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 for fixing that.

@danielolsen danielolsen merged commit 9fe40c3 into develop Apr 3, 2020
@danielolsen danielolsen deleted the fix_matreader_single_dcline_bug branch April 3, 2020 00:37
@ahurli ahurli mentioned this pull request Mar 11, 2021
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.

2 participants