Skip to content

Commit

Permalink
Merge pull request #422 from Breakthrough-Energy/daniel/create_get_bu…
Browse files Browse the repository at this point in the history
…s_demand

fix: ensure that get_bus_demand works in Create state
  • Loading branch information
danielolsen committed Apr 7, 2021
1 parent 59f1038 commit 224a909
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion powersimdata/input/input_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def get_bus_demand(scenario_info, grid):
:param powersimdata.input.grid.Grid grid: grid to construct bus demand for.
:return: (*pandas.DataFrame*) -- data frame of demand.
"""
demand = InputData().get_data(scenario_info, "demand")
bus = grid.bus
demand = InputData().get_data(scenario_info, "demand")[bus.zone_id.unique()]
bus["zone_Pd"] = bus.groupby("zone_id")["Pd"].transform("sum")
bus["zone_share"] = bus["Pd"] / bus["zone_Pd"]
zone_bus_shares = pd.DataFrame(
Expand Down
1 change: 1 addition & 0 deletions powersimdata/scenario/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def get_bus_demand(self):
:return: (*pandas.DataFrame*) -- data frame of demand (hour, bus).
"""
self._update_scenario_info()
grid = self.get_grid()
return get_bus_demand(self._scenario_info, grid)

Expand Down
11 changes: 11 additions & 0 deletions powersimdata/scenario/tests/test_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest

from powersimdata.scenario.scenario import Scenario


@pytest.mark.ssh
def test_get_bus_demand():
scenario = Scenario("")
scenario.state.set_builder(interconnect="Texas")
scenario.state.builder.set_base_profile("demand", "vJan2021")
scenario.state.get_bus_demand()

0 comments on commit 224a909

Please sign in to comment.