Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/features/#903-desaggregate-heat-…
Browse files Browse the repository at this point in the history
…pumps' into local
  • Loading branch information
nailend committed Oct 12, 2022
2 parents 0459618 + 6e6557b commit 1463d80
Show file tree
Hide file tree
Showing 7 changed files with 1,538 additions and 18 deletions.
45 changes: 40 additions & 5 deletions src/egon/data/airflow/dags/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
from egon.data.datasets.heat_etrago import HeatEtrago
from egon.data.datasets.heat_etrago.hts_etrago import HtsEtragoTable
from egon.data.datasets.heat_supply import HeatSupply
from egon.data.datasets.heat_supply.individual_heating import (
HeatPumps2050,
HeatPumpsPypsaEurSec,
HeatPumps2035,
)
from egon.data.datasets.hydrogen_etrago import (
HydrogenBusEtrago,
HydrogenGridEtrago,
Expand Down Expand Up @@ -329,6 +334,24 @@
]
)

cts_demand_buildings = CtsDemandBuildings(
dependencies=[
osm_buildings_streets,
cts_electricity_demand_annual,
hh_demand_buildings_setup,
tasks["heat_demand_timeseries.export-etrago-cts-heat-profiles"],
]
)

# Minimum heat pump capacity for pypsa-eur-sec
heat_pumps_pypsa_eur_sec = HeatPumpsPypsaEurSec(
dependencies=[
cts_demand_buildings,
DistrictHeatingAreas,
heat_time_series,
]
)

# run pypsa-eur-sec
run_pypsaeursec = PypsaEurSec(
dependencies=[
Expand All @@ -339,6 +362,7 @@
data_bundle,
electrical_load_etrago,
heat_time_series,
heat_pumps_pypsa_eur_sec,
]
)

Expand Down Expand Up @@ -579,12 +603,23 @@
dependencies=[vg250, setup_etrago, create_gas_polygons_egon2035]
)

cts_demand_buildings = CtsDemandBuildings(
# Heat pump disaggregation for eGon2035
heat_pumps_2035 = HeatPumps2035(
dependencies=[
osm_buildings_streets,
cts_electricity_demand_annual,
hh_demand_buildings_setup,
tasks["heat_demand_timeseries.export-etrago-cts-heat-profiles"],
cts_demand_buildings,
DistrictHeatingAreas,
heat_supply,
heat_time_series,
heat_pumps_pypsa_eur_sec,
tasks["power_plants.pv-rooftop-to-buildings"]
]
)

# Heat pump disaggregation for eGon100RE
heat_pumps_2050 = HeatPumps2050(
dependencies=[
run_pypsaeursec,
heat_pumps_pypsa_eur_sec,
]
)

Expand Down
3 changes: 3 additions & 0 deletions src/egon/data/datasets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,9 @@ emobility_mit:
export_results_to_csv: True
parallel_tasks: 10

demand_timeseries_mvgd:
parallel_tasks: 10

charging_infrastructure:
original_data:
sources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ def calc_building_amenity_share(df_cts_buildings):


def calc_cts_building_profiles(
egon_building_ids,
bus_ids,
scenario,
sector,
Expand All @@ -966,8 +965,6 @@ def calc_cts_building_profiles(
Parameters
----------
egon_building_ids: list of int
Ids of the building for which the profile is calculated.
bus_ids: list of int
Ids of the substation for which selected building profiles are
calculated.
Expand All @@ -979,7 +976,9 @@ def calc_cts_building_profiles(
Returns
-------
df_building_profiles: pd.DataFrame
Table of demand profile per building
Table of demand profile per building. Column names are building IDs and index
is hour of the year as int (0-8759).
"""
if sector == "electricity":
# Get cts building electricity demand share of selected buildings
Expand All @@ -992,8 +991,8 @@ def calc_cts_building_profiles(
EgonCtsElectricityDemandBuildingShare.scenario == scenario
)
.filter(
EgonCtsElectricityDemandBuildingShare.building_id.in_(
egon_building_ids
EgonCtsElectricityDemandBuildingShare.bus_id.in_(
bus_ids
)
)
)
Expand Down Expand Up @@ -1029,8 +1028,8 @@ def calc_cts_building_profiles(
)
.filter(EgonCtsHeatDemandBuildingShare.scenario == scenario)
.filter(
EgonCtsHeatDemandBuildingShare.building_id.in_(
egon_building_ids
EgonCtsHeatDemandBuildingShare.bus_id.in_(
bus_ids
)
)
)
Expand Down
20 changes: 20 additions & 0 deletions src/egon/data/datasets/electricity_demand_timeseries/tools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from io import StringIO
import csv
import time

from shapely.geometry import Point
import geopandas as gpd
Expand All @@ -11,6 +12,23 @@
engine = db.engine()


def timeit(func):
"""
Decorator for measuring function's running time.
"""

def measure_time(*args, **kw):
start_time = time.time()
result = func(*args, **kw)
print(
"Processing time of %s(): %.2f seconds."
% (func.__qualname__, time.time() - start_time)
)
return result

return measure_time


def random_point_in_square(geom, tol):
"""
Generate a random point within a square
Expand Down Expand Up @@ -174,6 +192,8 @@ def write_table_to_postgres(
if drop:
db_table.__table__.drop(bind=engine, checkfirst=True)
db_table.__table__.create(bind=engine)
else:
db_table.__table__.create(bind=engine, checkfirst=True)

df.to_sql(
name=db_table.__table__.name,
Expand Down
2 changes: 1 addition & 1 deletion src/egon/data/datasets/heat_demand_timeseries/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EgonDailyHeatDemandPerClimateZone(Base):
climate_zone = Column(Text, primary_key=True)
day_of_year = Column(Integer, primary_key=True)
temperature_class = Column(Integer)
heat_demand_share = Column(Float(53))
daily_demand_share = Column(Float(53))


def temperature_classes():
Expand Down
3 changes: 1 addition & 2 deletions src/egon/data/datasets/heat_supply/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def __init__(self, dependencies):
create_tables,
{
district_heating,
# Temporary drop everything related to rural heat
# individual_heating,
individual_heating,
potential_germany,
},
),
Expand Down
Loading

0 comments on commit 1463d80

Please sign in to comment.