Skip to content

Fix indexing of added HVDC and AC lines#216

Merged
rouille merged 2 commits intodevelopfrom
fix_ids
Jun 26, 2020
Merged

Fix indexing of added HVDC and AC lines#216
rouille merged 2 commits intodevelopfrom
fix_ids

Conversation

@rouille
Copy link
Copy Markdown
Collaborator

@rouille rouille commented Jun 26, 2020

Purpose

Fix a bug that incorrectly index added HVDC and AC lines (see issue #215)

What is the code doing?

  • Consider the correct data frame when seeting the index
  • Add test on indexing

Where to look

The _add_branch and _add_dcline methods of the TransformGrid class where the indexing logic happens.

Time estimate

10 min. It is a 2 variables modification.

@rouille rouille added the bug Something isn't working label Jun 26, 2020
@rouille rouille added this to the Black Lives Matter milestone Jun 26, 2020
@rouille rouille requested review from BainanXia and danielolsen June 26, 2020 18:03
@danielolsen
Copy link
Copy Markdown
Contributor

Before:

>>> from powersimdata.scenario.scenario import Scenario
>>> scenario = Scenario('')
>>> scenario.state.set_builder(['USA'])
Reading bus.csv
Reading plant.csv
Reading gencost.csv
Reading branch.csv
Reading dcline.csv
Reading sub.csv
Reading bus2sub.csv
Reading zone.csv
--> Summary
# Existing study
test | base | Anchor | Julia
# Available profiles
demand: v6
hydro: v3 | v4
solar: v3.1 | v4.2 | v4.3.1 | v4.3
wind: v4.1 | v5.2.1 | v5.3 | v5.4
>>> new_dclines = new_dclines = [
...     {'from_bus_id': 26558, 'to_bus_id': 24343, 'capacity': 8000},
...     {'from_bus_id': 24343, 'to_bus_id': 61534, 'capacity': 8000}]
>>> scenario.state.builder.change_table.add_dcline(new_dclines)
>>> scenario.state.get_grid().dcline
       from_bus_id  to_bus_id  ...  from_interconnect  to_interconnect
0      69999        2077254    ...  Eastern            Western
1      67947        2070132    ...  Eastern            Western
2      67315        2070170    ...  Eastern            Western
3      66353        2060653    ...  Eastern            Western
4      65584        2060761    ...  Eastern            Western
5      61858        2053305    ...  Eastern            Western
6      61981        2053238    ...  Eastern            Western
7      63463        3002054    ...  Eastern            Texas
8      59722        3008126    ...  Eastern            Texas
9      2050383      2028847    ...  Western            Western
10     2013620      2025332    ...  Western            Western
11     69748        51390      ...  Eastern            Eastern
12     11613        6132       ...  Eastern            Eastern
13     6171         6219       ...  Eastern            Eastern
14     69731        49734      ...  Eastern            Eastern
15     2021181      2021641    ...  Western            Western
16     5423         7280       ...  Eastern            Eastern
14050  26558        24343      ...  Eastern            Eastern
14050  24343        61534      ...  Eastern            Eastern

After:

>>> from powersimdata.scenario.scenario import Scenario
>>> scenario = Scenario('')
>>> scenario.state.set_builder(['USA'])
Reading bus.csv
Reading plant.csv
Reading gencost.csv
Reading branch.csv
Reading dcline.csv
Reading sub.csv
Reading bus2sub.csv
Reading zone.csv
--> Summary
# Existing study
test | base | Anchor | Julia
# Available profiles
demand: v6
hydro: v3 | v4
solar: v3.1 | v4.2 | v4.3.1 | v4.3
wind: v4.1 | v5.2.1 | v5.3 | v5.4
>>> new_dclines = new_dclines = [
...     {'from_bus_id': 26558, 'to_bus_id': 24343, 'capacity': 8000},
...     {'from_bus_id': 24343, 'to_bus_id': 61534, 'capacity': 8000}]
>>> scenario.state.builder.change_table.add_dcline(new_dclines)
>>> scenario.state.get_grid().dcline
    from_bus_id  to_bus_id  status  ...  muQmaxT  from_interconnect  to_interconnect
0   69999        2077254    1       ...  0        Eastern            Western    
1   67947        2070132    1       ...  0        Eastern            Western    
2   67315        2070170    1       ...  0        Eastern            Western    
3   66353        2060653    1       ...  0        Eastern            Western    
4   65584        2060761    1       ...  0        Eastern            Western    
5   61858        2053305    1       ...  0        Eastern            Western    
6   61981        2053238    1       ...  0        Eastern            Western    
7   63463        3002054    1       ...  0        Eastern            Texas      
8   59722        3008126    1       ...  0        Eastern            Texas      
9   2050383      2028847    1       ...  0        Western            Western    
10  2013620      2025332    1       ...  0        Western            Western    
11  69748        51390      1       ...  0        Eastern            Eastern    
12  11613        6132       1       ...  0        Eastern            Eastern    
13  6171         6219       1       ...  0        Eastern            Eastern    
14  69731        49734      1       ...  0        Eastern            Eastern    
15  2021181      2021641    1       ...  0        Western            Western    
16  5423         7280       1       ...  0        Eastern            Eastern    
17  26558        24343      1       ...  0        Eastern            Eastern    
18  24343        61534      1       ...  0        Eastern            Eastern    

[19 rows x 25 columns]

Copy link
Copy Markdown
Contributor

@danielolsen danielolsen 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 the quick fix. I appreciate the teamwork that led to this bug: my bad example code, you committing it, and then me missing it in the review.

@rouille
Copy link
Copy Markdown
Collaborator Author

rouille commented Jun 26, 2020

Thanks for the quick fix. I appreciate the teamwork that led to this bug: my bad example code, you committing it, and then me missing it in the review.

This is 100% my fault. Glad you caught the bug early.

@rouille rouille merged commit 316af1c into develop Jun 26, 2020
@rouille rouille deleted the fix_ids branch June 26, 2020 19:45
@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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants