Separate script for industrial production per ct from energy demand
This commit is contained in:
parent
37f36047ca
commit
851142fe0f
18
Snakefile
18
Snakefile
@ -155,15 +155,23 @@ rule build_industry_sector_ratios:
|
||||
script: 'scripts/build_industry_sector_ratios.py'
|
||||
|
||||
|
||||
rule build_industrial_demand_per_country:
|
||||
input:
|
||||
industry_sector_ratios="resources/industry_sector_ratios.csv"
|
||||
rule build_industrial_production_per_country:
|
||||
output:
|
||||
industrial_production_per_country="resources/industrial_production_per_country.csv"
|
||||
threads: 1
|
||||
resources: mem_mb=1000
|
||||
script: 'scripts/build_industrial_production_per_country.py'
|
||||
|
||||
|
||||
rule build_industrial_energy_demand_per_country:
|
||||
input:
|
||||
industry_sector_ratios="resources/industry_sector_ratios.csv",
|
||||
industrial_production_per_country="resources/industrial_production_per_country.csv"
|
||||
output:
|
||||
industrial_demand_per_country="resources/industrial_demand_per_country.csv",
|
||||
industrial_energy_demand_per_country="resources/industrial_energy_demand_per_country.csv"
|
||||
threads: 1
|
||||
resources: mem_mb=1000
|
||||
script: 'scripts/build_industrial_demand_per_country.py'
|
||||
script: 'scripts/build_industrial_energy_demand_per_country.py'
|
||||
|
||||
|
||||
rule build_industrial_demand:
|
||||
|
84
scripts/build_industrial_energy_demand_per_country.py
Normal file
84
scripts/build_industrial_energy_demand_per_country.py
Normal file
@ -0,0 +1,84 @@
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
|
||||
tj_to_ktoe = 0.0238845
|
||||
ktoe_to_twh = 0.01163
|
||||
|
||||
eb_base_dir = "data/eurostat-energy_balances-may_2018_edition"
|
||||
jrc_base_dir = "data/jrc-idees-2015"
|
||||
|
||||
# import EU ratios df as csv
|
||||
industry_sector_ratios=pd.read_csv(snakemake.input.industry_sector_ratios, sep=';', index_col=0)
|
||||
|
||||
#material demand per country and industry (kton/a)
|
||||
countries_production = pd.read_csv(snakemake.input.industrial_production_per_country, index_col=0)
|
||||
|
||||
#Annual energy consumption in Switzerland by sector in 2015 (in TJ)
|
||||
#From: Energieverbrauch in der Industrie und im Dienstleistungssektor, Der Bundesrat
|
||||
#http://www.bfe.admin.ch/themen/00526/00541/00543/index.html?lang=de&dossier_id=00775
|
||||
|
||||
dic_Switzerland ={'Iron and steel': 7889.,
|
||||
'Chemicals Industry': 26871.,
|
||||
'Non-metallic mineral products': 15513.+3820.,
|
||||
'Pulp, paper and printing': 12004.,
|
||||
'Food, beverages and tobacco': 17728.,
|
||||
'Non Ferrous Metals': 3037.,
|
||||
'Transport Equipment': 14993.,
|
||||
'Machinery Equipment': 4724.,
|
||||
'Textiles and leather': 1742.,
|
||||
'Wood and wood products': 0.,
|
||||
'Other Industrial Sectors': 10825.,
|
||||
'current electricity': 53760.}
|
||||
|
||||
|
||||
eb_names={'NO':'Norway', 'AL':'Albania', 'BA':'Bosnia and Herzegovina',
|
||||
'MK':'FYR of Macedonia', 'GE':'Georgia', 'IS':'Iceland',
|
||||
'KO':'Kosovo', 'MD':'Moldova', 'ME':'Montenegro', 'RS':'Serbia',
|
||||
'UA':'Ukraine', 'TR':'Turkey', }
|
||||
|
||||
jrc_names = {"GR" : "EL",
|
||||
"GB" : "UK"}
|
||||
|
||||
#final energy consumption per country and industry (TWh/a)
|
||||
countries_df = countries_production.dot(industry_sector_ratios.T)
|
||||
countries_df*= 0.001 #GWh -> TWh (ktCO2 -> MtCO2)
|
||||
|
||||
|
||||
|
||||
non_EU = ['NO', 'CH', 'ME', 'MK', 'RS', 'BA', 'AL']
|
||||
|
||||
|
||||
# save current electricity consumption
|
||||
for country in countries_df.index:
|
||||
if country in non_EU:
|
||||
if country == 'CH':
|
||||
countries_df.loc[country, 'current electricity']=dic_Switzerland['current electricity']*tj_to_ktoe*ktoe_to_twh
|
||||
else:
|
||||
excel_balances = pd.read_excel('{}/{}.XLSX'.format(eb_base_dir,eb_names[country]),
|
||||
sheet_name='2016', index_col=1,header=0, skiprows=1 ,squeeze=True)
|
||||
|
||||
countries_df.loc[country, 'current electricity'] = excel_balances.loc['Industry', 'Electricity']*ktoe_to_twh
|
||||
|
||||
else:
|
||||
|
||||
excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(jrc_base_dir,jrc_names.get(country,country)),
|
||||
sheet_name='Ind_Summary',index_col=0,header=0,squeeze=True) # the summary sheet
|
||||
|
||||
s_out = excel_out.iloc[27:48,-1]
|
||||
countries_df.loc[country, 'current electricity'] = s_out['Electricity']*ktoe_to_twh
|
||||
print(countries_df.loc[country, 'current electricity'])
|
||||
|
||||
|
||||
|
||||
rename_sectors = {'elec':'electricity',
|
||||
'biomass':'solid biomass',
|
||||
'heat':'low-temperature heat'}
|
||||
|
||||
countries_df.rename(columns=rename_sectors,inplace=True)
|
||||
|
||||
countries_df.index.name = "TWh/a (MtCO2/a)"
|
||||
|
||||
countries_df.to_csv(snakemake.output.industrial_energy_demand_per_country,
|
||||
float_format='%.2f')
|
@ -1,27 +1,14 @@
|
||||
|
||||
|
||||
#%matplotlib inline
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
|
||||
tj_to_ktoe = 0.0238845
|
||||
ktoe_to_twh = 0.01163
|
||||
|
||||
jrc_base_dir = "data/jrc-idees-2015"
|
||||
eb_base_dir = "data/eurostat-energy_balances-may_2018_edition"
|
||||
|
||||
|
||||
|
||||
tj_to_ktoe = 0.0238845
|
||||
|
||||
ktoe_to_twh = 0.01163
|
||||
|
||||
# import EU ratios df as csv
|
||||
df=pd.read_csv(snakemake.input.industry_sector_ratios, sep=';', index_col=0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub_sheet_name_dict = { 'Iron and steel':'ISI',
|
||||
'Chemicals Industry':'CHI',
|
||||
'Non-metallic mineral products': 'NMM',
|
||||
@ -38,15 +25,15 @@ index = ['elec','biomass','methane','hydrogen','heat','naphtha','process emissio
|
||||
|
||||
non_EU = ['NO', 'CH', 'ME', 'MK', 'RS', 'BA', 'AL']
|
||||
|
||||
rename = {"GR" : "EL",
|
||||
jrc_names = {"GR" : "EL",
|
||||
"GB" : "UK"}
|
||||
|
||||
eu28 = ['FR', 'DE', 'GB', 'IT', 'ES', 'PL', 'SE', 'NL', 'BE', 'FI', 'CZ',
|
||||
'DK', 'PT', 'RO', 'AT', 'BG', 'EE', 'GR', 'LV',
|
||||
'HU', 'IE', 'SK', 'LT', 'HR', 'LU', 'SI'] + ['CY','MT']
|
||||
eu28 = ['FR', 'DE', 'GB', 'IT', 'ES', 'PL', 'SE', 'NL', 'BE', 'FI',
|
||||
'DK', 'PT', 'RO', 'AT', 'BG', 'EE', 'GR', 'LV', 'CZ',
|
||||
'HU', 'IE', 'SK', 'LT', 'HR', 'LU', 'SI', 'CY', 'MT']
|
||||
|
||||
|
||||
countries = non_EU + [rename.get(eu,eu) for eu in eu28]
|
||||
countries = non_EU + eu28
|
||||
|
||||
|
||||
sectors = ['Iron and steel','Chemicals Industry','Non-metallic mineral products',
|
||||
@ -68,18 +55,12 @@ sect2sub = {'Iron and steel':['Electric arc','Integrated steelworks'],
|
||||
|
||||
subsectors = [ss for s in sectors for ss in sect2sub[s]]
|
||||
|
||||
#final energy consumption per country and industry (TWh/a)
|
||||
countries_df = pd.DataFrame(index=countries,
|
||||
columns=index,
|
||||
dtype=float)
|
||||
|
||||
#material demand per country and industry (kton/a)
|
||||
countries_demand = pd.DataFrame(index=countries,
|
||||
columns=subsectors,
|
||||
dtype=float)
|
||||
|
||||
|
||||
|
||||
out_dic ={'Electric arc': 'Electric arc',
|
||||
'Integrated steelworks': 'Integrated steelworks',
|
||||
'Basic chemicals': 'Basic chemicals (kt ethylene eq.)',
|
||||
@ -128,10 +109,11 @@ dic_sec_summary = {'Iron and steel': 'Iron and steel',
|
||||
'Other Industrial Sectors': ' Other Industrial Sectors'}
|
||||
|
||||
#countries=['CH']
|
||||
dic_countries={'NO':'Norway', 'AL':'Albania', 'BA':'Bosnia and Herzegovina',
|
||||
eb_names={'NO':'Norway', 'AL':'Albania', 'BA':'Bosnia and Herzegovina',
|
||||
'MK':'FYR of Macedonia', 'GE':'Georgia', 'IS':'Iceland',
|
||||
'KO':'Kosovo', 'MD':'Moldova', 'ME':'Montenegro', 'RS':'Serbia',
|
||||
'UA':'Ukraine', 'TR':'Turkey', }
|
||||
|
||||
dic_sec ={'Iron and steel':'Iron & steel industry',
|
||||
'Chemicals Industry': 'Chemical and Petrochemical industry',
|
||||
'Non-metallic mineral products': 'Non-ferrous metal industry',
|
||||
@ -164,7 +146,6 @@ dic_Switzerland ={'Iron and steel': 7889.,
|
||||
|
||||
dic_sec_position={}
|
||||
for country in countries:
|
||||
countries_df.loc[country] = 0.
|
||||
countries_demand.loc[country] = 0.
|
||||
print(country)
|
||||
for sector in sectors:
|
||||
@ -174,7 +155,7 @@ for country in countries:
|
||||
else:
|
||||
# estimate physical output
|
||||
#energy consumption in the sector and country
|
||||
excel_balances = pd.read_excel('{}/{}.XLSX'.format(eb_base_dir,dic_countries[country]),
|
||||
excel_balances = pd.read_excel('{}/{}.XLSX'.format(eb_base_dir,eb_names[country]),
|
||||
sheet_name='2016', index_col=2,header=0, skiprows=1 ,squeeze=True)
|
||||
e_country = excel_balances.loc[dic_sec[sector], 'Total all products']
|
||||
|
||||
@ -192,62 +173,19 @@ for country in countries:
|
||||
s_out = excel_out.iloc[loc_dic[sector][0]:loc_dic[sector][1],-1]
|
||||
|
||||
for subsector in sect2sub[sector]:
|
||||
output = ratio_country_EU28*s_out[out_dic[subsector]]
|
||||
countries_demand.loc[country,subsector] = output
|
||||
for ind in index:
|
||||
countries_df.loc[country, ind] += float(output*df.loc[ind, subsector]) # kton * MWh = GWh (# kton * tCO2 = ktCO2)
|
||||
countries_demand.loc[country,subsector] = ratio_country_EU28*s_out[out_dic[subsector]]
|
||||
|
||||
else:
|
||||
|
||||
# read the input sheets
|
||||
excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(jrc_base_dir,country), sheet_name=sub_sheet_name_dict[sector],index_col=0,header=0,squeeze=True) # the summary sheet
|
||||
excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(jrc_base_dir,jrc_names.get(country,country)), sheet_name=sub_sheet_name_dict[sector],index_col=0,header=0,squeeze=True) # the summary sheet
|
||||
|
||||
s_out = excel_out.iloc[loc_dic[sector][0]:loc_dic[sector][1],-1]
|
||||
|
||||
for subsector in sect2sub[sector]:
|
||||
output = s_out[out_dic[subsector]]
|
||||
countries_demand.loc[country,subsector] = output
|
||||
for ind in index:
|
||||
countries_df.loc[country, ind] += output*df.loc[ind, subsector] #kton * MWh = GWh (# kton * tCO2 = ktCO2)
|
||||
countries_demand.loc[country,subsector] = s_out[out_dic[subsector]]
|
||||
|
||||
countries_df*= 0.001 #GWh -> TWh (ktCO2 -> MtCO2)
|
||||
countries_demand.index.name = "kton/a"
|
||||
|
||||
# save current electricity consumption
|
||||
for country in countries:
|
||||
if country in non_EU:
|
||||
if country == 'CH':
|
||||
countries_df.loc[country, 'current electricity']=dic_Switzerland['current electricity']*tj_to_ktoe*ktoe_to_twh
|
||||
else:
|
||||
excel_balances = pd.read_excel('{}/{}.XLSX'.format(eb_base_dir,dic_countries[country]),
|
||||
sheet_name='2016', index_col=1,header=0, skiprows=1 ,squeeze=True)
|
||||
|
||||
countries_df.loc[country, 'current electricity'] = excel_balances.loc['Industry', 'Electricity']*ktoe_to_twh
|
||||
|
||||
else:
|
||||
|
||||
excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(jrc_base_dir,country),
|
||||
sheet_name='Ind_Summary',index_col=0,header=0,squeeze=True) # the summary sheet
|
||||
|
||||
s_out = excel_out.iloc[27:48,-1]
|
||||
countries_df.loc[country, 'current electricity'] = s_out['Electricity']*ktoe_to_twh
|
||||
print(countries_df.loc[country, 'current electricity'])
|
||||
|
||||
|
||||
|
||||
# save df as csv
|
||||
for ind in index:
|
||||
countries_df[ind]=countries_df[ind].astype('float')
|
||||
countries_df = countries_df.round(3)
|
||||
|
||||
countries_df.rename(index={value : key for key,value in rename.items()},inplace=True)
|
||||
|
||||
rename_sectors = {'elec':'electricity',
|
||||
'biomass':'solid biomass',
|
||||
'heat':'low-temperature heat'}
|
||||
|
||||
countries_df.rename(columns=rename_sectors,inplace=True)
|
||||
|
||||
countries_df.to_csv(snakemake.output.industrial_energy_demand_per_country,
|
||||
float_format='%.2f')
|
||||
countries_demand.to_csv(snakemake.output.industrial_demand_per_country,
|
||||
countries_demand.to_csv(snakemake.output.industrial_production_per_country,
|
||||
float_format='%.2f')
|
@ -1372,4 +1372,5 @@ sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha']
|
||||
df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out['Physical output (index)'] # unit MWh/t material
|
||||
|
||||
|
||||
df.index.name = "MWh/tMaterial"
|
||||
df.to_csv('resources/industry_sector_ratios.csv', sep=';')
|
||||
|
Loading…
Reference in New Issue
Block a user