Skip to content

Commit

Permalink
feat: add calculate_bus_demand to Create and Analyze
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Oct 8, 2020
1 parent e53b03a commit 90eaf9b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion powersimdata/scenario/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from powersimdata.input.input_data import InputData
from powersimdata.input.transform_profile import TransformProfile
from powersimdata.output.output_data import OutputData, construct_load_shed
from powersimdata.scenario.helpers import calculate_bus_demand
from powersimdata.scenario.state import State
from powersimdata.utility import server_setup

Expand Down Expand Up @@ -242,7 +243,7 @@ def get_demand(self, original=True):
:param bool original: should the original demand profile or the
potentially modified one be returned.
:return: (*pandas.DataFrame*) -- data frame of demand.
:return: (*pandas.DataFrame*) -- data frame of demand (hour, zone).
"""
profile = TransformProfile(
self._ssh, self._scenario_info, self.get_grid(), self.get_ct()
Expand Down Expand Up @@ -272,6 +273,18 @@ def get_demand(self, original=True):
demand[start:end] *= 1.0 - value / 100.0
return demand

def get_bus_demand(self):
"""Returns demand profiles, by bus.
:return: (*pandas.DataFrame*) -- data frame of demand (hour, bus).
"""
profile = TransformProfile(
self._ssh, self._scenario_info, self.get_grid(), self.get_ct()
)
demand = profile.get_profile("demand")
grid = self.get_grid()
return calculate_bus_demand(grid.bus, demand)

def get_hydro(self):
"""Returns hydro profile
Expand Down
15 changes: 14 additions & 1 deletion powersimdata/scenario/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
from powersimdata.input.transform_grid import TransformGrid
from powersimdata.input.transform_profile import TransformProfile
from powersimdata.scenario.execute import Execute
from powersimdata.scenario.helpers import check_interconnect, interconnect2name
from powersimdata.scenario.helpers import (
calculate_bus_demand,
check_interconnect,
interconnect2name,
)
from powersimdata.scenario.state import State
from powersimdata.utility import server_setup
from powersimdata.utility.transfer_data import upload
Expand Down Expand Up @@ -149,6 +153,15 @@ def get_demand(self):
"""
return self.get_profile("demand")

def get_bus_demand(self):
"""Returns demand profiles, by bus.
:return: (*pandas.DataFrame*) -- data frame of demand (hour, bus).
"""
demand = self.get_profile("demand")
grid = self.get_grid()
return calculate_bus_demand(grid.bus, demand)

def get_hydro(self):
"""Returns hydro profile.
Expand Down

0 comments on commit 90eaf9b

Please sign in to comment.