Skip to content

Commit

Permalink
Fix error due to updated eCalc version
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfjl committed Jan 3, 2024
1 parent e3f6b83 commit bdf61f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions popt/cost_functions/ecalc_npv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import csv
from pathlib import Path
import pandas as pd
import sys

HERE = Path().cwd() # fallback for ipynb's
HERE = HERE.resolve()
Expand Down Expand Up @@ -31,7 +32,7 @@ def ecalc_npv(pred_data, keys_opt, report):

from libecalc.core.ecalc import EnergyCalculator
from libecalc.common.time_utils import Frequency
from libecalc.input.model import YamlModel
from libecalc.presentation.yaml.model import YamlModel

# Economic values
npv_const = {}
Expand Down Expand Up @@ -112,14 +113,17 @@ def results_as_df(yaml_model, results, getter) -> pd.DataFrame:
"""Extract relevant values, as well as some meta (`attrs`)."""
df = {}
attrs = {}
res = None
for id_hash in results:
res = results[id_hash]
res = getter(res)
component = yaml_model.graph.components[id_hash]
component = yaml_model.graph.get_node(id_hash)
df[component.name] = res.values
attrs[component.name] = {'id_hash': id_hash,
'kind': type(component).__name__,
'unit': res.unit}
if res is None:
sys.exit('No emission results from eCalc!')
df = pd.DataFrame(df, index=res.timesteps)
df.index.name = "dates"
df.attrs = attrs
Expand Down

0 comments on commit bdf61f9

Please sign in to comment.