Skip to content

Commit

Permalink
added beis generation data
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFrankenQ committed Nov 18, 2023
1 parent e6096b4 commit f05eea4
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 21 deletions.
1 change: 1 addition & 0 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ electricity:
co2limit: 7.75e+7 # 0.05 * 3.1e9*0.5
co2base: 1.487e+9
agg_p_nom_limits: data/agg_p_nom_minmax.csv
include_beis: true # include BEIS data in the system

operational_reserve: # like https://genxproject.github.io/GenX/dev/core/#Reserves
activate: false
Expand Down
2 changes: 2 additions & 0 deletions config/config.validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ electricity:
conventional_carriers: [nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass]
renewable_carriers: [solar, onwind, offwind-ac, offwind-dc, hydro]

include_beis: true # include BEIS data in the system


estimate_renewable_capacities:
year: 2019
Expand Down
1 change: 1 addition & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ electricity:
co2limit: 7.75e+7 # 0.05 * 3.1e9*0.5
co2base: 1.487e+9
agg_p_nom_limits: data/agg_p_nom_minmax.csv
include_beis: true # include BEIS data in the system

operational_reserve: # like https://genxproject.github.io/GenX/dev/core/#Reserves
activate: false
Expand Down
11 changes: 11 additions & 0 deletions rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@


rule prepare_espeni_generation:
params:
elec_config=config["electricity"],
input:
espeni_dataset="data/espeni.csv",
beis_generation_dataset="data/DUKES_5.6.xlxs"
if config["electricity"]["include_beis"]
else [],
output:
espeni_generation=RESOURCES + "espeni_generation.csv",
espeni_interconnectors=RESOURCES + "espeni_interconnectors.csv",
beis_generation=RESOURCES + "beis_generation.csv"
if config["electricity"]["include_beis"]
else [],
log:
LOGS + "prepare_espeni_generation.log",
threads: 1
Expand All @@ -20,6 +28,7 @@ rule prepare_espeni_generation:
"../scripts/prepare_espeni_generation.py"



if config["enable"].get("prepare_links_p_nom", False):

rule prepare_links_p_nom:
Expand Down Expand Up @@ -671,6 +680,8 @@ rule build_electricity_demand_gb:


rule prepare_network:
params:
elec_config=config["electricity"],
input:
RESOURCES + "networks/elec_s{simpl}_eso_ec.nc",
overrides="data/override_component_attrs",
Expand Down
86 changes: 66 additions & 20 deletions scripts/prepare_espeni_generation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This script prepares generation and interconnector data from the ESPENI dataset for a specific year.
This script prepares generation and interconnector data from the ESPENI dataset
for a specific year.
It reads the ESPENI dataset, filters the data for a specific year, and resamples the data on an hourly basis.
The filtered and resampled generation data is saved to the specified output file, while the filtered and resampled
interconnector data is saved to another output file.
It reads the ESPENI dataset, filters the data for a specific year, and resamples the
data on an hourly basis. The filtered and resampled generation data is saved to the
specified output file, while the filtered and resampled interconnector data is saved
to another output file.
Created in November 2023
Expand All @@ -19,6 +21,50 @@

logger = logging.getLogger(__name__)


def get_beis_generation(file, year):

def clean_string(strings):
return [
''
.join(filter(str.isalpha, s))
.lower()
.replace('note', '')
for s in strings
]

logger.info("Gathering BEIS generation (supplied) data.")
df = pd.read_excel(
file,
sheet_name='5.6',
index_col=1,
header=161,
).iloc[:40]

df = df.loc[df[df.columns[0]] == 'All generating companies']
df = df.loc[df.index.dropna(), year]

df.index = clean_string(df.index)
df = df.groupby(df.index).sum().mul(1e-3)

carriers = ['gas', 'solar', 'wind', 'coal', 'hydro', 'biomass', 'nuclear', 'oil', 'total']

