Skip to content

Commit

Permalink
further removal of pandas series
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Nov 6, 2024
1 parent 7c988d0 commit 6a18a79
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion assume/common/fds.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_date_list(self, start=None, end=None):
return [start + i * self.freq for i in range(hour_count)]

def get_idx_from_date(self, date: datetime):
if not date:
if date is None:
return None
idx = (date - self.start) / self.freq
# todo check if modulo is 0 - else this is not a valid multiple of freq
Expand Down
2 changes: 1 addition & 1 deletion assume/units/demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def calculate_min_max_power(
tuple[pandas.Series, pandas.Series]: The bid colume as both the minimum and maximum power output of the unit.
"""
end_excl = end - self.index.freq
bid_volume = self.index.copy_empty(
bid_volume = FastDatetimeSeries(start, end_excl, self.index.freq,
self.volume[start:end_excl] - self.outputs[product_type][start:end_excl]
)
return bid_volume, bid_volume
Expand Down
24 changes: 8 additions & 16 deletions assume/units/powerplant.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,9 @@ def execute_current_dispatch(
"""
start = max(start, self.index.start)

max_power = FastDatetimeSeries(
start,
end,
self.index.freq,
self.forecaster.get_availability(self.id)[start:end] * self.max_power,
)

for t in self.outputs["energy"].get_date_list(start, end):
max_power = self.forecaster.get_availability(self.id)[start:end] * self.max_power

for idx, t in enumerate(self.outputs["energy"].get_date_list(start, end)):
current_power = self.outputs["energy"].at[t]

previous_power = self.get_output_before(t)
Expand All @@ -161,7 +156,7 @@ def execute_current_dispatch(
current_power = self.calculate_ramp(op_time, previous_power, current_power)

if current_power > 0:
current_power = min(current_power, max_power[t])
current_power = min(current_power, max_power[idx])
current_power = max(current_power, self.min_power)

self.outputs["energy"].at[t] = current_power
Expand All @@ -180,11 +175,8 @@ def set_dispatch_plan(
marketconfig (MarketConfig): The market configuration.
orderbook (Orderbook): The orderbook.
"""
products_index = list(get_products_index(orderbook))

max_power = self.index.copy_empty(
self.forecaster.get_availability(self.id)[products_index] * self.max_power
)
products_index = get_products_index(orderbook)
max_power = self.forecaster.get_availability(self.id)[list(products_index)] * self.max_power

product_type = marketconfig.product_type
for order in orderbook:
Expand All @@ -203,7 +195,7 @@ def set_dispatch_plan(

self.calculate_cashflow(product_type, orderbook)

for start in products_index:
for idx, start in enumerate(products_index):
current_power = self.outputs[product_type].at[start]

previous_power = self.get_output_before(start)
Expand All @@ -212,7 +204,7 @@ def set_dispatch_plan(
current_power = self.calculate_ramp(op_time, previous_power, current_power)

if current_power > 0:
current_power = min(current_power, max_power[start])
current_power = min(current_power, max_power[idx])
current_power = max(current_power, self.min_power)

self.outputs[product_type].at[start] = current_power
Expand Down
1 change: 1 addition & 0 deletions examples/world_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def init(world, n=1):
marketdesign = [
MarketConfig(
market_id="EOM",

opening_hours=rr.rrule(
rr.HOURLY, interval=24, dtstart=start, until=end, cache=True
),
Expand Down

0 comments on commit 6a18a79

Please sign in to comment.