Skip to content

Commit

Permalink
Adapt to new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
uvchik committed Feb 2, 2021
1 parent 9e61ead commit 4a5ca15
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/scenario_builder/config.py
Expand Up @@ -10,6 +10,7 @@
from reegis.config import get # noqa: F401
from reegis.config import get_dict # noqa: F401
from reegis.config import get_dict_list # noqa: F401
from reegis.config import get_list # noqa: F401
from reegis.config import init # noqa: F401

_loaded = False
Expand Down
25 changes: 16 additions & 9 deletions src/scenario_builder/data.py
@@ -1,17 +1,22 @@
"""Create a basic scenario from the internal data structure.
# -*- coding: utf-8 -*-

SPDX-FileCopyrightText: 2016-2019 Uwe Krien <krien@uni-bremen.de>
"""General data processing for general non-reegis data.
SPDX-FileCopyrightText: 2016-2020 Uwe Krien <krien@uni-bremen.de>
SPDX-License-Identifier: MIT
"""
__copyright__ = "Uwe Krien <krien@uni-bremen.de>"
__license__ = "MIT"


import os
from types import SimpleNamespace

import pandas as pd
from reegis.tools import download_file

from scenario_builder import config as cfg
from deflex import config as cfg
from deflex import tools

TRANSLATION_FUEL = {
"Abfall": "waste",
Expand All @@ -34,20 +39,22 @@ def get_ewi_data():
-------
namedtuple
TODO: Keep this in deflex???
Examples
--------
>>> my_ewi_data = get_ewi_data()
>>> round(my_ewi_data.fuel_costs.loc["hard coal", "value"], 2)
11.28
# >>> ewi_data = get_ewi_data()
# >>> round(ewi_data.fuel_costs.loc["hard coal", "value"], 2)
# 11.28
"""
# Download file
url = (
"https://www.ewi.uni-koeln.de/cms/wp-content/uploads/2019/12"
"/EWI_Merit_Order_Tool_2019_1_4.xlsm"
)
fn = os.path.join(cfg.get("paths", "general"), "ewi.xlsm")
download_file(fn, url)
fn = os.path.join(cfg.get("paths", "deflex_general"), "ewi.xls")
tools.download(fn, url)

# Create named tuple with all sub tables
ewi_tables = {
Expand Down
12 changes: 6 additions & 6 deletions src/scenario_builder/powerplants.py
Expand Up @@ -227,7 +227,7 @@ def create_powerplants(
.loc["volatile_source"]
}

if cfg.get("basic", "group_transformer"):
if cfg.get("creator", "group_transformer"):
power_plants["transformer"] = (
pp.groupby(
["model_classes", region_column, "energy_source_level_2"]
Expand Down Expand Up @@ -266,8 +266,8 @@ def create_powerplants(
pp_class["capacity"] / pp_class["capacity_in"] * 100
)
del pp_class["capacity_in"]
if cfg.get("basic", "round") is not None:
pp_class = pp_class.round(cfg.get("basic", "round"))
if cfg.get("creator", "round") is not None:
pp_class = pp_class.round(cfg.get("creator", "round"))
if "efficiency" in pp_class:
pp_class["efficiency"] = pp_class["efficiency"].div(100)
pp_class = pp_class.transpose()
Expand All @@ -291,7 +291,7 @@ def add_additional_values(table_collection):
"""
transf = table_collection["transformer"]
for values in ["variable_costs", "downtime_factor"]:
if cfg.get("basic", "use_{0}".format(values)) is True:
if cfg.get("creator", "use_{0}".format(values)) is True:
add_values = getattr(data.get_ewi_data(), values)
transf = transf.merge(
add_values, right_index=True, how="left", left_on="fuel",
Expand All @@ -316,11 +316,11 @@ def add_pp_limit(table_collection, year):
-------
"""
if len(cfg.get_dict("limited_transformer").keys()) > 0:
if len(cfg.get_list("creator", "limited_transformer")) > 0:
# Multiply with 1000 to get MWh (bmwi: GWh)
repp = bmwi.bmwi_re_energy_capacity() * 1000
trsf = table_collection["transformer"]
for limit_trsf in cfg.get_dict("limited_transformer").keys():
for limit_trsf in cfg.get_list("creator", "limited_transformer"):
trsf = table_collection["transformer"]
try:
limit = repp.loc[year, (limit_trsf, "energy")]
Expand Down

0 comments on commit 4a5ca15

Please sign in to comment.