Skip to content

Commit

Permalink
Integrated on/off toggles for GSDB in config
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbrinkerink committed Dec 9, 2024
1 parent 37cb126 commit 309e2d9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 30 deletions.
14 changes: 10 additions & 4 deletions workflow/scripts/osemosys_global/storage/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pandas as pd
import os
from typing import Optional, Any

from typing import Optional, Any

import logging

Expand Down Expand Up @@ -155,7 +156,8 @@ def main(

# Set residual capacity ('PWR') and residual capacity storage.
res_cap, res_cap_storage = res_capacity_storage(gesdb_data, gesdb_mapping,
res_cap_base, op_life_dict,
res_cap_base, storage_existing,
storage_planned, op_life_dict,
storage_parameters,
GESDB_TECH_MAP, DURATION_TYPE,
BUILD_YEAR, RETIREMENT_YEAR,
Expand Down Expand Up @@ -250,7 +252,9 @@ def main(
file_storage_build_rates = snakemake.input.storage_build_rates
file_default_op_life = snakemake.input.default_op_life
file_gesdb_project_data = snakemake.input.gesdb_project_data
file_gesdb_regional_mapping = snakemake.input.gesdb_regional_mapping
file_gesdb_regional_mapping = snakemake.input.gesdb_regional_mapping
storage_existing = snakemake.params.storage_existing
storage_planned = snakemake.params.storage_planned
start_year = snakemake.params.start_year
end_year = snakemake.params.end_year
region_name = snakemake.params.region_name
Expand Down Expand Up @@ -282,7 +286,9 @@ def main(
file_storage_build_rates = 'resources/data/storage_build_rates.csv'
file_default_op_life = 'resources/data/operational_life.csv'
file_gesdb_project_data = 'resources/data/GESDB_Project_Data.json'
file_gesdb_regional_mapping = 'resources/data/GESDB_region_mapping.csv'
file_gesdb_regional_mapping = 'resources/data/GESDB_region_mapping.csv'
storage_existing = True
storage_planned = True
start_year = 2021
end_year = 2050
region_name = 'GLOBAL'
Expand Down
60 changes: 37 additions & 23 deletions workflow/scripts/osemosys_global/storage/residual_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
def res_capacity_storage(gesdb_data,
gesdb_regional_mapping,
res_cap_base,
storage_existing,
storage_planned,
op_life_dict,
storage_param,
gesdb_tech_map,
Expand Down Expand Up @@ -137,29 +139,41 @@ def res_capacity_storage(gesdb_data,
(residual['YEAR'] == (year - 1))]
new_row.loc[new_row['YEAR'] == (year - 1), 'YEAR'] = year

residual = pd.concat([residual, new_row])
residual = pd.concat([residual, new_row])

if not storage_existing:
residual = residual.loc[residual['YEAR'] > start_year]

if not storage_planned:
residual = residual.loc[residual['YEAR'] == start_year]

if not residual.empty:

residual['REGION'] = region_name
residual = residual.drop_duplicates(subset=['REGION', 'STORAGE', 'YEAR']
, keep = 'last').set_index(['REGION', 'STORAGE', 'YEAR'])

# Pull power rating data for ResidualCapacity.csv
residual_capacity = residual[['rated_power']].reset_index(
drop = False).rename(columns = {'rated_power' : 'VALUE', 'STORAGE' : 'TECHNOLOGY'})

# Convert from kW to GW
residual_capacity['VALUE'] = round(residual_capacity['VALUE'] / 1000000, 4)
residual_capacity['TECHNOLOGY'] = 'PWR' + residual_capacity['TECHNOLOGY']

# Pull storage capacity data for ResidualStorageCapacity.csv
residual_storage_capacity = residual[['storage_capacity']].reset_index(
drop = False).rename(columns = {'storage_capacity' : 'VALUE'})

# Convert from kWh to PJ
residual_storage_capacity['VALUE'] = round(residual_storage_capacity['VALUE'
] / 277777777.77778, 5)

# Combine residual capacity df's.
residual_capacity = pd.concat([res_cap_base, residual_capacity]).reset_index(drop = True)
residual['REGION'] = region_name
residual = residual.drop_duplicates(subset=['REGION', 'STORAGE', 'YEAR']
, keep = 'last').set_index(['REGION', 'STORAGE', 'YEAR'])

# Pull power rating data for ResidualCapacity.csv
residual_capacity = residual[['rated_power']].reset_index(
drop = False).rename(columns = {'rated_power' : 'VALUE', 'STORAGE' : 'TECHNOLOGY'})

# Convert from kW to GW
residual_capacity['VALUE'] = round(residual_capacity['VALUE'] / 1000000, 4)
residual_capacity['TECHNOLOGY'] = 'PWR' + residual_capacity['TECHNOLOGY']

# Pull storage capacity data for ResidualStorageCapacity.csv
residual_storage_capacity = residual[['storage_capacity']].reset_index(
drop = False).rename(columns = {'storage_capacity' : 'VALUE'})

# Convert from kWh to PJ
residual_storage_capacity['VALUE'] = round(residual_storage_capacity['VALUE'
] / 277777777.77778, 5)

# Combine residual capacity df's.
residual_capacity = pd.concat([res_cap_base, residual_capacity]).reset_index(drop = True)

else:
residual_capacity = res_cap_base.copy()
residual_storage_capacity = pd.DataFrame(columns = ['REGION', 'STORAGE', 'YEAR','VALUE'])

return residual_capacity, residual_storage_capacity
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ def set_user_defined_capacity_sto(tech_capacity_sto,
'STORAGE'].str.startswith(tech), 'VALUE'] = df_res_cap_sto_ud_final.loc[
df_res_cap_sto_ud_final['STORAGE'].str.startswith(tech), 'VALUE'] * \
duration / 277.777778

df_res_sto_cap = pd.concat([res_cap_sto_base, df_res_cap_sto_ud_final
if not df_res_cap_sto_ud_final.empty else None])

if not res_cap_sto_base.empty:
df_res_sto_cap = pd.concat([res_cap_sto_base, df_res_cap_sto_ud_final
if not df_res_cap_sto_ud_final.empty else None])
else:
df_res_sto_cap = df_res_cap_sto_ud_final.copy()

# Group residual capacities in case user defined technology entries already exist.
df_res_sto_cap = df_res_sto_cap.groupby(['REGION', 'STORAGE', 'YEAR']
Expand Down

0 comments on commit 309e2d9

Please sign in to comment.