adjust plot_summary to work with myopic, remove update config
This commit is contained in:
parent
18f4eac351
commit
f683a93f08
@ -571,7 +571,8 @@ rule plot_summary:
|
|||||||
costs=SDIR + '/csvs/costs.csv',
|
costs=SDIR + '/csvs/costs.csv',
|
||||||
energy=SDIR + '/csvs/energy.csv',
|
energy=SDIR + '/csvs/energy.csv',
|
||||||
balances=SDIR + '/csvs/supply_energy.csv',
|
balances=SDIR + '/csvs/supply_energy.csv',
|
||||||
clustered_pop_layout="resources/pop_layout_elec_s{simpl}_{clusters}.csv",
|
eurostat=input_eurostat,
|
||||||
|
country_codes='data/Country_codes.csv',
|
||||||
output:
|
output:
|
||||||
costs=SDIR + '/graphs/costs.pdf',
|
costs=SDIR + '/graphs/costs.pdf',
|
||||||
energy=SDIR + '/graphs/energy.pdf',
|
energy=SDIR + '/graphs/energy.pdf',
|
||||||
|
@ -202,7 +202,7 @@ def plot_energy():
|
|||||||
new_index = preferred_order.intersection(df.index).append(df.index.difference(preferred_order))
|
new_index = preferred_order.intersection(df.index).append(df.index.difference(preferred_order))
|
||||||
|
|
||||||
new_columns = df.columns.sort_values()
|
new_columns = df.columns.sort_values()
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(12,8))
|
fig, ax = plt.subplots(figsize=(12,8))
|
||||||
|
|
||||||
print(df.loc[new_index, new_columns])
|
print(df.loc[new_index, new_columns])
|
||||||
@ -363,7 +363,7 @@ def historical_emissions(cts):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def plot_carbon_budget_distribution():
|
def plot_carbon_budget_distribution(input_eurostat):
|
||||||
"""
|
"""
|
||||||
Plot historical carbon emissions in the EU and decarbonization path
|
Plot historical carbon emissions in the EU and decarbonization path
|
||||||
"""
|
"""
|
||||||
@ -385,9 +385,10 @@ def plot_carbon_budget_distribution():
|
|||||||
ax1.set_xlim([1990,snakemake.config['scenario']['planning_horizons'][-1]+1])
|
ax1.set_xlim([1990,snakemake.config['scenario']['planning_horizons'][-1]+1])
|
||||||
|
|
||||||
path_cb = snakemake.config['results_dir'] + snakemake.config['run'] + '/csvs/'
|
path_cb = snakemake.config['results_dir'] + snakemake.config['run'] + '/csvs/'
|
||||||
countries=pd.read_csv(path_cb + 'countries.csv', index_col=1)
|
pop_layout = pd.read_csv(snakemake.input.clustered_pop_layout, index_col=0)
|
||||||
|
countries=pd.read_csv(snakemake.input.country_codes, index_col=1)
|
||||||
cts=countries.index.to_list()
|
cts=countries.index.to_list()
|
||||||
e_1990 = co2_emissions_year(cts, opts, year=1990)
|
e_1990 = co2_emissions_year(cts, input_eurostat, opts, year=1990)
|
||||||
CO2_CAP=pd.read_csv(path_cb + 'carbon_budget_distribution.csv',
|
CO2_CAP=pd.read_csv(path_cb + 'carbon_budget_distribution.csv',
|
||||||
index_col=0)
|
index_col=0)
|
||||||
|
|
||||||
@ -438,8 +439,7 @@ if __name__ == "__main__":
|
|||||||
if 'snakemake' not in globals():
|
if 'snakemake' not in globals():
|
||||||
from helper import mock_snakemake
|
from helper import mock_snakemake
|
||||||
snakemake = mock_snakemake('plot_summary')
|
snakemake = mock_snakemake('plot_summary')
|
||||||
|
|
||||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
|
||||||
|
|
||||||
n_header = 4
|
n_header = 4
|
||||||
|
|
||||||
@ -453,4 +453,4 @@ if __name__ == "__main__":
|
|||||||
opts=sector_opts.split('-')
|
opts=sector_opts.split('-')
|
||||||
for o in opts:
|
for o in opts:
|
||||||
if "cb" in o:
|
if "cb" in o:
|
||||||
plot_carbon_budget_distribution()
|
plot_carbon_budget_distribution(snakemake.input.eurostat)
|
||||||
|
@ -158,18 +158,16 @@ def get(item, investment_year=None):
|
|||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
def co2_emissions_year(opts, year):
|
def co2_emissions_year(countries, input_eurostat, opts, year):
|
||||||
"""
|
"""
|
||||||
Calculate CO2 emissions in one specific year (e.g. 1990 or 2018).
|
Calculate CO2 emissions in one specific year (e.g. 1990 or 2018).
|
||||||
"""
|
"""
|
||||||
emissions_scope = snakemake.config["energy"]["emissions"]
|
emissions_scope = snakemake.config["energy"]["emissions"]
|
||||||
eea_co2 = build_eea_co2(snakemake.input.co2, year, emissions_scope)
|
eea_co2 = build_eea_co2(snakemake.input.co2, year, emissions_scope)
|
||||||
input_eurostat = snakemake.input.eurostat
|
|
||||||
|
|
||||||
# TODO: read Eurostat data from year > 2014
|
# TODO: read Eurostat data from year > 2014
|
||||||
# this only affects the estimation of CO2 emissions for BA, RS, AL, ME, MK
|
# this only affects the estimation of CO2 emissions for BA, RS, AL, ME, MK
|
||||||
report_year = snakemake.config["energy"]["eurostat_report_year"]
|
report_year = snakemake.config["energy"]["eurostat_report_year"]
|
||||||
countries = pd.Index(pop_layout.ct.unique())
|
|
||||||
if year > 2014:
|
if year > 2014:
|
||||||
eurostat_co2 = build_eurostat_co2(input_eurostat, countries, report_year, year=2014)
|
eurostat_co2 = build_eurostat_co2(input_eurostat, countries, report_year, year=2014)
|
||||||
else:
|
else:
|
||||||
@ -205,10 +203,10 @@ def build_carbon_budget(o, fn):
|
|||||||
|
|
||||||
countries = n.buses.country.dropna().unique()
|
countries = n.buses.country.dropna().unique()
|
||||||
|
|
||||||
e_1990 = co2_emissions_year( opts, year=1990)
|
e_1990 = co2_emissions_year(countries, snakemake.input.eurostat, opts, year=1990)
|
||||||
|
|
||||||
#emissions at the beginning of the path (last year available 2018)
|
#emissions at the beginning of the path (last year available 2018)
|
||||||
e_0 = co2_emissions_year(opts, year=2018)
|
e_0 = co2_emissions_year(countries, snakemake.input.eurostat, opts, year=2018)
|
||||||
|
|
||||||
planning_horizons = snakemake.config['scenario']['planning_horizons']
|
planning_horizons = snakemake.config['scenario']['planning_horizons']
|
||||||
t_0 = planning_horizons[0]
|
t_0 = planning_horizons[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user