Skip to content

Commit

Permalink
Merge branch 'master' into ltes_storage_units
Browse files Browse the repository at this point in the history
  • Loading branch information
TomKae00 committed Jan 21, 2025
2 parents 2fbdd9e + bd5e36c commit 4ab9d9c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
25 changes: 14 additions & 11 deletions rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,15 @@ if config["enable"]["retrieve"] and (
config["electricity"]["base_network"] == "osm-prebuilt"
):
OSM_VERSION = config["electricity"]["osm-prebuilt-version"]
OSM_COMPONENTS = ["buses", "converters", "lines", "links", "transformers"]
OSM_FILES = [
"buses.csv",
"converters.csv",
"lines.csv",
"links.csv",
"transformers.csv",
]
if OSM_VERSION >= 0.6:
OSM_COMPONENTS.append("map")
OSM_FILES.append("map.html")
OSM_ZENODO_IDS = {
0.1: "12799202",
0.2: "13342577",
Expand All @@ -555,17 +561,14 @@ if config["enable"]["retrieve"] and (
# update rule to use the correct version
rule retrieve_osm_prebuilt:
input:
[
storage(
f"https://zenodo.org/records/{OSM_ZENODO_IDS[OSM_VERSION]}/files/{component}.csv"
**{
file: storage(
f"https://zenodo.org/records/{OSM_ZENODO_IDS[OSM_VERSION]}/files/{file}"
)
for component in OSM_COMPONENTS
],
for file in OSM_FILES
},
output:
[
f"data/osm-prebuilt/{OSM_VERSION}/{component}.csv"
for component in OSM_COMPONENTS
],
**{file: f"data/osm-prebuilt/{OSM_VERSION}/{file}" for file in OSM_FILES},
log:
"logs/retrieve_osm_prebuilt.log",
threads: 1
Expand Down
28 changes: 13 additions & 15 deletions scripts/make_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,24 +542,22 @@ def calculate_weighted_prices(n, label, weighted_prices):
carriers = n.buses.carrier.unique()

for carrier in carriers:
load = (
n.statistics.withdrawal(
groupby=pypsa.statistics.groupers["bus", "carrier"],
aggregate_time=False,
nice_names=False,
bus_carrier=carrier,
)
.groupby(level="bus")
.sum()
.T.fillna(0)
load = n.statistics.withdrawal(
groupby=pypsa.statistics.groupers["bus", "carrier"],
aggregate_time=False,
nice_names=False,
bus_carrier=carrier,
)

price = n.buses_t.marginal_price.loc[:, n.buses.carrier == carrier]
price = price.reindex(columns=load.columns, fill_value=1)
if not load.empty and load.sum().sum() > 0:
load = load.groupby(level="bus").sum().T.fillna(0)

price = n.buses_t.marginal_price.loc[:, n.buses.carrier == carrier]
price = price.reindex(columns=load.columns, fill_value=1)

weighted_prices.loc[carrier, label] = (
load * price
).sum().sum() / load.sum().sum()
weighted_prices.loc[carrier, label] = (
load * price
).sum().sum() / load.sum().sum()

return weighted_prices

Expand Down

0 comments on commit 4ab9d9c

Please sign in to comment.