Skip to content

Commit a0fe43c

Browse files
committed
Remove represent_hours function
1 parent 7ebab9e commit a0fe43c

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

src/muse/objectives.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,8 @@ def capacity_to_service_demand(
214214
) -> xr.DataArray:
215215
"""Minimum capacity required to fulfill the demand."""
216216
from muse.quantities import capacity_to_service_demand
217-
from muse.timeslices import represent_hours
218217

219-
hours = represent_hours(demand.timeslice)
220-
return capacity_to_service_demand(
221-
demand=demand, technologies=technologies, hours=hours
222-
)
218+
return capacity_to_service_demand(demand=demand, technologies=technologies)
223219

224220

225221
@register_objective
@@ -230,13 +226,12 @@ def capacity_in_use(
230226
**kwargs,
231227
):
232228
from muse.commodities import is_enduse
233-
from muse.timeslices import represent_hours
229+
from muse.timeslices import TIMESLICE
234230

235-
hours = represent_hours(demand.timeslice)
236231
enduses = is_enduse(technologies.comm_usage.sel(commodity=demand.commodity))
237232
return (
238-
(demand.sel(commodity=enduses).sum("commodity") / hours).sum("timeslice")
239-
* hours.sum()
233+
(demand.sel(commodity=enduses).sum("commodity") / TIMESLICE).sum("timeslice")
234+
* TIMESLICE.sum()
240235
/ technologies.utilization_factor
241236
)
242237

src/muse/quantities.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,11 @@ def group_assets(x: xr.DataArray) -> xr.DataArray:
529529
def capacity_to_service_demand(
530530
demand: xr.DataArray,
531531
technologies: xr.Dataset,
532-
hours=None,
533532
) -> xr.DataArray:
534533
"""Minimum capacity required to fulfill the demand."""
535-
from muse.timeslices import represent_hours
534+
from muse.timeslices import TIMESLICE
536535

537-
if hours is None:
538-
hours = represent_hours(demand.timeslice)
539-
max_hours = hours.max() / hours.sum()
536+
max_hours = TIMESLICE.max() / TIMESLICE.sum()
540537
commodity_output = technologies.fixed_outputs.sel(commodity=demand.commodity)
541538
max_demand = (
542539
demand.where(commodity_output > 0, 0)

src/muse/timeslices.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"convert_timeslice",
77
"timeslice_projector",
88
"setup_module",
9-
"represent_hours",
109
]
1110

1211
from collections.abc import Mapping, Sequence
@@ -588,19 +587,6 @@ def new_to_old_timeslice(ts: DataArray, ag_level="Month") -> dict:
588587
return converted_ts
589588

590589

591-
def represent_hours(
592-
timeslices: DataArray, nhours: Union[int, float] = 8765.82
593-
) -> DataArray:
594-
"""Number of hours per timeslice.
595-
596-
Arguments:
597-
timeslices: The timeslice for which to compute the number of hours
598-
nhours: The total number of hours represented in the timeslice. Defaults to the
599-
average number of hours in year.
600-
"""
601-
return convert_timeslice(DataArray([nhours]), timeslices).squeeze()
602-
603-
604590
def drop_timeslice(data: DataArray) -> DataArray:
605591
"""Drop the timeslice variable from a DataArray.
606592

0 commit comments

Comments
 (0)