From 5038faa020af13f74ef0377767d9e7478ae33113 Mon Sep 17 00:00:00 2001 From: martavp <30744159+martavp@users.noreply.github.com> Date: Wed, 4 Dec 2019 16:37:50 +0100 Subject: [PATCH 1/3] Delete build_biomass_potentials.py describe biomass --- scripts/build_biomass_potentials.py | 54 ----------------------------- 1 file changed, 54 deletions(-) delete mode 100644 scripts/build_biomass_potentials.py diff --git a/scripts/build_biomass_potentials.py b/scripts/build_biomass_potentials.py deleted file mode 100644 index 566c24dc..00000000 --- a/scripts/build_biomass_potentials.py +++ /dev/null @@ -1,54 +0,0 @@ - -import pandas as pd - -idx = pd.IndexSlice - -def build_biomass_potentials(): - - #delete empty column C from this sheet first before reading it in - df = pd.read_excel(snakemake.input.jrc_potentials, - "Potentials (PJ)", - index_col=[0,1]) - - df.rename(columns={"Unnamed: 18":"Municipal waste"},inplace=True) - df.drop(columns="Total",inplace=True) - df.replace("-",0.,inplace=True) - - df_dict = {} - - for i in range(36): - df_dict[df.iloc[i*16,1]] = df.iloc[1+i*16:(i+1)*16].astype(float) - - df_new = pd.concat(df_dict) - - us_type = pd.Series(index=df_new.columns) - us_type.iloc[0:7] = "not included" - us_type.iloc[7:8] = "biogas" - us_type.iloc[8:9] = "solid biomass" - us_type.iloc[9:11] = "not included" - us_type.iloc[11:16] = "solid biomass" - us_type.iloc[16:17] = "biogas" - - - #convert from PJ to MWh - biomass_potentials = df_new.loc[idx[:,snakemake.config['biomass']['year'],snakemake.config['biomass']['scenario']],:].groupby(us_type,axis=1).sum().groupby(level=0).sum().rename({"UK" : "GB", "BH" : "BA"})/3.6*1e6 - biomass_potentials.to_csv(snakemake.output.biomass_potentials) - - - -if __name__ == "__main__": - - - # Detect running outside of snakemake and mock snakemake for testing - if 'snakemake' not in globals(): - from vresutils import Dict - import yaml - snakemake = Dict() - snakemake.input = Dict() - snakemake.input['jrc_potentials'] = "data/biomass/JRC Biomass Potentials.xlsx" - snakemake.output = Dict() - snakemake.output['biomass_potentials'] = 'data/biomass_potentials.csv' - with open('config.yaml') as f: - snakemake.config = yaml.load(f) - - build_biomass_potentials() From f6d407cc24a26e12817f27964ec952e505542211 Mon Sep 17 00:00:00 2001 From: martavp <30744159+martavp@users.noreply.github.com> Date: Wed, 4 Dec 2019 16:38:19 +0100 Subject: [PATCH 2/3] Add files via upload describe biomass --- scripts/build_biomass_potentials.py | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 scripts/build_biomass_potentials.py diff --git a/scripts/build_biomass_potentials.py b/scripts/build_biomass_potentials.py new file mode 100644 index 00000000..db478778 --- /dev/null +++ b/scripts/build_biomass_potentials.py @@ -0,0 +1,64 @@ + +import pandas as pd + +idx = pd.IndexSlice + +def build_biomass_potentials(): + + #delete empty column C from this sheet first before reading it in + df = pd.read_excel(snakemake.input.jrc_potentials, + "Potentials (PJ)", + index_col=[0,1]) + + df.rename(columns={"Unnamed: 18":"Municipal waste"},inplace=True) + df.drop(columns="Total",inplace=True) + df.replace("-",0.,inplace=True) + + df_dict = {} + + for i in range(36): + df_dict[df.iloc[i*16,1]] = df.iloc[1+i*16:(i+1)*16].astype(float) + + df_new = pd.concat(df_dict) + + # solid biomass includes: Primary agricultural residues (MINBIOAGRW1), + # Forestry energy residue (MINBIOFRSF1), + # Secondary forestry residues (MINBIOWOOW1), + # Secondary Forestry residues – sawdust (MINBIOWOO1a)', + # Forestry residues from landscape care biomass (MINBIOFRSF1a), + # Municipal waste (MINBIOMUN1)', + + # biogas includes : Manure biomass potential (MINBIOGAS1), + # Sludge biomass (MINBIOSLU1) + + us_type = pd.Series(index=df_new.columns) + us_type.iloc[0:7] = "not included" + us_type.iloc[7:8] = "biogas" + us_type.iloc[8:9] = "solid biomass" + us_type.iloc[9:11] = "not included" + us_type.iloc[11:16] = "solid biomass" + us_type.iloc[16:17] = "biogas" + + + #convert from PJ to MWh + biomass_potentials = df_new.loc[idx[:,snakemake.config['biomass']['year'],snakemake.config['biomass']['scenario']],:].groupby(us_type,axis=1).sum().groupby(level=0).sum().rename({"UK" : "GB", "BH" : "BA"})/3.6*1e6 + biomass_potentials.to_csv(snakemake.output.biomass_potentials) + + + +if __name__ == "__main__": + + + # Detect running outside of snakemake and mock snakemake for testing + if 'snakemake' not in globals(): + from vresutils import Dict + import yaml + snakemake = Dict() + snakemake.input = Dict() + snakemake.input['jrc_potentials'] = "data/biomass/JRC Biomass Potentials.xlsx" + snakemake.output = Dict() + snakemake.output['biomass_potentials'] = 'data/biomass_potentials.csv' + with open('config.yaml') as f: + snakemake.config = yaml.load(f) + + build_biomass_potentials() From 36a57222f7f9626c831668ae019d996abf1c11b1 Mon Sep 17 00:00:00 2001 From: lisazeyen <35347358+lisazeyen@users.noreply.github.com> Date: Fri, 24 Jan 2020 15:31:17 +0100 Subject: [PATCH 3/3] Clip p min pu (#50) * changes for retrofitting * changed Snakefile to work with new pypsa-eur version, change solve_network.py to clip also n.generators_t.p_min_pu * removed retrofitting data files --- Snakefile | 2 +- scripts/solve_network.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Snakefile b/Snakefile index f400b794..0ab03d3f 100644 --- a/Snakefile +++ b/Snakefile @@ -172,7 +172,7 @@ rule build_industrial_demand: rule prepare_sector_network: input: - network=pypsaeur('networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc'), + network=pypsaeur('networks/{network}_s{simpl}_{clusters}_ec_lv{lv}_{opts}.nc'), energy_totals_name='data/energy_totals.csv', co2_totals_name='data/co2_totals.csv', transport_name='data/transport_data.csv', diff --git a/scripts/solve_network.py b/scripts/solve_network.py index cf1a1b2b..0267fdfb 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -59,7 +59,7 @@ def prepare_network(n, solve_opts=None): solve_opts = snakemake.config['solving']['options'] if 'clip_p_max_pu' in solve_opts: - for df in (n.generators_t.p_max_pu, n.storage_units_t.inflow): + for df in (n.generators_t.p_max_pu, n.generators_t.p_min_pu, n.storage_units_t.inflow): df.where(df>solve_opts['clip_p_max_pu'], other=0., inplace=True) if solve_opts.get('load_shedding'):