<jupyter_start><jupyter_text>Generate emissions scenariosHere, we check that we can reproduce the baseline results of AR6 using SSP2-4.5 in FaIR, and export the emissions scenarios that we want to run our modified scenarios with.We see that according to UNFCCC NDC Synthesis Report (https://unfccc.int/sites/default/files/resource/cma2021_08_adv_1.pdf), SSP2-4.5 is quite in line with NDC projections to 2030. So, we use this as our baseline scenario.<jupyter_code>import copy

from climateforcing.utils import mkdir_p
import matplotlib.pyplot as pl
import numpy as np
import pandas as pd
from scipy.interpolate import interp1d
emissions_out = {}
scenarios = ["ssp245", "ssp245_constant-2020-ch4", "ch4_30", "ch4_40", "ch4_50", "coal-phase-out"]<jupyter_output><empty_output><jupyter_text>Put into a FaIR-style input arraySome unit conversion required first. We define SSP2-4.5 for each scenario first, then overwrite the specific entries we want to change.<jupyter_code>ssp_df = pd.read_csv('../data_input/rcmip/rcmip-emissions-annual-means-world-ssp245-v5-1-0.csv')
years = np.arange(1750, 2111)

startyear = 1750
first_scenyear = 2015
last_scenyear = 2110
first_row = int(first_scenyear-startyear)
last_row = int(last_scenyear-startyear)

species = [  # in fair 1.6, order is important
    '|CO2|MAGICC Fossil and Industrial',
    '|CO2|MAGICC AFOLU',
    '|CH4',
    '|N2O',
    '|Sulfur',
    '|CO',
    '|VOC',
    '|NOx',
    '|BC',
    '|OC',
    '|NH3',
    '|CF4',
    '|C2F6',
    '|C6F14',
    '|HFC23',
    '|HFC32',
    '|HFC4310mee',
    '|HFC125',
    '|HFC134a',
    '|HFC143a',
    '|HFC227ea',
    '|HFC245fa',
    '|SF6',
    '|CFC11',
    '|CFC12',
    '|CFC113',
    '|CFC114',
    '|CFC115',
    '|CCl4',
    '|CH3CCl3',
    '|HCFC22',
    '|HCFC141b',
    '|HCFC142b',
    '|Halon1211',
    '|Halon1202',
    '|Halon1301',
    '|Halon2402',
    '|CH3Br',
    '|CH3Cl',
]

unit_convert = np.ones(40)
unit_convert[1] = 12/44/1000
unit_convert[2] = 12/44/1000
unit_convert[4] = 28/44/1000
unit_convert[5] = 32/64
unit_convert[8] = 14/46

for scenario in scenarios:
    emissions_out[scenario] = np.ones((361, 40)) * np.nan
    emissions_out[scenario][:,0] = years

    years_future = [2015] + list(range(2020,2111,10))
    for i, specie in enumerate(species):
        emissions_out[scenario][:first_row,i+1] = ssp_df.loc[
            (ssp_df['Model']=='MESSAGE-GLOBIOM')&
            (ssp_df['Region']=='World')&
            (ssp_df['Scenario']=='ssp245')&
            (ssp_df['Variable'].str.endswith(specie)),str(startyear):'2014']*unit_convert[i+1]
        f = interp1d(years_future, ssp_df.loc[
            (ssp_df['Model']=='MESSAGE-GLOBIOM')&
            (ssp_df['Region']=='World')&
            (ssp_df['Scenario']=='ssp245')&
            (ssp_df['Variable'].str.endswith(specie)),'2015':'2110'].dropna(axis=1))
        emissions_out[scenario][first_row:(last_row+1), i+1] = f(
            np.arange(first_scenyear, last_scenyear+1)
        )*unit_convert[i+1]
for specie_index in [1, 5, 6, 7, 8, 9, 10, 11]:
    pl.plot(
        np.arange(1980.5, 2101),
        100 * emissions_out[scenario][230:351, specie_index] / emissions_out[scenario][270, specie_index],
        label=specie_index,
    )
pl.legend()
pl.title('reconstructed emissions')
pl.ylabel('relative units, year 2020 = 100')
emissions_out<jupyter_output><empty_output><jupyter_text>SSP2-4.5 with constant CH4 emissions from 2020Baseline for other scenariosThe methane commitment says nothing about ozone-forming SLCFs.<jupyter_code>emissions_out['ssp245_constant-2020-ch4'] = copy.copy(emissions_out['ssp245'])
emissions_out['ssp245_constant-2020-ch4'][270:,3] = emissions_out['ssp245'][270,3]<jupyter_output><empty_output><jupyter_text>30%, 40% and 50% methane reductions by 2030 We will use the constant 2020 emissions as a baseline and assume a linear decline 2020 to 2030, with 30, 40 or 50% below SSP2-4.5 values in all future years.- 380 MtCH4/yr as "business as usual" in 2030 in ETC Keeping 1.5C Alive- 382 MtCH4/yr in 2030 in SSP2-4.5- 388 MtCH4/yr in 2020 in SSP2-4.5it's therefore OK to assume SSP2-4.5 values as our baseline.<jupyter_code>for reduct in [30, 40, 50]:
    emissions_out['ch4_{}'.format(reduct)] = copy.copy(emissions_out['ssp245_constant-2020-ch4'])
    emissions_out['ch4_{}'.format(reduct)][280:,3] = emissions_out['ch4_{}'.format(reduct)][280:,3] * (1-reduct*0.01)
    emissions_out['ch4_{}'.format(reduct)][270:281,3] = np.linspace(1,0,11)*emissions_out['ch4_{}'.format(reduct)][270,3] + np.linspace(0,1,11)*emissions_out['ch4_{}'.format(reduct)][280,3]
pl.plot(np.arange(1750.5, 2111), emissions_out['ssp245_constant-2020-ch4'][:,3])
pl.plot(np.arange(1750.5, 2111), emissions_out['ch4_30'][:,3])
pl.plot(np.arange(1750.5, 2111), emissions_out['ch4_40'][:,3])
pl.plot(np.arange(1750.5, 2111), emissions_out['ch4_50'][:,3])<jupyter_output><empty_output><jupyter_text>Coal phase out by 2030this will be a little more difficult, and requires us to go back to the IIASA Scenario Database to estimate the coal-attributable emissions. Luckily for us, which makes it easy, in SSP2-4.5 coal consumption is pretty flat from 2020 to 2030.I will use CEDS data to estimate fugitive emissions as well as direct emissions attributed to coal. This is because IEA data isn't granular enough and isn't publicly available.We assume simply that coal is replaced by a zero-carbon alternative.Because of units and other thorniniess, we'll do it the slow way, species by species.We won't bother with NH3, as it's almost all agricultural.  CO2<jupyter_code>emissions_out['coal-phase-out'][269,1] * 44/12  # SSP2-4.5 emissions estimate in GtCO2 for 2019
# CEDS emissions 2019 in ktCO2
ceds_co2_sector_df = pd.read_csv('../data_input/ceds-20210421/CO2_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_co2_sector_df.set_index('sector', inplace=True)
ceds_co2_sector_df.sum().loc['X2019']<jupyter_output><empty_output><jupyter_text>What we'll do here is take the coal emissions directly attributable from combustion, plus any fugitive emissions from solid fuels, divide by the total CO2 emissions to get a coal attributable fraction, then This number is about 10% lower than IEA coal attributable emissions, but (1) their data isn't public and (2) it gives a different number for total emissions to CEDS.<jupyter_code># quick verification that the numbers agree
ceds_co2_fuel_df = pd.read_csv('../data_input/ceds-20210421/CO2_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_co2_fuel_df.set_index('fuel', inplace=True)
ceds_co2_fuel_df.sum().loc['X2019']
coal_co2 = (
    ceds_co2_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_co2_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_co2_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_co2_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_co2
# this is the "harmonized" coal ktCO2 emissions in SSP2-4.5
coal_co2_ssp245_harmonized = coal_co2 / ceds_co2_fuel_df.sum().loc['X2019'] * 1e6 * emissions_out['coal-phase-out'][269,1] * 44/12
coal_co2_ssp245_harmonized<jupyter_output><empty_output><jupyter_text>Now, we can estimate an emissions factor by looking at the primary energy supply from coal in SSP2-4.5. We use 2020 rather than 2019, as 2019 is not supplied in the scenario.<jupyter_code>message_ssp245_df = pd.read_csv('../data_input/iiasa/ssp245-iam-database.csv')
message_ssp245_df.set_index('VARIABLE', inplace=True)
message_ssp245_df
message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']  # EJ/yr
# kgCO2 / MJ for coal
emissions_factor_coal_co2 = (
    coal_co2_ssp245_harmonized * 1e-6 / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_co2
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_co2 = emissions_factor_coal_co2 * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':] / (44/12)
ssp245_coal_co2
# now, of course, it won't be an instant phase out, so the 2020 to 2040 is a linear ramp.
ssp245_coal_co2.loc['2020'] = 0
ssp245_coal_co2.loc['2030'] = ssp245_coal_co2.loc['2030'] * 0.5
ssp245_coal_co2
f = interp1d(np.arange(2020,2101,10), ssp245_coal_co2.values)
ssp245_coal_co2_interp = f(np.arange(2020,2101))
ssp245_coal_co2_interp
emissions_out['coal-phase-out'][270:351,1] = emissions_out['coal-phase-out'][270:351,1] - ssp245_coal_co2_interp
emissions_out['coal-phase-out'][351:,1] = emissions_out['coal-phase-out'][351:,1] - ssp245_coal_co2_interp[-1]
# as we can see this trajectory is a little artificial, because we have assumed that all coal is replaced by a zero
# carbon fuel. In the real world much of the additional capacity will be gas.
pl.plot(emissions_out['ssp245'][:,1])
pl.plot(emissions_out['coal-phase-out'][:,1])<jupyter_output><empty_output><jupyter_text>CH4We are implementing the 30% methane reduction in place of the coal phase out from methane.The next few cells I'll retain in case we switch back<jupyter_code># CEDS emissions 2019 in ktCH4
ceds_ch4_sector_df = pd.read_csv('../data_input/ceds-20210421/CH4_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_ch4_sector_df.set_index('sector', inplace=True)
ceds_ch4_sector_df.sum().loc['X2019']
# quick verification that the numbers agree
ceds_ch4_fuel_df = pd.read_csv('../data_input/ceds-20210421/CH4_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_ch4_fuel_df.set_index('fuel', inplace=True)
ceds_ch4_fuel_df.sum().loc['X2019']
coal_ch4 = (
    ceds_ch4_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_ch4_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_ch4_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_ch4_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_ch4
# this is the "harmonized" coal MtCH4 emissions in SSP2-4.5.
coal_ch4_ssp245_harmonized = coal_ch4 / ceds_ch4_fuel_df.sum().loc['X2019'] * emissions_out['coal-phase-out'][269,3]
coal_ch4_ssp245_harmonized<jupyter_output><empty_output><jupyter_text>Now, we can estimate an emissions factor by looking at the primary energy supply from coal in SSP2-4.5. We use 2020 rather than 2019, as 2019 is not supplied in the scenario.<jupyter_code># kgCH4 / MJ for coal
emissions_factor_coal_ch4 = (
    coal_ch4_ssp245_harmonized / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_ch4
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_ch4 = emissions_factor_coal_ch4 * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':]
ssp245_coal_ch4
# now, of course, it won't be an instant phase out, so the 2020 to 2030 is a linear ramp.
ssp245_coal_ch4.loc['2020'] = 0
ssp245_coal_ch4.loc['2030'] = 0.5 * ssp245_coal_ch4.loc['2030']
ssp245_coal_ch4
f = interp1d(np.arange(2020,2101,10), ssp245_coal_ch4.values)
ssp245_coal_ch4_interp = f(np.arange(2020,2101))
ssp245_coal_ch4_interp
emissions_out['coal-phase-out'][270:351,3] = emissions_out['coal-phase-out'][270:351,3] - ssp245_coal_ch4_interp
emissions_out['coal-phase-out'][351:,3] = emissions_out['coal-phase-out'][351:,3] - ssp245_coal_ch4_interp[-1]
# override
emissions_out['coal-phase-out'][270:,3] = emissions_out['ch4_30'][270:,3]
pl.plot(emissions_out['ssp245'][:,3])
pl.plot(emissions_out['coal-phase-out'][:,3])<jupyter_output><empty_output><jupyter_text>N2O<jupyter_code>emissions_out['coal-phase-out'][269,4] * 44/28  # SSP2-4.5 emissions estimate in MtN2O for 2019
# CEDS emissions 2019 in ktN2O
ceds_n2o_sector_df = pd.read_csv('../data_input/ceds-20210421/N2O_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_n2o_sector_df.set_index('sector', inplace=True)
ceds_n2o_sector_df.sum().loc['X2019']
# quick verification that the numbers agree
ceds_n2o_fuel_df = pd.read_csv('../data_input/ceds-20210421/N2O_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_n2o_fuel_df.set_index('fuel', inplace=True)
ceds_n2o_fuel_df.sum().loc['X2019']
coal_n2o = (
    ceds_n2o_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_n2o_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_n2o_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_n2o_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_n2o
# this is the "harmonized" coal ktN2O emissions in SSP2-4.5
coal_n2o_ssp245_harmonized = coal_n2o / ceds_n2o_fuel_df.sum().loc['X2019'] * 1e3 * emissions_out['coal-phase-out'][269,4] * 44/28
coal_n2o_ssp245_harmonized
# kgN2O / MJ for coal
emissions_factor_coal_n2o = (
    coal_n2o_ssp245_harmonized * 1e-3 / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_n2o
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_n2o = emissions_factor_coal_n2o * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':] / (44/28)
ssp245_coal_n2o
# now, of course, it won't be an instant phase out, so the 2020 to 2030 is a linear ramp.
ssp245_coal_n2o.loc['2020'] = 0
ssp245_coal_n2o.loc['2030'] = 0.5 * ssp245_coal_n2o.loc['2030']
f = interp1d(np.arange(2020,2101,10), ssp245_coal_n2o.values)
ssp245_coal_n2o_interp = f(np.arange(2020,2101))
ssp245_coal_n2o_interp
emissions_out['coal-phase-out'][270:351,4] = emissions_out['coal-phase-out'][270:351,4] - ssp245_coal_n2o_interp
emissions_out['coal-phase-out'][351:,4] = emissions_out['coal-phase-out'][351:,4] - ssp245_coal_n2o_interp[-1]
pl.plot(emissions_out['ssp245'][:,4])
pl.plot(emissions_out['coal-phase-out'][:,4])<jupyter_output><empty_output><jupyter_text>SO2<jupyter_code>emissions_out['coal-phase-out'][269,5] * 64/32  # SSP2-4.5 emissions estimate in MtSO2 for 2019
# CEDS emissions 2019 in ktSO2
ceds_so2_sector_df = pd.read_csv('../data_input/ceds-20210421/SO2_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_so2_sector_df.set_index('sector', inplace=True)
ceds_so2_sector_df.sum().loc['X2019']
# quick verification that the numbers agree
ceds_so2_fuel_df = pd.read_csv('../data_input/ceds-20210421/SO2_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_so2_fuel_df.set_index('fuel', inplace=True)
ceds_so2_fuel_df.sum().loc['X2019']
coal_so2 = (
    ceds_so2_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_so2_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_so2_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_so2_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_so2
# this is the "harmonized" coal ktSO2 emissions in SSP2-4.5
coal_so2_ssp245_harmonized = coal_so2 / ceds_so2_fuel_df.sum().loc['X2019'] * 1e3 * emissions_out['coal-phase-out'][269,5] * 64/32
coal_so2_ssp245_harmonized
# kgSO2 / MJ for coal
emissions_factor_coal_so2 = (
    coal_so2_ssp245_harmonized * 1e-3 / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_so2
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_so2 = emissions_factor_coal_so2 * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':] / (64/32)
ssp245_coal_so2
# now, of course, it won't be an instant phase out, so the 2020 to 2030 is a linear ramp.
ssp245_coal_so2.loc['2020'] = 0
ssp245_coal_so2.loc['2030'] = 0.5 * ssp245_coal_so2.loc['2030']
f = interp1d(np.arange(2020,2101,10), ssp245_coal_so2.values)
ssp245_coal_so2_interp = f(np.arange(2020,2101))
ssp245_coal_so2_interp
emissions_out['coal-phase-out'][270:351,5] = emissions_out['coal-phase-out'][270:351,5] - ssp245_coal_so2_interp
emissions_out['coal-phase-out'][351:,5] = emissions_out['coal-phase-out'][351:,5] - ssp245_coal_so2_interp[-1]
pl.plot(emissions_out['ssp245'][:,5])
pl.plot(emissions_out['coal-phase-out'][:,5])<jupyter_output><empty_output><jupyter_text>CO<jupyter_code>emissions_out['coal-phase-out'][269,6] # SSP2-4.5 emissions estimate in MtCO for 2019
# CEDS emissions 2019 in ktCO
ceds_co_sector_df = pd.read_csv('../data_input/ceds-20210421/CO_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_co_sector_df.set_index('sector', inplace=True)
ceds_co_sector_df.sum().loc['X2019']
# quick verification that the numbers agree
ceds_co_fuel_df = pd.read_csv('../data_input/ceds-20210421/CO_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_co_fuel_df.set_index('fuel', inplace=True)
ceds_co_fuel_df.sum().loc['X2019']
coal_co = (
    ceds_co_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_co_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_co_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_co_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_co
# this is the "harmonized" coal ktCO emissions in SSP2-4.5. Some of this is biomass based, but we don't have this info.
coal_co_ssp245_harmonized = coal_co / ceds_co_fuel_df.sum().loc['X2019'] * 1e3 * emissions_out['coal-phase-out'][269,6]
coal_co_ssp245_harmonized
# kgCO / MJ for coal
emissions_factor_coal_co = (
    coal_co_ssp245_harmonized * 1e-3 / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_co
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_co = emissions_factor_coal_co * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':]
ssp245_coal_co
# now, of course, it won't be an instant phase out, so the 2020 to 2030 is a linear ramp.
ssp245_coal_co.loc['2020'] = 0
ssp245_coal_co.loc['2030'] = 0.5 * ssp245_coal_co.loc['2030']
f = interp1d(np.arange(2020,2101,10), ssp245_coal_co.values)
ssp245_coal_co_interp = f(np.arange(2020,2101))
ssp245_coal_co_interp
emissions_out['coal-phase-out'][270:351,6] = emissions_out['coal-phase-out'][270:351,6] - ssp245_coal_co_interp
emissions_out['coal-phase-out'][351:,6] = emissions_out['coal-phase-out'][351:,6] - ssp245_coal_co_interp[-1]
pl.plot(emissions_out['ssp245'][:,6])
pl.plot(emissions_out['coal-phase-out'][:,6])<jupyter_output><empty_output><jupyter_text>VOC<jupyter_code>emissions_out['coal-phase-out'][269,7]  # SSP2-4.5 emissions estimate in MtVOC for 2019
# CEDS emissions 2019 in ktVOC
ceds_voc_sector_df = pd.read_csv('../data_input/ceds-20210421/NMVOC_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_voc_sector_df.set_index('sector', inplace=True)
ceds_voc_sector_df.sum().loc['X2019']
# quick verification that the numbers agree
ceds_voc_fuel_df = pd.read_csv('../data_input/ceds-20210421/NMVOC_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_voc_fuel_df.set_index('fuel', inplace=True)
ceds_voc_fuel_df.sum().loc['X2019']
coal_voc = (
    ceds_voc_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_voc_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_voc_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_voc_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_voc
# this is the "harmonized" coal ktVOC emissions in SSP2-4.5
coal_voc_ssp245_harmonized = coal_voc / ceds_voc_fuel_df.sum().loc['X2019'] * 1e3 * emissions_out['coal-phase-out'][269,7]
coal_voc_ssp245_harmonized
# kgVOC / MJ for coal
emissions_factor_coal_voc = (
    coal_voc_ssp245_harmonized * 1e-3 / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_voc
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_voc = emissions_factor_coal_voc * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':]
ssp245_coal_voc
# now, of course, it won't be an instant phase out, so the 2020 to 2030 is a linear ramp.
ssp245_coal_voc.loc['2020'] = 0
ssp245_coal_voc.loc['2030'] = 0.5 * ssp245_coal_voc.loc['2030']
f = interp1d(np.arange(2020,2101,10), ssp245_coal_voc.values)
ssp245_coal_voc_interp = f(np.arange(2020,2101))
ssp245_coal_voc_interp
emissions_out['coal-phase-out'][270:351,7] = emissions_out['coal-phase-out'][270:351,7] - ssp245_coal_voc_interp
emissions_out['coal-phase-out'][351:,7] = emissions_out['coal-phase-out'][351:,7] - ssp245_coal_voc_interp[-1]
pl.plot(emissions_out['ssp245'][:,7])
pl.plot(emissions_out['coal-phase-out'][:,7])<jupyter_output><empty_output><jupyter_text>NOxAnother unit brain tax<jupyter_code>emissions_out['coal-phase-out'][269,8] * 46/14  # SSP2-4.5 emissions estimate in MtNO2 for 2019
# CEDS emissions 2019 in ktNO2
ceds_nox_sector_df = pd.read_csv('../data_input/ceds-20210421/NOx_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_nox_sector_df.set_index('sector', inplace=True)
ceds_nox_sector_df.sum().loc['X2019']
# quick verification that the numbers agree
ceds_nox_fuel_df = pd.read_csv('../data_input/ceds-20210421/NOx_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_nox_fuel_df.set_index('fuel', inplace=True)
ceds_nox_fuel_df.sum().loc['X2019']
coal_nox = (
    ceds_nox_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_nox_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_nox_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_nox_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_nox
# this is the "harmonized" coal ktNO2 emissions in SSP2-4.5
coal_nox_ssp245_harmonized = coal_nox / ceds_nox_fuel_df.sum().loc['X2019'] * 1e3 * emissions_out['coal-phase-out'][269,8] * 46/14
coal_nox_ssp245_harmonized
# kgNO2 / MJ for coal
emissions_factor_coal_nox = (
    coal_nox_ssp245_harmonized * 1e-3 / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_nox
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_nox = emissions_factor_coal_nox * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':] / (46/14)
ssp245_coal_nox
# now, of course, it won't be an instant phase out, so the 2020 to 2030 is a linear ramp.
ssp245_coal_nox.loc['2020'] = 0
ssp245_coal_nox.loc['2030'] = 0.5 * ssp245_coal_nox.loc['2030']
f = interp1d(np.arange(2020,2101,10), ssp245_coal_nox.values)
ssp245_coal_nox_interp = f(np.arange(2020,2101))
ssp245_coal_nox_interp
emissions_out['coal-phase-out'][270:351,8] = emissions_out['coal-phase-out'][270:351,8] - ssp245_coal_nox_interp
emissions_out['coal-phase-out'][351:,8] = emissions_out['coal-phase-out'][351:,8] - ssp245_coal_nox_interp[-1]
pl.plot(emissions_out['ssp245'][:,8])
pl.plot(emissions_out['coal-phase-out'][:,8])<jupyter_output><empty_output><jupyter_text>BC<jupyter_code>emissions_out['coal-phase-out'][269,9] # SSP2-4.5 emissions estimate in MtBC for 2019
# CEDS emissions 2019 in ktBC
ceds_bc_sector_df = pd.read_csv('../data_input/ceds-20210421/BC_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_bc_sector_df.set_index('sector', inplace=True)
ceds_bc_sector_df.sum().loc['X2019']
# quick verification that the numbers agree
ceds_bc_fuel_df = pd.read_csv('../data_input/ceds-20210421/BC_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_bc_fuel_df.set_index('fuel', inplace=True)
ceds_bc_fuel_df.sum().loc['X2019']
coal_bc = (
    ceds_bc_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_bc_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_bc_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_bc_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_bc
# this is the "harmonized" coal ktBC emissions in SSP2-4.5
coal_bc_ssp245_harmonized = coal_bc / ceds_bc_fuel_df.sum().loc['X2019'] * 1e3 * emissions_out['coal-phase-out'][269,9]
coal_bc_ssp245_harmonized
# kgBC / MJ for coal
emissions_factor_coal_bc = (
    coal_bc_ssp245_harmonized * 1e-3 / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_bc
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_bc = emissions_factor_coal_bc * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':]
ssp245_coal_bc
# now, of course, it won't be an instant phase out, so the 2020 to 2030 is a linear ramp.
ssp245_coal_bc.loc['2020'] = 0
ssp245_coal_bc.loc['2030'] = 0.5 * ssp245_coal_bc.loc['2030']
f = interp1d(np.arange(2020,2101,10), ssp245_coal_bc.values)
ssp245_coal_bc_interp = f(np.arange(2020,2101))
ssp245_coal_bc_interp
emissions_out['coal-phase-out'][270:351,9] = emissions_out['coal-phase-out'][270:351,9] - ssp245_coal_bc_interp
emissions_out['coal-phase-out'][351:,9] = emissions_out['coal-phase-out'][351:,9] - ssp245_coal_bc_interp[-1]
pl.plot(emissions_out['ssp245'][:,9])
pl.plot(emissions_out['coal-phase-out'][:,9])<jupyter_output><empty_output><jupyter_text>OC<jupyter_code>emissions_out['coal-phase-out'][269,10]  # SSP2-4.5 emissions estimate in MtOC for 2019
# CEDS emissions 2019 in ktOC
ceds_oc_sector_df = pd.read_csv('../data_input/ceds-20210421/OC_global_CEDS_emissions_by_sector_2021_04_21.csv')
ceds_oc_sector_df.set_index('sector', inplace=True)
ceds_oc_sector_df.sum().loc['X2019']
# quick verification that the numbers agree
ceds_oc_fuel_df = pd.read_csv('../data_input/ceds-20210421/OC_global_CEDS_emissions_by_fuel_2021_04_21.csv')
ceds_oc_fuel_df.set_index('fuel', inplace=True)
ceds_oc_fuel_df.sum().loc['X2019']
coal_oc = (
    ceds_oc_fuel_df.loc['brown_coal', 'X2019'] +
    ceds_oc_fuel_df.loc['coal_coke', 'X2019'] +
    ceds_oc_fuel_df.loc['hard_coal', 'X2019'] +
    ceds_oc_sector_df.loc['1B1_Fugitive-solid-fuels','X2019']
)
coal_oc
# this is the "harmonized" coal ktOC emissions in SSP2-4.5
coal_oc_ssp245_harmonized = coal_oc / ceds_oc_fuel_df.sum().loc['X2019'] * 1e3 * emissions_out['coal-phase-out'][269,10]
coal_oc_ssp245_harmonized
# kgOC / MJ for coal
emissions_factor_coal_oc = (
    coal_oc_ssp245_harmonized * 1e-3 / message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020']
)
emissions_factor_coal_oc
# convert the harmonized coal fraction back to FaIR emissions
ssp245_coal_oc = emissions_factor_coal_oc * message_ssp245_df.loc['Primary Energy|Coal|w/o CCS', '2020':]
ssp245_coal_oc
# now, of course, it won't be an instant phase out, so the 2020 to 2030 is a linear ramp.
ssp245_coal_oc.loc['2020'] = 0
ssp245_coal_oc.loc['2030'] = 0.5 * ssp245_coal_oc.loc['2030']
f = interp1d(np.arange(2020,2101,10), ssp245_coal_oc.values)
ssp245_coal_oc_interp = f(np.arange(2020,2101))
ssp245_coal_oc_interp
emissions_out['coal-phase-out'][270:351,10] = emissions_out['coal-phase-out'][270:351,10] - ssp245_coal_oc_interp
emissions_out['coal-phase-out'][351:,10] = emissions_out['coal-phase-out'][351:,10] - ssp245_coal_oc_interp[-1]
pl.plot(emissions_out['ssp245'][:,10])
pl.plot(emissions_out['coal-phase-out'][:,10])<jupyter_output><empty_output><jupyter_text>Finally, save out!<jupyter_code>mkdir_p('../data_output/fair_emissions_files/')
for scenario in scenarios:
    np.savetxt('../data_output/fair_emissions_files/{}.csv'.format(scenario), emissions_out[scenario], delimiter=',')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1391716797778806, 'fraction_numerical': 0.10288446706771556, 'mean_word_length': 6.394639292842886, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '17', 'dir': 'jupyter-structured-clean-dedup', 'id': '652699', 'license': 'MIT', 'n_tokens_mistral': 12674, 'n_tokens_neox': 10685, 'n_words': 1763, 'path': 'notebooks/2_generate_baseline_emissions.ipynb', 'repo_name': 'chrisroadmap/cop26-pathways', 'size': '25932'}