Skip to content

Commit

Permalink
Merge remote-tracking branch 'powerd-data/dev' into features/powerd-all
Browse files Browse the repository at this point in the history
  • Loading branch information
khelfen committed Nov 26, 2024
2 parents eefbb3b + 4ca597c commit 306aa87
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 7 deletions.
12 changes: 12 additions & 0 deletions src/egon/data/airflow/dags/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
HeatSupply,
)
from egon.data.datasets.heat_supply.individual_heating import (
HeatPumps2019,
HeatPumps2035,
HeatPumps2050,
HeatPumpsPypsaEur,
Expand Down Expand Up @@ -590,6 +591,17 @@
dependencies=[vg250, setup_etrago, create_gas_polygons]
)

# Heat pump disaggregation for status2019
heat_pumps_2019 = HeatPumps2019(
dependencies=[
cts_demand_buildings,
DistrictHeatingAreas,
heat_supply,
heat_time_series,
power_plants,
]
)

# Heat pump disaggregation for eGon2035
heat_pumps_2035 = HeatPumps2035(
dependencies=[
Expand Down
3 changes: 2 additions & 1 deletion src/egon/data/datasets/ch4_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def load_biogas_generators(scn_name):
)
target_file = Path(".") / "datasets" / "gas_data" / basename

urlretrieve(url, target_file)
if not target_file.is_file():
urlretrieve(url, target_file)

# Read-in data from csv-file
biogas_generators_list = pd.read_excel(
Expand Down
4 changes: 4 additions & 0 deletions src/egon/data/datasets/chp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ def assign_heat_bus():
epsg=4326,
)

if chp.empty:
print(f"No CHP for district heating in scenario {scenario}")
return

# Select district heating areas and their centroid
district_heating = db.select_geodataframe(
f"""
Expand Down
4 changes: 4 additions & 0 deletions src/egon/data/datasets/chp_etrago.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def insert_egon100re():
"""
)

if chp_dh.empty:
print("No CHP for district heating in scenario eGon100RE")
return

# Create geodataframes for gas CHP plants
chp_el = link_geom_from_buses(
gpd.GeoDataFrame(
Expand Down
7 changes: 4 additions & 3 deletions src/egon/data/datasets/demandregio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,13 +952,14 @@ def timeseries_per_wz():
"""

scenarios = egon.data.config.settings()["egon-data"]["--scenarios"]

year_already_in_database = []
for scn in scenarios:
year = int(scenario_parameters.global_settings(scn)["weather_year"])

for sector in ["CTS", "industry"]:
insert_timeseries_per_wz(sector, int(year))

if not year in year_already_in_database:
insert_timeseries_per_wz(sector, int(year))
year_already_in_database.append(year)

def get_cached_tables():
"""Get cached demandregio tables and db-dump from former runs"""
Expand Down
43 changes: 43 additions & 0 deletions src/egon/data/datasets/gas_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,49 @@ def define_gas_buses_abroad(scn_name="eGon2035"):
gdf_abroad_buses.drop_duplicates(
subset="country", keep="first", inplace=True
)

if settings()["egon-data"]["--dataset-boundary"] != "Everything":
gdf_abroad_buses_insert = pd.DataFrame(
index=[gdf_abroad_buses.index.max() + 1],
data={
"scn_name": scn_name,
"bus_id": (db.next_etrago_id("bus") + len(gdf_abroad_buses) + 1),
"x": 10.4234469,
"y": 51.0834196,
"country": "DE",
"carrier": gas_carrier,
},
)

gdf_abroad_buses_insert = geopandas.GeoDataFrame(
gdf_abroad_buses_insert,
geometry=geopandas.points_from_xy(
gdf_abroad_buses_insert["x"], gdf_abroad_buses_insert["y"]
),
)
gdf_abroad_buses_insert = gdf_abroad_buses_insert.rename(
columns={"geometry": "geom"}
).set_geometry("geom", crs=4326)

# Insert to db
print(gdf_abroad_buses_insert)
gdf_abroad_buses_insert.to_postgis(
"egon_etrago_bus",
engine,
schema="grid",
index=False,
if_exists="append",
dtype={"geom": Geometry()},
)

gdf_abroad_buses = pd.concat(
[
gdf_abroad_buses,
gdf_abroad_buses_insert
],
ignore_index=True,
)

return gdf_abroad_buses

else:
Expand Down
3 changes: 3 additions & 0 deletions src/egon/data/datasets/hydrogen_etrago/h2_to_ch4.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def insert_h2_to_ch4_to_h2():
"""
scenarios = config.settings()["egon-data"]["--scenarios"]

if "status2019" in scenarios:
scenarios.remove("status2019")

for scn_name in scenarios:
# Connect to local database
engine = db.engine()
Expand Down
3 changes: 3 additions & 0 deletions src/egon/data/datasets/hydrogen_etrago/power_to_h2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def insert_power_to_h2_to_power():
"""
scenarios = config.settings()["egon-data"]["--scenarios"]

if "status2019" in scenarios:
scenarios.remove("status2019")

for scn_name in scenarios:

# Connect to local database
Expand Down
8 changes: 7 additions & 1 deletion src/egon/data/datasets/power_plants/pv_rooftop.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ def pv_rooftop_per_mv_grid_and_scenario(scenario, level):
WHERE carrier = 'solar_rooftop'
AND scenario_name = '{scenario}'
"""
).capacity[0]
)

if target.empty:
print(f"No PV rooftop in scenario {scenario}")
return
else:
target = target.capacity[0]

dataset = config.settings()["egon-data"]["--dataset-boundary"]

Expand Down
4 changes: 4 additions & 0 deletions src/egon/data/datasets/power_plants/pv_rooftop_buildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,10 @@ def allocate_scenarios(
"""
cap_per_bus_id_df = cap_per_bus_id(scenario)

if cap_per_bus_id_df.empty:
print(f"No PV rooftop in scenario {scenario}")
return

logger.debug(
f"cap_per_bus_id_df total capacity: {cap_per_bus_id_df.capacity.sum()}"
)
Expand Down
2 changes: 1 addition & 1 deletion src/egon/data/datasets/scenario_parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class ScenarioParameters(Dataset):
#:
name: str = "ScenarioParameters"
#:
version: str = "0.0.12"
version: str = "0.0.17"

def __init__(self, dependencies):
super().__init__(
Expand Down
2 changes: 1 addition & 1 deletion src/egon/data/datasets/scenario_parameters/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def global_settings(scenario):

elif scenario == "status2019":
parameters = {
"weather_year": 2019,
"weather_year": 2011,
"population_year": 2019,
"fuel_costs": { # TYNDP 2020, data for 2020 (https://2020.entsos-tyndp-scenarios.eu/fuel-commodities-and-carbon-prices/)
"oil": 12.9*3.6, # [EUR/MWh]
Expand Down
12 changes: 12 additions & 0 deletions src/egon/data/datasets/scenario_path/import_status2019.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def download_status2019():
None.
"""

if "status2019" in config.settings()["egon-data"]["--scenarios"]:
print("Scenario status2019 was created within the pipeline. "
"It is not imported from zenodo.")
return

# Get parameters from config and set download URL
url = sources["url_status2019"]
status2019_path = Path(".") / "PoWerD_status2019.backup"
Expand All @@ -43,6 +49,12 @@ def import_scn_status2019():
*No parameters required
"""

if "status2019" in config.settings()["egon-data"]["--scenarios"]:
print("Scenario status2019 was created within the pipeline. "
"It is not imported from zenodo.")
return

# Connect to the data base
con = db.engine()

Expand Down

0 comments on commit 306aa87

Please sign in to comment.