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: correct generation of duplicated bus entries in bus-to-NEEM-region mapping #546

Merged
merged 3 commits into from
Sep 21, 2021

Conversation

danielolsen
Copy link
Contributor

Pull Request doc

Purpose

Closes #545.

What the code is doing

  • Within create_mapping_files.py, after we detect bus coordinates that lay within region polygons, we identify duplicated buses. For each, we find the closest neighboring bus within non-duplicated buses. We assume that that is the best guess for the 'true' region of the duplicated bus, and mark any other regions to be dropped.
  • There is also an unrelated fix for the code to make directories.
  • We update the CSV as a result of running the new code.

Testing

Tested manually to generate a new CSV:

from powersimdata import Grid
from powersimdata.design.investment.create_mapping_files import write_bus_neem_map
grid = Grid("USA")
write_bus_neem_map(grid)

Confirming that the new CSV has no duplicates:

>>> from powersimdata.design.investment import const
>>> mapping = pd.read_csv(const.bus_neem_regions_path)
>>> mapping.index.duplicated().sum()
0

We can also see that the newly-generated CSV now has exactly nine fewer rows, and no other changes, which follows from the nine duplicate pairs detected earlier.

Confirming that the Scenario that triggered the bug before no longer does:

>>> from powersimdata import Scenario
>>> from powersimdata.design.investment.investment_costs import calculate_ac_inv_costs
>>> scenario = Scenario(3287)
>>> calculate_ac_inv_costs(scenario)
{'line_cost': 387768866295.44775, 'transformer_cost': 9334839565.245375}

Time estimate

15-30 minutes.

@danielolsen danielolsen added the bug Something isn't working label Sep 14, 2021
@danielolsen danielolsen self-assigned this Sep 14, 2021
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.

Good catch.

@danielolsen danielolsen force-pushed the daniel/bus_to_neem_fix branch from 7b28d44 to 1b58500 Compare September 21, 2021 21:42
@danielolsen danielolsen merged commit 109900b into develop Sep 21, 2021
@danielolsen danielolsen deleted the daniel/bus_to_neem_fix branch September 21, 2021 21:55
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.

Duplicate entries in buses_NEEMregion.csv can cause ValueError when calculating AC investment costs
2 participants