Skip to content

Commit

Permalink
debug merge error in demandregio
Browse files Browse the repository at this point in the history
  • Loading branch information
khelfen committed Dec 28, 2024
1 parent 5b90e76 commit 9665577
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/egon/data/datasets/demandregio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DemandRegio(Dataset):
def __init__(self, dependencies):
super().__init__(
name="DemandRegio",
version="0.0.9",
version="0.0.10.dev",
dependencies=dependencies,
tasks=(
clone_and_install, # demandregio must be previously installed
Expand Down Expand Up @@ -505,7 +505,7 @@ def disagg_households_power(
return df


def write_demandregio_hh_profiles_to_db(hh_profiles, year):
def write_demandregio_hh_profiles_to_db(hh_profiles):
"""Write HH demand profiles from demand regio into db. One row per
year and nuts3. The annual load profile timeseries is an array.
Expand All @@ -517,11 +517,11 @@ def write_demandregio_hh_profiles_to_db(hh_profiles, year):
Parameters
----------
hh_profiles: pd.DataFrame
year: int
Returns
-------
"""
years = hh_profiles.index.year.unique().values
df_to_db = pd.DataFrame(
columns=["id", "year", "nuts3", "load_in_mwh"]
).set_index("id")
Expand All @@ -546,11 +546,13 @@ def write_demandregio_hh_profiles_to_db(hh_profiles, year):
else:
id = id + 1

for nuts3 in hh_profiles.columns:
id += 1
df_to_db.at[id, "year"] = year
df_to_db.at[id, "nuts3"] = nuts3
df_to_db.at[id, "load_in_mwh"] = hh_profiles[nuts3].to_list()
for year in years:
df = hh_profiles[hh_profiles.index.year == year]
for nuts3 in hh_profiles.columns:
id += 1
df_to_db.at[id, "year"] = year
df_to_db.at[id, "nuts3"] = nuts3
df_to_db.at[id, "load_in_mwh"] = df[nuts3].to_list()

df_to_db["year"] = df_to_db["year"].apply(int)
df_to_db["nuts3"] = df_to_db["nuts3"].astype(str)
Expand Down Expand Up @@ -638,7 +640,7 @@ def change_year(dt, year):

hh_load_timeseries.iloc[:24 * 7] = hh_load_timeseries.iloc[24 * 7:24 * 7 * 2].values

write_demandregio_hh_profiles_to_db(hh_load_timeseries, year)
write_demandregio_hh_profiles_to_db(hh_load_timeseries)


def insert_cts_ind(scenario, year, engine, target_values):
Expand Down Expand Up @@ -743,7 +745,10 @@ def insert_household_demand():
)

for scn in scenarios:
year = scenario_parameters.global_settings(scn)["population_year"]
year = (
2023 if scn == "status2023"
else scenario_parameters.global_settings(scn)["population_year"]
)

# Insert demands of private households
insert_hh_demand(scn, year, engine)
Expand Down

0 comments on commit 9665577

Please sign in to comment.