beis_clean = pd.Series(0, index=carriers, name='beis')
beis_clean.loc['gas'] = df.loc['gas']

beis_clean.loc[beis_clean.index.intersection(df.index)] = (
df.loc[beis_clean.index.intersection(df.index)]
)

beis_clean.loc['wind'] = df.loc['onshorewind'] + df.loc['offshorewind']
beis_clean.loc['biomass'] = df.loc['thermalrenewables']
beis_clean.loc['hydro'] = df.loc['pumpedstorage'] + df.loc['hydronaturalflow']

beis_clean.loc['total'] = df.loc["totalallgeneratingcompanies"]

return beis_clean


if __name__ == '__main__':
if "snakemake" not in globals():
from _helpers import mock_snakemake
Expand All @@ -33,27 +79,27 @@
generator_mapper = {
'POWER_ELEXM_CCGT_MW': 'CCGT',
'POWER_ELEXM_OCGT_MW': 'OCGT',
'POWER_ELEXM_OIL_MW': 'OIL',
'POWER_ELEXM_COAL_MW': 'COAL',
'POWER_ELEXM_NUCLEAR_MW': 'NUCLEAR',
'POWER_ELEXM_WIND_MW': 'WIND',
'POWER_ELEXM_OIL_MW': 'oil',
'POWER_ELEXM_COAL_MW': 'coal',
'POWER_ELEXM_NUCLEAR_MW': 'nuclear',
'POWER_ELEXM_WIND_MW': 'wind',
'POWER_ELEXM_NPSHYD_MW': 'NPSHYD',
'POWER_ELEXM_BIOMASS_POSTCALC_MW': 'BIOMASS',
'POWER_ELEXM_OTHER_POSTCALC_MW': 'OTHER',
'POWER_NGEM_EMBEDDED_SOLAR_GENERATION_MW': 'SOLAR',
'POWER_NGEM_EMBEDDED_WIND_GENERATION_MW': 'EMBEDDED_WIND',
'POWER_ELEXM_BIOMASS_POSTCALC_MW': 'biomass',
'POWER_ELEXM_OTHER_POSTCALC_MW': 'other',
'POWER_NGEM_EMBEDDED_SOLAR_GENERATION_MW': 'solar',
'POWER_NGEM_EMBEDDED_WIND_GENERATION_MW': 'embedded wind',
}

intercon_mapper = {
'POWER_NGEM_BRITNED_FLOW_MW': 'BRITNED',
'POWER_NGEM_BRITNED_FLOW_MW': 'BritNed',
'POWER_NGEM_EAST_WEST_FLOW_MW': 'EAST_WEST',
'POWER_NGEM_FRENCH_FLOW_MW': 'FRENCH_FLOW',
'POWER_NGEM_MOYLE_FLOW_MW': 'MOYLE',
'POWER_NGEM_FRENCH_FLOW_MW': 'french flow',
'POWER_NGEM_MOYLE_FLOW_MW': 'Moyle',
}

espeni = pd.read_csv(snakemake.input.espeni_dataset, index_col=2, parse_dates=True)

year = '2019'
year = '2019'

generation = (
espeni
Expand All @@ -69,9 +115,9 @@
.resample('H').mean()
)

if snakemake.params['elec_config']['include_beis']:
beis_generation = get_beis_generation(snakemake.input.beis_generation, year)
beis_generation.to_csv(snakemake.output.beis_generation)

generation.to_csv(snakemake.output.generation)
interconnectors.to_csv(snakemake.output.interconnectors)




1 change: 0 additions & 1 deletion scripts/prepare_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,6 @@ def add_modular_nuclear(n):
# On the choice of ramp rates see for instance
# The benefits of nuclear flexibility in power system operations with renewable energy,
# Jenkins et al, 2018

n.generators.loc[idx, ['ramp_limit_up', 'ramp_limit_down']] = 0.05


Expand Down

0 comments on commit f05eea4

Please sign in to comment.