Skip to content

Commit

Permalink
fix rounding in dynamic_lcia
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoDiepers committed Sep 25, 2024
1 parent 1036e63 commit 298ce18
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion bw_timex/timex_lca.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import warnings
from datetime import datetime
from functools import partial
from itertools import chain
from typing import Callable, Optional

Expand Down Expand Up @@ -31,7 +32,11 @@
from .helper_classes import SetList, TimeMappingDict
from .matrix_modifier import MatrixModifier
from .timeline_builder import TimelineBuilder
from .utils import extract_date_as_integer, resolve_temporalized_node_name
from .utils import (
extract_date_as_integer,
resolve_temporalized_node_name,
round_datetime,
)


class TimexLCA:
Expand Down Expand Up @@ -445,6 +450,18 @@ def dynamic_lcia(
# Set a default for inventory_in_time_horizon using the full dynamic_inventory_df
inventory_in_time_horizon = self.dynamic_inventory_df

# Round dates to nearest year and sum up emissions for each year
inventory_in_time_horizon.date = inventory_in_time_horizon.date.apply(
partial(round_datetime, resolution="year")
)
inventory_in_time_horizon = (
inventory_in_time_horizon.groupby(
inventory_in_time_horizon.columns.tolist()
)
.sum()
.reset_index()
)

# Calculate the latest considered impact date
t0_date = pd.Timestamp(self.timeline_builder.edge_extractor.t0.date[0])
latest_considered_impact = t0_date + pd.DateOffset(years=time_horizon)
Expand Down

0 comments on commit 298ce18

Please sign in to comment.