Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate hh demand curves in function 'demands_per_bus' #381

Closed
IlkaCu opened this issue Aug 11, 2021 · 0 comments · Fixed by #546
Closed

Integrate hh demand curves in function 'demands_per_bus' #381

IlkaCu opened this issue Aug 11, 2021 · 0 comments · Fixed by #546
Assignees

Comments

@IlkaCu
Copy link
Member

IlkaCu commented Aug 11, 2021

As soon as the household demand curves are available (PR #260) the data need to be included here:

def demands_per_bus(scenario):
"""Sum all electricity demand curves up per bus
Parameters
----------
scenario : str
Scenario name.
Returns
-------
pandas.DataFrame
Aggregated electrical demand timeseries per bus
"""
# Read information from configuration file
sources = egon.data.config.datasets()["etrago_electricity"]["sources"]
# Select data on CTS electricity demands per bus
cts_curves = db.select_dataframe(
f"""SELECT subst_id, p_set FROM
{sources['cts_curves']['schema']}.
{sources['cts_curves']['table']}
WHERE scn_name = '{scenario}'""",
index_col="subst_id",
)
# Rename index
cts_curves.index.rename("bus", inplace=True)
# Select data on industrial demands assigned to osm landuse areas
ind_curves_osm = db.select_dataframe(
f"""SELECT bus, p_set FROM
{sources['osm_curves']['schema']}.
{sources['osm_curves']['table']}
WHERE scn_name = '{scenario}'""",
index_col="bus",
)
# Select data on industrial demands assigned to industrial sites
ind_curves_sites = db.select_dataframe(
f"""SELECT bus, p_set FROM
{sources['sites_curves']['schema']}.
{sources['sites_curves']['table']}
WHERE scn_name = '{scenario}'""",
index_col="bus",
)
# Create one df by appending all imported dataframes
demand_curves = cts_curves.append([ind_curves_osm, ind_curves_sites])
# Split array to single columns in the dataframe
demand_curves_split = demand_curves
demand_curves_split = pd.DataFrame(
demand_curves.p_set.tolist(), index=demand_curves_split.index
)
# Group all rows with the same bus
demand_curves_bus = demand_curves_split.groupby(
demand_curves_split.index
).sum()
# Initzialize and fill resulsting dataframe
curves = pd.DataFrame(columns=["bus", "p_set"])
curves["bus"] = demand_curves_bus.index
curves["p_set"] = demand_curves_bus.values.tolist()
return curves

@IlkaCu IlkaCu self-assigned this Aug 11, 2021
IlkaCu added a commit that referenced this issue Dec 2, 2021
IlkaCu added a commit that referenced this issue Dec 14, 2021
…and-per-bus

Add hh demand profiles to etrago tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant