diff --git a/Snakefile b/Snakefile index eaae1e74..f586a2a7 100644 --- a/Snakefile +++ b/Snakefile @@ -138,6 +138,25 @@ rule build_biomass_potentials: resources: mem_mb=1000 script: 'scripts/build_biomass_potentials.py' + +rule build_industry_sector_ratios: + output: + industry_sector_ratios="resources/industry_sector_ratios.csv" + threads: 1 + resources: mem_mb=1000 + script: 'scripts/build_industry_sector_ratios.py' + + +rule build_industrial_demand_per_country: + input: + industry_sector_ratios="resources/industry_sector_ratios.csv" + output: + industrial_demand_per_country="resources/industrial_demand_per_country.csv" + threads: 1 + resources: mem_mb=1000 + script: 'scripts/build_industrial_demand_per_country.py' + + rule build_industrial_demand: input: clustered_pop_layout="resources/pop_layout_{network}_s{simpl}_{clusters}.csv" diff --git a/scripts/build_industrial_demand_per_country.py b/scripts/build_industrial_demand_per_country.py new file mode 100644 index 00000000..70ca2cc7 --- /dev/null +++ b/scripts/build_industrial_demand_per_country.py @@ -0,0 +1,238 @@ + + +#%matplotlib inline +import pandas as pd +import numpy as np + + + +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('resources/industry_sector_ratios.csv', sep=';', index_col=0) + + + + + +sub_sheet_name_dict = { 'Iron and steel':'ISI', + 'Chemicals Industry':'CHI', + 'Non-metallic mineral products': 'NMM', + 'Pulp, paper and printing': 'PPA', + 'Food, beverages and tobacco': 'FBT', + 'Non Ferrous Metals' : 'NFM', + 'Transport Equipment': 'TRE', + 'Machinery Equipment': 'MAE', + 'Textiles and leather':'TEL', + 'Wood and wood products': 'WWP', + 'Other Industrial Sectors': 'OIS'} + +index = ['elec','biomass','methane','hydrogen','heat','naphtha','process emission'] + +countries_df = pd.DataFrame(columns=index) #data frame final energy consumption per country and source + + +non_EU = ['NO', 'CH', 'ME', 'MK', 'RS', 'BA', 'AL'] + +rename = {"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'] + + +countries = non_EU + [rename.get(eu,eu) for eu in eu28[:-2]] + + +sectors = ['Iron and steel','Chemicals Industry','Non-metallic mineral products', + 'Pulp, paper and printing', 'Food, beverages and tobacco', 'Non Ferrous Metals', + 'Transport Equipment', 'Machinery Equipment', 'Textiles and leather', + 'Wood and wood products', 'Other Industrial Sectors'] + +sect2sub = {'Iron and steel':['Electric arc','Integrated steelworks'], + 'Chemicals Industry': ['Basic chemicals', 'Other chemicals', 'Pharmaceutical products etc.'], + 'Non-metallic mineral products': ['Cement','Ceramics & other NMM','Glass production'], + 'Pulp, paper and printing': ['Pulp production','Paper production','Printing and media reproduction'], + 'Food, beverages and tobacco': ['Food, beverages and tobacco'], + 'Non Ferrous Metals': ['Alumina production', 'Aluminium - primary production', 'Aluminium - secondary production', 'Other non-ferrous metals'], + 'Transport Equipment': ['Transport Equipment'], + 'Machinery Equipment': ['Machinery Equipment'], + 'Textiles and leather': ['Textiles and leather'], + 'Wood and wood products' :['Wood and wood products'], + 'Other Industrial Sectors':['Other Industrial Sectors']} + +out_dic ={'Electric arc': 'Electric arc', + 'Integrated steelworks': 'Integrated steelworks', + 'Basic chemicals': 'Basic chemicals (kt ethylene eq.)', + 'Other chemicals':'Other chemicals (kt ethylene eq.)', + 'Pharmaceutical products etc.':'Pharmaceutical products etc. (kt ethylene eq.)', + 'Cement':'Cement (kt)', + 'Ceramics & other NMM':'Ceramics & other NMM (kt bricks eq.)', + 'Glass production':'Glass production (kt)', + 'Pulp production':'Pulp production (kt)', + 'Paper production':'Paper production (kt)', + 'Printing and media reproduction':'Printing and media reproduction (kt paper eq.)', + 'Food, beverages and tobacco': 'Physical output (index)', + 'Alumina production':'Alumina production (kt)', + 'Aluminium - primary production': 'Aluminium - primary production', + 'Aluminium - secondary production': 'Aluminium - secondary production', + 'Other non-ferrous metals' : 'Other non-ferrous metals (kt lead eq.)', + 'Transport Equipment': 'Physical output (index)', + 'Machinery Equipment': 'Physical output (index)', + 'Textiles and leather': 'Physical output (index)', + 'Wood and wood products': 'Physical output (index)', + 'Other Industrial Sectors': 'Physical output (index)'} + +loc_dic={'Iron and steel':[5,8], + 'Chemicals Industry': [7,11], + 'Non-metallic mineral products': [6,10], + 'Pulp, paper and printing': [7,11], + 'Food, beverages and tobacco': [2,6], + 'Non Ferrous Metals': [9,14], + 'Transport Equipment': [3,5], + 'Machinery Equipment': [3,5], + 'Textiles and leather': [3,5], + 'Wood and wood products': [3,5], + 'Other Industrial Sectors': [3,5]} + +# In the summary sheet (IDEES database) some names include a white space +dic_sec_summary = {'Iron and steel': 'Iron and steel', + 'Chemicals Industry': 'Chemicals Industry', + 'Non-metallic mineral products': 'Non-metallic mineral products', + 'Pulp, paper and printing': 'Pulp, paper and printing', + 'Food, beverages and tobacco': ' Food, beverages and tobacco', + 'Non Ferrous Metals': 'Non Ferrous Metals', + 'Transport Equipment': ' Transport Equipment', + 'Machinery Equipment': ' Machinery Equipment', + 'Textiles and leather': ' Textiles and leather', + 'Wood and wood products': ' Wood and wood products', + 'Other Industrial Sectors': ' Other Industrial Sectors'} + +#countries=['CH'] +dic_countries={'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', + 'Pulp, paper and printing': 'Paper, Pulp and Print', + 'Food, beverages and tobacco': 'Food and Tabacco', + 'Non Ferrous Metals': 'Non-metallic Minerals (Glass, pottery & building mat. Industry)', + 'Transport Equipment': 'Transport Equipment', + 'Machinery Equipment': 'Machinery', + 'Textiles and leather': 'Textile and Leather', + 'Wood and wood products': 'Wood and Wood Products', + 'Other Industrial Sectors': 'Non-specified (Industry)'} + # Mining and Quarrying, Construction + +#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.} + +dic_sec_position={} +for country in countries: + countries_df.loc[country] = 0 + print (country) + for sector in sectors: + if country in non_EU: + if country == 'CH': + e_country = dic_Switzerland[sector]*tj_to_ktoe + else: + # estimate physical output + #energy consumption in the sector and country + excel_balances = pd.read_excel('{}/{}.XLSX'.format(eb_base_dir,dic_countries[country]), + sheet_name='2016', index_col=2,header=0, skiprows=1 ,squeeze=True) + e_country = excel_balances.loc[dic_sec[sector], 'Total all products'] + + #energy consumption in the sector and EU28 + excel_sum_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_EU28.xlsx'.format(jrc_base_dir), + sheet_name='Ind_Summary', index_col=0,header=0,squeeze=True) # the summary sheet + s_sum_out = excel_sum_out.iloc[49:76,-1] + e_EU28 = s_sum_out[dic_sec_summary[sector]] + + ratio_country_EU28=e_country/e_EU28 + + excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_EU28.xlsx'.format(jrc_base_dir), + 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 = ratio_country_EU28*s_out[out_dic[subsector]] + + for ind in index: + countries_df.loc[country, ind] += float(output*df.loc[ind, subsector]) # kton * MWh = GWh (# kton * tCO2 = ktCO2) + + 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 + + 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]] + for ind in index: + countries_df.loc[country, ind] += output*df.loc[ind, subsector] #kton * MWh = GWh (# kton * tCO2 = ktCO2) + +countries_df*= 0.001 #GWh -> TWh (ktCO2 -> MtCO2) + +# 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('resources/industrial_demand_per_country.csv', + float_format='%.2f') diff --git a/scripts/build_industry_sector_ratios.py b/scripts/build_industry_sector_ratios.py new file mode 100644 index 00000000..ba14c3f9 --- /dev/null +++ b/scripts/build_industry_sector_ratios.py @@ -0,0 +1,1372 @@ + + +import pandas as pd +import numpy as np + +base_dir = "data/jrc-idees-2015" + +# year for wich data is retrieved +year = 2015 +year = year-2016 + +conv_factor=11.630 #ktoe/kton -> MWh/ton + +country = 'EU28' + + +sub_sheet_name_dict = { 'Iron and steel':'ISI', + 'Chemicals Industry':'CHI', + 'Non-metallic mineral products': 'NMM', + 'Pulp, paper and printing': 'PPA', + 'Food, beverages and tobacco': 'FBT', + 'Non Ferrous Metals' : 'NFM', + 'Transport Equipment': 'TRE', + 'Machinery Equipment': 'MAE', + 'Textiles and leather':'TEL', + 'Wood and wood products': 'WWP', + 'Other Industrial Sectors': 'OIS'} + +index = ['elec','biomass','methane','hydrogen','heat','naphtha','process emission'] + +df = pd.DataFrame(index=index) + + +## Iron and steel +# +#> There are two different approaches to produce iron and steel: i.e., integrated steelworks and electric arc. +# +#> Electric arc approach has higher efficiency and relies more on electricity. +# +#> We assume that integrated steelworks will be replaced by electric arc entirely. + +sector = 'Iron and steel' + +# read the input sheets +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) # the summary sheet + +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) # the final energy consumption sheet + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) # the used energy sheet + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) # the emission sheet + +### Electric arc + +sector = 'Electric arc' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[51:57,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec',sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat',sector] += s_fec['Low enthalpy heat'] + +#### Steel: Smelters + +subsector = 'Steel: Smelters' + +# read the corresponding lines +s_fec = excel_fec.iloc[61:67,year] + +s_ued = excel_ued.iloc[61:67,year] + +assert s_fec.index[0] == subsector + +# Efficiency changes due to transforming all the smelters into methane +eff_met=s_ued['Natural gas (incl. biogas)']/s_fec['Natural gas (incl. biogas)'] + +df.loc['methane', sector] += s_ued[subsector]/eff_met + +#### Steel: Electric arc + +subsector = 'Steel: Electric arc' + +# read the corresponding lines +s_fec = excel_fec.iloc[67:68,year] + +assert s_fec.index[0] == subsector + +# only electricity +df.loc['elec',sector] += s_fec[subsector] + +#### Steel: Furnaces, Refining and Rolling +#> assume fully electrified +# +#> other processes are scaled by the used energy + +subsector = 'Steel: Furnaces, Refining and Rolling' + +# read the corresponding lines +s_fec = excel_fec.iloc[68:75,year] + +s_ued = excel_ued.iloc[68:75,year] + +assert s_fec.index[0] == subsector + +# this process can be electrified +eff = s_ued['Steel: Furnaces, Refining and Rolling - Electric']/s_fec['Steel: Furnaces, Refining and Rolling - Electric'] + +df.loc['elec',sector] += s_ued[subsector]/eff + +#### Steel: Products finishing +#> assume fully electrified + +subsector = 'Steel: Products finishing' + +# read the corresponding lines +s_fec = excel_fec.iloc[75:92,year] + +s_ued = excel_ued.iloc[75:92,year] + +assert s_fec.index[0] == subsector + +# this process can be electrified +eff = s_ued['Steel: Products finishing - Electric']/s_fec['Steel: Products finishing - Electric'] + +df.loc['elec',sector] += s_ued[subsector]/eff + +#### Process emissions (per physical output) + +s_emi = excel_emi.iloc[51:93,year] + +assert s_emi.index[0] == sector + +s_out = excel_out.iloc[7:8,year] + +assert sector in str(s_out.index) + +df.loc['process emission',sector] = s_emi['Process emissions']/s_out[sector] # unit tCO2/t material + +# final energy consumption per t +df.loc[['elec','heat','methane'],sector] = df.loc[['elec','heat','methane'],sector]*conv_factor/s_out[sector] # unit MWh/t material + + + +## Integrated steelworks is converted to Electric arc +# +#> Electric arc uses scrap metal and Direct Reduced Iron +# +#> We assume that when substituting Integrated Steelworks by Electric arc furnaces. +#> 50% of Integrated steelworks is substituted by scrap metal + electric furnaces +#> 50% of Integrated steelworks is substituted by Direct Reduce Iron (with Hydrogen) + electric furnaces + +df['Integrated steelworks']=df['Electric arc'] + +# adding the Hydrogen necessary for the Direct Reduction of Iron. consumption 1.7 MWh H2 /ton steel +#(0.5 becuase only half of the steel requires DRI, the rest is scrap metal) +df.loc['hydrogen', 'Integrated steelworks'] =1.7 * 0.5 + + +## Chemicals Industry + +sector = 'Chemicals Industry' + +# read the input sheets +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) # the summary sheet + +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) # the final energy consumption sheet + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) # the used energy sheet + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) # the emission sheet + +### Basic chemicals + +sector = 'Basic chemicals' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:9,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec',sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat',sector] += s_fec['Low enthalpy heat'] + +#### Chemicals: Feedstock (energy used as raw material) +#> There are Solids, Refinery gas, LPG, Diesel oil, Residual fuel oil, Other liquids, Naphtha, Natural gas for feedstock. +# +#> Naphta represents 47%, methane 17%. LPG (18%) solids, refinery gas, diesel oil, residual fuel oils and other liquids are asimilated to Napthta +# +#> Following Lechtenbohmer 2016, the 85 TWh/year of methane for the ammonia industry are substited by hydrogen. + +subsector = 'Chemicals: Feedstock (energy used as raw material)' + +# read the corresponding lines +s_fec = excel_fec.iloc[13:22,year] + +assert s_fec.index[0] == subsector + +# naphtha +df.loc['naphtha',sector] += s_fec['Naphtha'] + +# natural gas +# 85 TWh/year of methane for the ammonia industry are substituted by hydrogen +df.loc['methane',sector] += s_fec['Natural gas'] - 85000/conv_factor +df.loc['hydrogen',sector] += 85000/conv_factor +# 1 ktoe = 11630 MWh + +# LPG and other feedstock materials are assimilated to naphtha since they will be produced trough Fischer-Tropsh process +df.loc['naphtha',sector] += (s_fec['Solids'] + s_fec['Refinery gas'] + s_fec['LPG'] + s_fec['Diesel oil'] + + s_fec['Residual fuel oil'] + s_fec['Other liquids']) + +#### Chemicals: Steam processing +#> All the final energy consumption in the Stem processing is converted to biomass. +# +#> The current efficiency of biomass is assumed in the conversion. + +subsector = 'Chemicals: Steam processing' + +# read the corresponding lines +s_fec = excel_fec.iloc[22:33,year] + +s_ued = excel_ued.iloc[22:33,year] + +assert s_fec.index[0] == subsector + +# efficiency of biomass +eff_bio = s_ued['Biomass']/s_fec['Biomass'] + +# replace all fec by biomass +df.loc['biomass',sector] += s_ued[subsector]/eff_bio + +#### Chemicals: Furnaces +#> assume fully electrified + +subsector = 'Chemicals: Furnaces' + +# read the corresponding lines +s_fec = excel_fec.iloc[33:41,year] + +s_ued = excel_ued.iloc[33:41,year] + +assert s_fec.index[0] == subsector + +#efficiency of electrification +eff_elec = s_ued['Chemicals: Furnaces - Electric']/s_fec['Chemicals: Furnaces - Electric'] + +df.loc['elec',sector] += s_ued[subsector]/eff_elec + +#### Chemicals: Process cooling +#> assume fully electrified + +subsector = 'Chemicals: Process cooling' + +# read the corresponding lines +s_fec = excel_fec.iloc[41:55,year] + +s_ued = excel_ued.iloc[41:55,year] + +assert s_fec.index[0] == subsector + +eff_elec = s_ued['Chemicals: Process cooling - Electric']/s_fec['Chemicals: Process cooling - Electric'] + +df.loc['elec',sector] += s_ued[subsector]/eff_elec + +#### Chemicals: Generic electric process + +subsector = 'Chemicals: Generic electric process' + +# read the corresponding lines +s_fec = excel_fec.iloc[55:56,year] + +assert s_fec.index[0] == subsector + +df.loc['elec',sector] += s_fec[subsector] + +#### Process emissions + +s_emi = excel_emi.iloc[3:57,year] + +assert s_emi.index[0] == sector + +s_out = excel_out.iloc[8:9,year] + +assert sector in str(s_out.index) + +df.loc['process emission',sector] += s_emi['Process emissions']/s_out.values # unit tCO2/t material + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out.values# unit MWh/t material +# 1 ktoe = 11630 MWh + +### Other chemicals + +sector = 'Other chemicals' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[58:64,year] + +# check the position +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec',sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat',sector] += s_fec['Low enthalpy heat'] + +#### Chemicals: High enthalpy heat processing +#> assume fully electrified + +subsector = 'Chemicals: High enthalpy heat processing' + +# read the corresponding lines +s_fec = excel_fec.iloc[68:81,year] + +s_ued = excel_ued.iloc[68:81,year] + +assert s_fec.index[0] == subsector + +eff_elec = s_ued['High enthalpy heat processing - Electric (microwave)']/s_fec['High enthalpy heat processing - Electric (microwave)'] + +df.loc['elec',sector] += s_ued[subsector]/eff_elec + +#### Chemicals: Furnaces +#> assume fully electrified + +subsector = 'Chemicals: Furnaces' + +# read the corresponding lines +s_fec = excel_fec.iloc[81:89,year] + +s_ued = excel_ued.iloc[81:89,year] + +assert s_fec.index[0] == subsector + +eff_elec = s_ued['Chemicals: Furnaces - Electric']/s_fec['Chemicals: Furnaces - Electric'] + +df.loc['elec',sector] += s_ued[subsector]/eff_elec + +#### Chemicals: Process cooling +#> assume fully electrified + +subsector = 'Chemicals: Process cooling' + +# read the corresponding lines +s_fec = excel_fec.iloc[89:103,year] + +s_ued = excel_ued.iloc[89:103,year] + +assert s_fec.index[0] == subsector + +eff = s_ued['Chemicals: Process cooling - Electric']/s_fec['Chemicals: Process cooling - Electric'] + +df.loc['elec',sector] += s_ued[subsector]/eff + +#### Chemicals: Generic electric process + +subsector = 'Chemicals: Generic electric process' + +# read the corresponding lines +s_fec = excel_fec.iloc[103:104,year] + +assert s_fec.index[0] == subsector + +df.loc['elec',sector] += s_fec[subsector] + +#### Process emissions + +s_emi = excel_emi.iloc[58:105,year] + +assert s_emi.index[0] == sector + +s_out = excel_out.iloc[9:10,year] + +assert sector in str(s_out.index) + +df.loc['process emission',sector] += s_emi['Process emissions']/s_out.values # unit tCO2/t material + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*11.630/s_out.values # unit MWh/t material +# 1 ktoe = 11630 MWh + +### Pharmaceutical products etc. + +sector = 'Pharmaceutical products etc.' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[106:112,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec',sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat',sector] += s_fec['Low enthalpy heat'] + +#### Chemicals: High enthalpy heat processing +#> assume fully electrified + +subsector = 'Chemicals: High enthalpy heat processing' + +# read the corresponding lines +s_fec = excel_fec.iloc[116:129,year] + +s_ued = excel_ued.iloc[116:129,year] + +assert s_fec.index[0] == subsector + +eff_elec = s_ued['High enthalpy heat processing - Electric (microwave)']/s_fec['High enthalpy heat processing - Electric (microwave)'] + +df.loc['elec',sector] += s_ued[subsector]/eff_elec + +#### Chemicals: Furnaces +#> assume fully electrified + +subsector = 'Chemicals: Furnaces' + +# read the corresponding lines +s_fec = excel_fec.iloc[129:137,year] + +s_ued = excel_ued.iloc[129:137,year] + +assert s_fec.index[0] == subsector + +eff = s_ued['Chemicals: Furnaces - Electric']/s_fec['Chemicals: Furnaces - Electric'] + +df.loc['elec',sector] += s_ued[subsector]/eff + +#### Chemicals: Process cooling +#> assume fully electrified + +subsector = 'Chemicals: Process cooling' + +# read the corresponding lines +s_fec = excel_fec.iloc[137:151,year] + +s_ued = excel_ued.iloc[137:151,year] + +assert s_fec.index[0] == subsector + +eff_elec = s_ued['Chemicals: Process cooling - Electric']/s_fec['Chemicals: Process cooling - Electric'] + +df.loc['elec',sector] += s_ued[subsector]/eff_elec + +#### Chemicals: Generic electric process + +subsector = 'Chemicals: Generic electric process' + +# read the corresponding lines +s_fec = excel_fec.iloc[151:152,year] + +assert s_fec.index[0] == subsector + +df.loc['elec',sector] += s_fec[subsector] + +# read the corresponding lines +s_out = excel_out.iloc[10:11,year] + +# check the position +assert sector in str(s_out.index) + +df.loc['process emission',sector] += 0 # unit tCO2/t material + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat', 'naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*11.630/s_out.values # unit MWh/t material +# 1 ktoe = 11630 MWh + +## Non-metallic mineral products +# +#> This includes cement, ceramic and glass production. +# +#> This sector includes process-emissions related to the fabrication of clinker. + +sector = 'Non-metallic mineral products' + +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) + +### Cement +# +#> This sector has process-emissions. +# +#> Includes three subcategories: (a) Grinding, milling of raw material, (b) Pre-heating and pre-calcination, (c) clinker production (kilns), (d) Grinding, packaging. (b)+(c) represent 94% of fec. So (a) is joined to (b) and (d) is joined to (c). +# +#> Temperatures above 1400C are required for procesing limestone and sand into clinker. +# +#> Everything (except current electricity and heat consumption) is transformed into biomass + +sector = 'Cement' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:25,year] + +s_ued = excel_ued.iloc[3:25,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec',sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat',sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to biomass +eff_bio=s_ued['Biomass']/s_fec['Biomass'] + +df.loc['biomass', sector] += s_ued[['Cement: Grinding, milling of raw material', 'Cement: Pre-heating and pre-calcination']].sum()/eff_bio + +#### Cement: Clinker production (kilns) + +subsector = 'Cement: Clinker production (kilns)' + +# read the corresponding lines +s_fec = excel_fec.iloc[34:43,year] + +s_ued = excel_ued.iloc[34:43,year] + +assert s_fec.index[0] == subsector + +# Efficiency changes due to biomass +eff_bio=s_ued['Biomass']/s_fec['Biomass'] + +df.loc['biomass', sector] += s_ued[['Cement: Clinker production (kilns)', 'Cement: Grinding, packaging']].sum()/eff_bio + +#### Process-emission came from the calcination of limestone to chemically reactive calcium oxide (lime). +#> Calcium carbonate -> lime + CO2 +# +#> CaCO3 -> CaO + CO2 + +s_emi = excel_emi.iloc[3:44,year] + +assert s_emi.index[0] == sector + +s_out = excel_out.iloc[7:8,year] + +assert sector in str(s_out.index) + +df.loc['process emission',sector] +=s_emi['Process emissions']/s_out.values # unit tCO2/t material + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out.values # unit MWh/t material + +### Ceramics & other NMM +# +#> This sector has process emissions. +# +#> Includes four subcategories: (a) Mixing of raw material, (b) Drying and sintering of raw material, (c) Primary production process, (d) Product finishing. (b)represents 65% of fec and (a) 4%. So (a) is joined to (b). +# +#> Everything is electrified + +sector = 'Ceramics & other NMM' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[45:94,year] + +s_ued = excel_ued.iloc[45:94,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Ceramics: Microwave drying and sintering']/s_fec['Ceramics: Microwave drying and sintering'] +df.loc['elec', sector] += s_ued[['Ceramics: Mixing of raw material','Ceramics: Drying and sintering of raw material']].sum()/eff_elec + +eff_elec=s_ued['Ceramics: Electric kiln']/s_fec['Ceramics: Electric kiln'] +df.loc['elec', sector] += s_ued['Ceramics: Primary production process']/eff_elec + +eff_elec=s_ued['Ceramics: Electric furnace']/s_fec['Ceramics: Electric furnace'] +df.loc['elec', sector] += s_ued['Ceramics: Product finishing']/eff_elec + +s_emi = excel_emi.iloc[45:94,year] + +assert s_emi.index[0] == sector + +s_out = excel_out.iloc[8:9,year] + +assert sector in str(s_out.index) + +df.loc['process emission',sector] += s_emi['Process emissions']/s_out.values # unit tCO2/t material + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*11.630/s_out.values # unit MWh/t material +# 1 ktoe = 11630 MWh + +### Glass production +# +#> This sector has process emissions. +# +#> Includes four subcategories: (a) Melting tank, (b) Forming, (c) Annealing, (d) Finishing processes. (a)represents 73%. (b), (d) are joined to (c). +# +#> Everything is electrified. + +sector = 'Glass production' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[95:123,year] + +s_ued = excel_ued.iloc[95:123,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Glass: Electric melting tank']/s_fec['Glass: Electric melting tank'] +df.loc['elec', sector] += s_ued['Glass: Melting tank']/eff_elec + +eff_elec=s_ued['Glass: Annealing - electric']/s_fec['Glass: Annealing - electric'] +df.loc['elec', sector] += s_ued[['Glass: Forming','Glass: Annealing','Glass: Finishing processes']].sum()/eff_elec + +s_emi = excel_emi.iloc[95:124,year] + +assert s_emi.index[0] == sector + +s_out = excel_out.iloc[9:10,year] + +assert sector in str(s_out.index) + +df.loc['process emission',sector] += s_emi['Process emissions']/s_out.values # unit tCO2/t material + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out.values # unit MWh/t material + +## Pulp, paper and printing +# +#> Pulp, paper and printing can be completely electrified. +# +#> There are no process emissions associated to this sector. + +sector = 'Pulp, paper and printing' + +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +### Pulp production +# +#> Includes three subcategories: (a) Wood preparation, grinding; (b) Pulping; (c) Cleaning. +# +#> (b) Pulping is electrified. The efficiency is calculated from the pulping process that is already electric. +# +#> (a) Wood preparation, grinding and (c) Cleaning represent only 10% their current energy consumption is assumed to be electrified without any change in efficiency + +sector = 'Pulp production' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:28,year] + +s_ued = excel_ued.iloc[3:28,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Industry-specific +df.loc['elec', sector] += s_fec[['Pulp: Wood preparation, grinding', 'Pulp: Cleaning']].sum() + +# Efficiency changes due to electrification +eff_elec=s_ued['Pulp: Pulping electric']/s_fec['Pulp: Pulping electric'] +df.loc['elec', sector] += s_ued['Pulp: Pulping thermal']/eff_elec + +# add electricity from process that is already electrified +df.loc['elec', sector] += s_fec['Pulp: Pulping electric'] + +s_out = excel_out.iloc[8:9,year] + +assert sector in str(s_out.index) + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out['Pulp production (kt)'] # unit MWh/t material + +### Paper production +# +#> Includes three subcategories: (a) Stock preparation; (b) Paper machine; (c) Product finishing. +# +#> (b) Paper machine and (c) Product finishing are electrified. The efficiency is calculated from the pulping process that is already electric. +# +#> (a) Stock preparation represents only 7% and its current energy consumption is assumed to be electrified without any change in efficiency. + +sector = 'Paper production' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[29:78,year] + +s_ued = excel_ued.iloc[29:78,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Industry-specific +df.loc['elec', sector] += s_fec['Paper: Stock preparation'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Paper: Paper machine - Electricity']/s_fec['Paper: Paper machine - Electricity'] +df.loc['elec', sector] += s_ued['Paper: Paper machine - Steam use']/eff_elec + +eff_elec=s_ued['Paper: Product finishing - Electricity']/s_fec['Paper: Product finishing - Electricity'] +df.loc['elec', sector] += s_ued['Paper: Product finishing - Steam use']/eff_elec + +# add electricity from process that is already electrified +df.loc['elec', sector] += s_fec['Paper: Paper machine - Electricity'] + +# read the corresponding lines +s_out = excel_out.iloc[9:10,year] + +assert sector in str(s_out.index) + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out.values # unit MWh/t material\ + +### Printing and media reproduction +# +#> (a) Printing and publishing is assumed to be electrified without any change in efficiency. + +sector='Printing and media reproduction' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[79:90,year] + +s_ued = excel_ued.iloc[79:90,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec',sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() +df.loc['elec',sector] += s_ued[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat',sector] += s_fec['Low enthalpy heat'] +df.loc['heat',sector] += s_ued['Low enthalpy heat'] + +# Industry-specific +df.loc['elec', sector] += s_fec['Printing and publishing'] +df.loc['elec', sector] += s_ued['Printing and publishing'] + +# read the corresponding lines +s_out = excel_out.iloc[10:11,year] + +assert sector in str(s_out.index) + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] + +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out.values # unit MWh/t material + +## Food, beverages and tobaco +# +#> Food, beverages and tobaco can be completely electrified. +# +#> There are no process emissions associated to this sector. + +sector = 'Food, beverages and tobacco' + +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:78,year] + +s_ued = excel_ued.iloc[3:78,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Food: Direct Heat - Electric']/s_fec['Food: Direct Heat - Electric'] +df.loc['elec', sector] += s_ued['Food: Oven (direct heat)']/eff_elec + +eff_elec=s_ued['Food: Process Heat - Electric']/s_fec['Food: Process Heat - Electric'] +df.loc['elec', sector] += s_ued['Food: Specific process heat']/eff_elec + +eff_elec=s_ued['Food: Electric drying']/s_fec['Food: Electric drying'] +df.loc['elec', sector] += s_ued['Food: Drying']/eff_elec + +eff_elec=s_ued['Food: Electric cooling']/s_fec['Food: Electric cooling'] +df.loc['elec', sector] += s_ued['Food: Process cooling and refrigeration']/eff_elec + +# Steam processing is electrified without change in efficiency +df.loc['elec', sector] += s_fec['Food: Steam processing'] + +# add electricity from process that is already electrified +df.loc['elec', sector] += s_fec['Food: Electric machinery'] + +# read the corresponding lines +s_out = excel_out.iloc[3:4,year] + +# final energy consumption per t +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 + +## Non Ferrous Metals + +sector = 'Non Ferrous Metals' + +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) # the emission sheet + +### Alumina +# +#> High enthalpy heat is converted to methane. Process heat at T>500ÂșC is required here. +# +#> Refining is electrified. +# +#> There are no process emissions associated to Alumina manufacturing + +sector = 'Alumina production' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:31,year] + +s_ued = excel_ued.iloc[3:31,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# High-enthalpy heat is transformed into methane +s_fec = excel_fec.iloc[13:24,year] + +s_ued = excel_ued.iloc[13:24,year] + +assert s_fec.index[0] == 'Alumina production: High enthalpy heat' + +eff_met=s_ued['Natural gas (incl. biogas)']/s_fec['Natural gas (incl. biogas)'] +df.loc['methane', sector] += s_fec['Alumina production: High enthalpy heat']/eff_met + +# Efficiency changes due to electrification +s_fec = excel_fec.iloc[24:30,year] + +s_ued = excel_ued.iloc[24:30,year] + +assert s_fec.index[0] == 'Alumina production: Refining' + +eff_elec=s_ued['Electricity']/s_fec['Electricity'] +df.loc['elec', sector] += s_ued['Alumina production: Refining']/eff_elec + +# read the corresponding lines +s_out = excel_out.iloc[9:10,year] + +assert sector in str(s_out.index) + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out['Alumina production (kt)'] # unit MWh/t material + +### Aluminium primary route +# +#> Production through the primary route is divided into 50% remains as today and 50% is transformed into secondary route + +sector = 'Aluminium - primary production' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[31:66,year] + +s_ued = excel_ued.iloc[31:66,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Add aluminium electrolysis (smelting +df.loc['elec', sector] += s_fec['Aluminium electrolysis (smelting)'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Aluminium processing - Electric']/s_fec['Aluminium processing - Electric'] +df.loc['elec', sector] += s_ued['Aluminium processing (metallurgy e.g. cast house, reheating)']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Aluminium finishing - Electric']/s_fec['Aluminium finishing - Electric'] +df.loc['elec', sector] += s_ued['Aluminium finishing']/eff_elec + +s_emi = excel_emi.iloc[31:67,year] + +assert s_emi.index[0] == sector + +s_out = excel_out.iloc[11:12,year] + +assert sector in str(s_out.index) + +df.loc['process emission',sector] = s_emi['Process emissions']/s_out['Aluminium - primary production'] # unit tCO2/t material + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out['Aluminium - primary production'] # unit MWh/t material + +### Aluminium secondary route +# +#> All is coverted into secondary route fully electrified + +sector = 'Aluminium - secondary production' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[68:109,year] + +s_ued = excel_ued.iloc[68:109,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Secondary aluminium - Electric']/s_fec['Secondary aluminium - Electric'] +df.loc['elec', sector] += s_ued['Secondary aluminium (incl. pre-treatment, remelting)']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Aluminium processing - Electric']/s_fec['Aluminium processing - Electric'] +df.loc['elec', sector] += s_ued['Aluminium processing (metallurgy e.g. cast house, reheating)']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Aluminium finishing - Electric']/s_fec['Aluminium finishing - Electric'] +df.loc['elec', sector] += s_ued['Aluminium finishing']/eff_elec + +# read the corresponding lines +s_out = excel_out.iloc[12:13,year] + +assert sector in str(s_out.index) + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out['Aluminium - secondary production'] # unit MWh/t material +# 1 ktoe = 11630 MWh + +# primary route is divided into 50% remains as today and 50% is transformed into secondary route +df.loc[sources,'Aluminium - primary production'] = 0.5*df.loc[sources,'Aluminium - primary production'] + 0.5*df.loc[sources,'Aluminium - secondary production'] +df.loc['process emission','Aluminium - primary production'] = 0.5*df.loc['process emission','Aluminium - primary production'] + +### Other non-ferrous metals + +sector = 'Other non-ferrous metals' + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[110:152,year] + +s_ued = excel_ued.iloc[110:152,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Metal production - Electric']/s_fec['Metal production - Electric'] +df.loc['elec', sector] += s_ued['Other Metals: production']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Metal processing - Electric']/s_fec['Metal processing - Electric'] +df.loc['elec', sector] += s_ued['Metal processing (metallurgy e.g. cast house, reheating)']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Metal finishing - Electric']/s_fec['Metal finishing - Electric'] +df.loc['elec', sector] += s_ued['Metal finishing']/eff_elec + +s_emi = excel_emi.iloc[110:153,year] + +assert s_emi.index[0] == sector + +s_out = excel_out.iloc[13:14,year] + +assert sector in str(s_out.index) + +df.loc['process emission',sector] = s_emi['Process emissions']/s_out['Other non-ferrous metals (kt lead eq.)'] # unit tCO2/t material + +# final energy consumption per t +sources=['elec','biomass', 'methane', 'hydrogen', 'heat','naphtha'] +df.loc[sources,sector] = df.loc[sources,sector]*conv_factor/s_out['Other non-ferrous metals (kt lead eq.)'] # unit MWh/t material + +## Transport Equipment + +sector = 'Transport Equipment' +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) # the emission sheet + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:45,year] + +s_ued = excel_ued.iloc[3:45,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Trans. Eq.: Electric Foundries']/s_fec['Trans. Eq.: Electric Foundries'] +df.loc['elec', sector] += s_ued['Trans. Eq.: Foundries']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Trans. Eq.: Electric connection']/s_fec['Trans. Eq.: Electric connection'] +df.loc['elec', sector] += s_ued['Trans. Eq.: Connection techniques']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Trans. Eq.: Heat treatment - Electric']/s_fec['Trans. Eq.: Heat treatment - Electric'] +df.loc['elec', sector] += s_ued['Trans. Eq.: Heat treatment']/eff_elec + +df.loc['elec', sector] += s_fec['Trans. Eq.: General machinery'] +df.loc['elec', sector] += s_fec['Trans. Eq.: Product finishing'] + +# Steam processing is supplied with biomass +eff_biomass=s_ued['Biomass']/s_fec['Biomass'] +df.loc['biomass', sector] += s_ued['Trans. Eq.: Steam processing']/eff_biomass + +# read the corresponding lines +s_out = excel_out.iloc[3:4,year] +# final energy consumption per t +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 +# 1 ktoe = 11630 MWh + +## Machinery Equipment + +sector = 'Machinery Equipment' + +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) # the emission sheet + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:45,year] + +s_ued = excel_ued.iloc[3:45,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Mach. Eq.: Electric Foundries']/s_fec['Mach. Eq.: Electric Foundries'] +df.loc['elec', sector] += s_ued['Mach. Eq.: Foundries']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Mach. Eq.: Electric connection']/s_fec['Mach. Eq.: Electric connection'] +df.loc['elec', sector] += s_ued['Mach. Eq.: Connection techniques']/eff_elec + +# Efficiency changes due to electrification +eff_elec=s_ued['Mach. Eq.: Heat treatment - Electric']/s_fec['Mach. Eq.: Heat treatment - Electric'] +df.loc['elec', sector] += s_ued['Mach. Eq.: Heat treatment']/eff_elec + +df.loc['elec', sector] += s_fec['Mach. Eq.: General machinery'] +df.loc['elec', sector] += s_fec['Mach. Eq.: Product finishing'] + +# Steam processing is supplied with biomass +eff_biomass=s_ued['Biomass']/s_fec['Biomass'] +df.loc['biomass', sector] += s_ued['Mach. Eq.: Steam processing']/eff_biomass + +# read the corresponding lines +s_out = excel_out.iloc[3:4,year] + +# final energy consumption per t +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 + +## Textiles and leather + +sector = 'Textiles and leather' +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) # the emission sheet + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:57,year] + +s_ued = excel_ued.iloc[3:57,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Textiles: Electric drying']/s_fec['Textiles: Electric drying'] +df.loc['elec', sector] += s_ued['Textiles: Drying']/eff_elec + +df.loc['elec', sector] += s_fec['Textiles: Electric general machinery'] +df.loc['elec', sector] += s_fec['Textiles: Finishing Electric'] + +# Steam processing is supplied with biomass +eff_biomass=s_ued[15:26]['Biomass']/s_fec[15:26]['Biomass'] +df.loc['biomass', sector] += s_ued['Textiles: Pretreatment with steam']/eff_biomass +df.loc['biomass', sector] += s_ued['Textiles: Wet processing with steam']/eff_biomass + +# read the corresponding lines +s_out = excel_out.iloc[3:4,year] + +# final energy consumption per t +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 + +## Wood and wood products + +sector = 'Wood and wood products' +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) # the emission sheet + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:46,year] + +s_ued = excel_ued.iloc[3:46,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Wood: Electric drying']/s_fec['Wood: Electric drying'] +df.loc['elec', sector] += s_ued['Wood: Drying']/eff_elec + +df.loc['elec', sector] += s_fec['Wood: Electric mechanical processes'] +df.loc['elec', sector] += s_fec['Wood: Finishing Electric'] + +# Steam processing is supplied with biomass +eff_biomass=s_ued[15:25]['Biomass']/s_fec[15:25]['Biomass'] +df.loc['biomass', sector] += s_ued['Wood: Specific processes with steam']/eff_biomass + +# read the corresponding lines +s_out = excel_out.iloc[3:4,year] + +# final energy consumption per t +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 + +## Other Industrial Sectors + +sector = 'Other Industrial Sectors' +# read the input sheets +excel_fec = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_fec', + index_col=0,header=0,squeeze=True) + +excel_ued = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_ued', + index_col=0,header=0,squeeze=True) + +excel_out = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector], + index_col=0,header=0,squeeze=True) + +excel_emi = pd.read_excel('{}/JRC-IDEES-2015_Industry_{}.xlsx'.format(base_dir,country), sheet_name=sub_sheet_name_dict[sector]+'_emi', + index_col=0,header=0,squeeze=True) # the emission sheet + +df[sector] = 0 + +# read the corresponding lines +s_fec = excel_fec.iloc[3:67,year] + +s_ued = excel_ued.iloc[3:67,year] + +assert s_fec.index[0] == sector + +# Lighting, Air compressors, Motor drives, Fans and pumps +df.loc['elec', sector] += s_fec[['Lighting','Air compressors','Motor drives','Fans and pumps']].sum() + +# Low enthalpy heat +df.loc['heat', sector] += s_fec['Low enthalpy heat'] + +# Efficiency changes due to electrification +eff_elec=s_ued['Other Industrial sectors: Electric processing']/s_fec['Other Industrial sectors: Electric processing'] +df.loc['elec', sector] += s_ued['Other Industrial sectors: Process heating']/eff_elec + +eff_elec=s_ued['Other Industries: Electric drying']/s_fec['Other Industries: Electric drying'] +df.loc['elec', sector] += s_ued['Other Industrial sectors: Drying']/eff_elec + +eff_elec=s_ued['Other Industries: Electric cooling']/s_fec['Other Industries: Electric cooling'] +df.loc['elec', sector] += s_ued['Other Industrial sectors: Process Cooling']/eff_elec + +# Diesel motors are electrified +df.loc['elec', sector] += s_fec['Other Industrial sectors: Diesel motors (incl. biofuels)'] +df.loc['elec', sector] += s_fec['Other Industrial sectors: Electric machinery'] + +# Steam processing is supplied with biomass +eff_biomass=s_ued[15:25]['Biomass']/s_fec[15:25]['Biomass'] +df.loc['biomass', sector] += s_ued['Other Industrial sectors: Steam processing']/eff_biomass + +# read the corresponding lines +s_out = excel_out.iloc[3:4,year] + +# final energy consumption per t +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.to_csv('resources/industry_sector_ratios.csv', sep=';')