コード例 #1
0
  def __init__(self, scenario=None):
    if scenario is None:
      scenario = list(scenarios.keys())[0]
    self.scenario = scenario
    self.ac = scenarios[scenario]

    # TAM
    tamconfig_list = [
      ['param', 'World', 'PDS World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['source_until_2014', self.ac.source_until_2014, self.ac.source_until_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['source_after_2014', self.ac.ref_source_post_2014, self.ac.pds_source_post_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['trend', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    tamconfig = pd.DataFrame(tamconfig_list[1:], columns=tamconfig_list[0], dtype=np.object).set_index('param')
    self.tm = tam.TAM(tamconfig=tamconfig, tam_ref_data_sources=rrs.energy_tam_1_ref_data_sources,
      tam_pds_data_sources=rrs.energy_tam_1_pds_data_sources)
    ref_tam_per_region=self.tm.ref_tam_per_region()
    pds_tam_per_region=self.tm.pds_tam_per_region()

    adconfig_list = [
      ['param', 'World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['trend', self.ac.soln_pds_adoption_prognostication_trend, '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', self.ac.soln_pds_adoption_prognostication_growth, 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    adconfig = pd.DataFrame(adconfig_list[1:], columns=adconfig_list[0], dtype=np.object).set_index('param')
    ad_data_sources = {
      'Region: OECD90': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
        },
      },
      'Region: Eastern Europe': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
        },
      },
      'Region: Asia (Sans Japan)': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
        },
      },
      'Region: Middle East and Africa': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
          'Based on Greenpeace (2015) Reference Scen- CHP Electricity Included - Modified to include Renewable and NonRenewable Waste by Erika Boeing, 2016 - See Adoption Factoring!': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Reference_Scen_CHP_Electricity_Included_Modified_to_include_Ren_ceb5044c.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
          'Based on: Greenpeace 2015 Energy Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
        },
        '100% RES2050 Case': {
          'Based on: Greenpeace 2015 Advanced Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
        },
      },
      'Region: Latin America': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
          'Based on: Greenpeace 2015 Energy Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
          'Based on: Greenpeace 2015 Advanced Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
        },
        '100% RES2050 Case': {
          'Based on: Greenpeace 2015 Advanced Revolution.1': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution_1.csv'),
        },
      },
      'Region: China': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
          'Based on: IEA ETP 2016 6DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
          'Based on: IEA ETP 2016 4DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
          'Based on: Greenpeace 2015 Energy Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
          'Based on IEA (2016) 2DS  Modified to include Renewable and NonRenewable Waste by Erika Boeing, 2016, see Adoption_Factoring!': THISDIR.joinpath('ad', 'ad_based_on_IEA_2016_2DS_Modified_to_include_Renewable_and_NonRenewable_Waste_by_Erika_Boei_c94b414a.csv'),
          'Based on: Greenpeace 2015 Advanced Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
        },
        '100% RES2050 Case': {
          'Based on: Greenpeace 2015 Advanced Revolution.1': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution_1.csv'),
        },
      },
      'Region: India': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
          'Based on: IEA ETP 2016 6DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
          'Based on: IEA ETP 2016 4DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
          'Based on: Greenpeace 2015 Energy Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
          'Based on: IEA ETP 2016 2DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
          'Based on: Greenpeace 2015 Advanced Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
        },
        '100% RES2050 Case': {
          'Based on: Greenpeace 2015 Advanced Revolution.1': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution_1.csv'),
        },
      },
      'Region: EU': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
          'Based on: IEA ETP 2016 6DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
          'Based on: IEA ETP 2016 4DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
          'Based on: Greenpeace 2015 Energy Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
          'Based on: IEA ETP 2016 2DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
          'Based on: Greenpeace 2015 Advanced Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
        },
        '100% RES2050 Case': {
          'Based on: Greenpeace 2015 Advanced Revolution.1': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution_1.csv'),
        },
      },
      'Region: USA': {
        'Baseline Cases': {
          'Monni et al Methodology,Decreasing Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_MethodologyDecreasing_Cap_Customized_Prognostication_by_Erika_Boeing_2016_Se_e9ca4246.csv'),
          'Based on: IEA ETP 2016 6DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
        },
        'Conservative Cases': {
          'Monni et al Methodology, 48.2% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_48_2_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_was_85599acc.csv'),
          'Based on: IEA ETP 2016 4DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
          'Based on: Greenpeace 2015 Energy Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
        },
        'Ambitious Cases': {
          'Monni et al Methodology, 75% Cap, Customized Prognostication by Erika Boeing, 2016, See waste_toWTE and wte_electricity tabs': THISDIR.joinpath('ad', 'ad_Monni_et_al_Methodology_75_Cap_Customized_Prognostication_by_Erika_Boeing_2016_See_waste_8d463c6a.csv'),
          'Based on: IEA ETP 2016 2DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
          'Based on: Greenpeace 2015 Advanced Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
        },
        '100% RES2050 Case': {
          'Based on: Greenpeace 2015 Advanced Revolution.1': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution_1.csv'),
        },
      },
    }
    self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
        adconfig=adconfig)

    # Custom PDS Data
    ca_pds_data_sources = [
      {'name': 'Baseline Case_ Monni et al Methodology,Decreasing Cap', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Baseline_Case__Monni_et_al_MethodologyDecreasing_Cap.csv')},
      {'name': 'Based on: IEA ETP 2016 6DS', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_based_on_IEA_ETP_2016_6DS.csv')},
      {'name': 'Drawdown Scenario Integrated Adoption', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Drawdown_Scenario_Integrated_Adoption.csv')},
      {'name': 'Optimum Scenario Integrated Adoption', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Optimum_Scenario_Integrated_Adoption.csv')},
      {'name': 'Monni et al Methodology, 48.2% Cap,', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Monni_et_al_Methodology_48_2_Cap.csv')},
      {'name': 'Based on: IEA ETP 2016 4DS', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_based_on_IEA_ETP_2016_4DS.csv')},
      {'name': 'Based on: Greenpeace 2015 Reference', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_based_on_Greenpeace_2015_Reference.csv')},
      {'name': 'Monni et al Methodology, 75% Cap,', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Monni_et_al_Methodology_75_Cap.csv')},
      {'name': 'Based on: IEA ETP 2016 Annex', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_based_on_IEA_ETP_2016_Annex.csv')},
      {'name': 'Based on: IEA ETP 2016 2DS', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_based_on_IEA_ETP_2016_2DS.csv')},
    ]
    self.pds_ca = customadoption.CustomAdoption(data_sources=ca_pds_data_sources,
        soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
        high_sd_mult=1.0, low_sd_mult=1.0,
        total_adoption_limit=pds_tam_per_region)

    ref_adoption_data_per_region = None

    if False:
      # One may wonder why this is here. This file was code generated.
      # This 'if False' allows subsequent conditions to all be elif.
      pass
    elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
      pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region()
      pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region()
      pds_adoption_is_single_source = None
    elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
      pds_adoption_data_per_region = self.ad.adoption_data_per_region()
      pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
      pds_adoption_is_single_source = self.ad.adoption_is_single_source()

    ht_ref_adoption_initial = pd.Series(
      [87.6267887442796, 51.17031245078304, 2.2000998651967416, 29.05180238687869, 2.1836150772536023,
       10.670422548840941, 12.355592643914243, 4.801134096492596, 74.56251675648713, 27.036465455169868],
       index=dd.REGIONS)
    ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
    ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
    ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
    ht_pds_adoption_initial = ht_ref_adoption_initial
    ht_regions, ht_percentages = zip(*self.ac.pds_adoption_final_percentage)
    ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages), index=list(ht_regions))
    ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[2050]
    ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
    ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
    self.ht = helpertables.HelperTables(ac=self.ac,
        ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
        pds_adoption_data_per_region=pds_adoption_data_per_region,
        ref_adoption_limits=ref_tam_per_region, pds_adoption_limits=pds_tam_per_region,
        pds_adoption_trend_per_region=pds_adoption_trend_per_region,
        pds_adoption_is_single_source=pds_adoption_is_single_source)

    self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

    self.ua = unitadoption.UnitAdoption(ac=self.ac,
        ref_total_adoption_units=ref_tam_per_region, pds_total_adoption_units=pds_tam_per_region,
        soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
        soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
        bug_cfunits_double_count=True)
    soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
    soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
    conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
    soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

    self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
        ref_learning_increase_mult=2, conv_learning_increase_mult=2,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_tot_iunits=conv_ref_tot_iunits,
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        fc_convert_iunit_factor=rrs.TERAWATT_TO_KILOWATT)

    self.oc = operatingcost.OperatingCost(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
        soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
        soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
        conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
        single_iunit_purchase_year=2017,
        soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
        conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
        conversion_factor=rrs.TERAWATT_TO_KILOWATT)

    self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

    self.c2 = co2calcs.CO2Calcs(ac=self.ac,
        ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
        soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
        soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
        soln_pds_direct_co2_emissions_saved=self.ua.soln_pds_direct_co2_emissions_saved(),
        soln_pds_direct_ch4_co2_emissions_saved=self.ua.soln_pds_direct_ch4_co2_emissions_saved(),
        soln_pds_direct_n2o_co2_emissions_saved=self.ua.soln_pds_direct_n2o_co2_emissions_saved(),
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
        conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        fuel_in_liters=False)

    self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014, 'World'],
        soln_avg_annual_use=self.ac.soln_avg_annual_use,
        conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #2
0
ファイル: __init__.py プロジェクト: benibienz/drawdown
  def __init__(self, scenario=None):
    if scenario is None:
      scenario = list(scenarios.keys())[0]
    self.scenario = scenario
    self.ac = scenarios[scenario]

    # TLA
    self.ae = aez.AEZ(solution_name=self.name)
    if self.ac.use_custom_tla:
      self.c_tla = tla.CustomTLA(filename=THISDIR.joinpath('custom_tla_data.csv'))
      custom_world_vals = self.c_tla.get_world_values()
    else:
      custom_world_vals = None
    self.tla_per_region = tla.tla_per_region(self.ae.get_land_distribution(), custom_world_values=custom_world_vals)

    # Custom PDS Data
    ca_pds_data_sources = [
      {'name': 'Optimistic-Achieve Commitment in 15 years w/ 100% intact, NYDF/2030 (Charlotte Wheeler, 2016)', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_OptimisticAchieve_Commitment_in_15_years_w_100_intact_NYDF2030_Charlotte_Wheeler_2016.csv')},
      {'name': 'Optimistic-Achieve Commitment in 15 years w/ 100% intact, WRI/2030 (Charlotte Wheeler, 2016)', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_OptimisticAchieve_Commitment_in_15_years_w_100_intact_WRI2030_Charlotte_Wheeler_2016.csv')},
      {'name': 'Conservative-Achieve Commitment in 15 years w/ 32.8% intact, WRI/2030 (Charlotte Wheeler,2016)', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_ConservativeAchieve_Commitment_in_15_years_w_32_8_intact_WRI2030_Charlotte_Wheeler2016.csv')},
      {'name': 'Conservative-Achieve Commitment in 15 years w/ 32.8% intact with continued growth post-2030, WRI/2030 and beyond (Charlotte Wheeler,2016)', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_ConservativeAchieve_Commitment_in_15_years_w_32_8_intact_with_continued_growth_post2030__5a53995a.csv')},
      {'name': 'Conservative-Achieve Commitment in 30 years w/ 100% intact, WRI/2045 (Charlotte Wheeler,2016)', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_ConservativeAchieve_Commitment_in_30_years_w_100_intact_WRI2045_Charlotte_Wheeler2016.csv')},
      {'name': 'Conservative-Achieve Commitment in 30 years w/ 32.8% intact, WRI/2045 (Charlotte Wheeler,2016)', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_ConservativeAchieve_Commitment_in_30_years_w_32_8_intact_WRI2045_Charlotte_Wheeler2016.csv')},
      {'name': 'Conservative-Achieve Commitment in 30 years w/ 32.8% intact with continued growth, WRI/2045 (Charlotte Wheeler,2016)', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_ConservativeAchieve_Commitment_in_30_years_w_32_8_intact_with_continued_growth_WRI2045_C_bcd9d435.csv')},
      {'name': 'Conservative-Achieve Commitment in 45 years w/ 100% intact, WRI/2060 (Charlotte Wheeler,2016)', 'include': False,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_ConservativeAchieve_Commitment_in_45_years_w_100_intact_WRI2060_Charlotte_Wheeler2016.csv')},
      {'name': 'Conservative-Achieve Commitment in 45 years w/ 32.8% intact, WRI/2060 (Charlotte Wheeler,2016)', 'include': False,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_ConservativeAchieve_Commitment_in_45_years_w_32_8_intact_WRI2060_Charlotte_Wheeler2016.csv')},
    ]
    self.pds_ca = customadoption.CustomAdoption(data_sources=ca_pds_data_sources,
        soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
        high_sd_mult=1.0, low_sd_mult=1.0,
        total_adoption_limit=self.tla_per_region)


    if False:
      # One may wonder why this is here. This file was code generated.
      # This 'if False' allows subsequent conditions to all be elif.
      pass
    elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
      pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region()
      pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region()
      pds_adoption_is_single_source = None

    ht_ref_adoption_initial = pd.Series(
      [0.0, 0.0, 0.0, 0.0, 0.0,
       0.0, 0.0, 0.0, 0.0, 0.0],
       index=dd.REGIONS)
    ht_ref_adoption_final = self.tla_per_region.loc[2050] * (ht_ref_adoption_initial / self.tla_per_region.loc[2014])
    ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
    ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
    ht_pds_adoption_initial = ht_ref_adoption_initial
    ht_regions, ht_percentages = zip(*self.ac.pds_adoption_final_percentage)
    ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages), index=list(ht_regions))
    ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[2050]
    ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
    ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
    self.ht = helpertables.HelperTables(ac=self.ac,
        ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
        pds_adoption_data_per_region=pds_adoption_data_per_region,
        ref_adoption_limits=self.tla_per_region, pds_adoption_limits=self.tla_per_region,
        pds_adoption_trend_per_region=pds_adoption_trend_per_region,
        pds_adoption_is_single_source=pds_adoption_is_single_source)

    self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

    self.ua = unitadoption.UnitAdoption(ac=self.ac,
        ref_total_adoption_units=self.tla_per_region, pds_total_adoption_units=self.tla_per_region,
        electricity_unit_factor=1000000.0,
        soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
        soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
        bug_cfunits_double_count=True)
    soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
    soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
    conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
    soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

    self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
        ref_learning_increase_mult=2, conv_learning_increase_mult=2,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_tot_iunits=conv_ref_tot_iunits,
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        conv_ref_first_cost_uses_tot_units=True,
        fc_convert_iunit_factor=land.MHA_TO_HA)

    self.oc = operatingcost.OperatingCost(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
        soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
        soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
        conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
        single_iunit_purchase_year=2017,
        soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
        conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
        conversion_factor=land.MHA_TO_HA)

    self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
        soln_pds_direct_ch4_co2_emissions_saved=self.ua.direct_ch4_co2_emissions_saved_land(),
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

    self.c2 = co2calcs.CO2Calcs(ac=self.ac,
        ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
        soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
        soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
        soln_pds_direct_co2eq_emissions_saved=self.ua.direct_co2eq_emissions_saved_land(),
        soln_pds_direct_co2_emissions_saved=self.ua.direct_co2_emissions_saved_land(),
        soln_pds_direct_n2o_co2_emissions_saved=self.ua.direct_n2o_co2_emissions_saved_land(),
        soln_pds_direct_ch4_co2_emissions_saved=self.ua.direct_ch4_co2_emissions_saved_land(),
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
        conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        annual_land_area_harvested=self.ua.soln_pds_annual_land_area_harvested(),
        regime_distribution=self.ae.get_land_distribution())
コード例 #3
0
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TLA
        self.ae = aez.AEZ(solution_name=self.name)
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution())

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Conservative-Low, Linear Trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeLow_Linear_Trend.csv')
            },
            {
                'name':
                'Conservative-Medium, Linear Trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeMedium_Linear_Trend.csv')
            },
            {
                'name':
                'High-linear trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Highlinear_trend.csv')
            },
            {
                'name':
                'High-high early growth, linear trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Highhigh_early_growth_linear_trend.csv')
            },
            {
                'name':
                'High, very high early growth, linear trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_High_very_high_early_growth_linear_trend.csv'
                )
            },
            {
                'name':
                'Max, high early growth, linear trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Max_high_early_growth_linear_trend.csv')
            },
            {
                'name':
                'Aggressive Max, urgent adoption',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Aggressive_Max_urgent_adoption.csv')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None

        ht_ref_adoption_initial = pd.Series(
            [3.27713, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (
            ht_ref_adoption_initial / self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=self.tla_per_region,
            pds_adoption_limits=self.tla_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=self.tla_per_region,
            pds_total_adoption_units=self.tla_per_region,
            electricity_unit_factor=1000000.0,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_first_cost_uses_tot_units=True,
            fc_convert_iunit_factor=land.MHA_TO_HA)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=land.MHA_TO_HA)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            tot_red_in_deg_land=self.ua.
            cumulative_reduction_in_total_degraded_land(),
            pds_protected_deg_land=self.ua.
            pds_cumulative_degraded_land_protected(),
            ref_protected_deg_land=self.ua.
            ref_cumulative_degraded_land_protected(),
            regime_distribution=self.ae.get_land_distribution())
コード例 #4
0
  def __init__(self, scenario=None):
    if scenario is None:
      scenario = list(scenarios.keys())[0]
    self.scenario = scenario
    self.ac = scenarios[scenario]

    # TAM
    tamconfig_list = [
      ['param', 'World', 'PDS World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['source_until_2014', self.ac.source_until_2014, self.ac.source_until_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['source_after_2014', self.ac.ref_source_post_2014, self.ac.pds_source_post_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['trend', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    tamconfig = pd.DataFrame(tamconfig_list[1:], columns=tamconfig_list[0], dtype=np.object).set_index('param')
    self.tm = tam.TAM(tamconfig=tamconfig, tam_ref_data_sources=rrs.tam_ref_data_sources,
      tam_pds_data_sources=rrs.tam_pds_data_sources)
    ref_tam_per_region=self.tm.ref_tam_per_region()
    pds_tam_per_region=self.tm.pds_tam_per_region()

    adconfig_list = [
      ['param', 'World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['trend', self.ac.soln_pds_adoption_prognostication_trend, '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', self.ac.soln_pds_adoption_prognostication_growth, 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    adconfig = pd.DataFrame(adconfig_list[1:], columns=adconfig_list[0], dtype=np.object).set_index('param')
    ad_data_sources = {
      'Baseline Cases': {
          'Based on: SWWR 2016 extrapolation (S curve)': THISDIR.joinpath('ad', 'ad_based_on_SWWR_2016_extrapolation_S_curve.csv'),
          'Based on: IEA ETP 2016 6DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
          'Based on: AMPERE 2014 MESSAGE MACRO Reference': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_Reference.csv'),
          'Based on: AMPERE 2014 GEM E3 Reference': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_GEM_E3_Reference.csv'),
      },
      'Conservative Cases': {
          'Based on SWWR 2016 extrapolation (linear)': THISDIR.joinpath('ad', 'ad_based_on_SWWR_2016_extrapolation_linear.csv'),
          'Based on: IEA ETP 2016 4DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
          'Based on: AMPERE 2014 MESSAGE MACRO 550': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_550.csv'),
          'Based on: AMPERE 2014 GEM E3 550': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_GEM_E3_550.csv'),
          'Based on: AMPERE 2014 IMAGE TIMER 550': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_550.csv'),
      },
      'Ambitious Cases': {
          'Based on: IEA ETP 2016 2DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
          'Based on: AMPERE 2014 MESSAGE MACRO 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_450.csv'),
          'Based on: AMPERE 2014 GEM E3 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_GEM_E3_450.csv'),
          'Based on: AMPERE 2014 IMAGE TIMER 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_450.csv'),
          'Based on: Greenpeace 2015 Energy Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
      },
      '100% RES2050 Case': {
          'Based on: Greenpeace 2015 Advanced Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
      },
    }
    self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
        adconfig=adconfig)

    ref_adoption_data_per_region = None

    if False:
      # One may wonder why this is here. This file was code generated.
      # This 'if False' allows subsequent conditions to all be elif.
      pass
    elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
      pds_adoption_data_per_region = self.ad.adoption_data_per_region()
      pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
      pds_adoption_is_single_source = self.ad.adoption_is_single_source()

    ht_ref_adoption_initial = pd.Series(
      [1.4839924067703905, 0.8270896918586633, 0.02591480263096046, 0.6209258199488832, 0.0,
       0.01063400521753205, 0.6140914609653803, 0.004289346642365869, 0.3857891986976892, 0.40391347548945267],
       index=dd.REGIONS)
    ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
    ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
    ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
    ht_pds_adoption_initial = ht_ref_adoption_initial
    ht_regions, ht_percentages = zip(*self.ac.pds_adoption_final_percentage)
    ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages), index=list(ht_regions))
    ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[2050]
    ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
    ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
    self.ht = helpertables.HelperTables(ac=self.ac,
        ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
        pds_adoption_data_per_region=pds_adoption_data_per_region,
        ref_adoption_limits=ref_tam_per_region, pds_adoption_limits=pds_tam_per_region,
        pds_adoption_trend_per_region=pds_adoption_trend_per_region,
        pds_adoption_is_single_source=pds_adoption_is_single_source)

    self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

    self.ua = unitadoption.UnitAdoption(ac=self.ac,
        ref_total_adoption_units=ref_tam_per_region, pds_total_adoption_units=pds_tam_per_region,
        soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
        soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
        bug_cfunits_double_count=True)
    soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
    soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
    conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
    soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

    self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
        ref_learning_increase_mult=2, conv_learning_increase_mult=2,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_tot_iunits=conv_ref_tot_iunits,
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        fc_convert_iunit_factor=rrs.TERAWATT_TO_KILOWATT)

    self.oc = operatingcost.OperatingCost(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
        soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
        soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
        conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
        single_iunit_purchase_year=2017,
        soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
        conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
        conversion_factor=rrs.TERAWATT_TO_KILOWATT)

    self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

    self.c2 = co2calcs.CO2Calcs(ac=self.ac,
        ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
        soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
        soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
        soln_pds_direct_co2_emissions_saved=self.ua.soln_pds_direct_co2_emissions_saved(),
        soln_pds_direct_ch4_co2_emissions_saved=self.ua.soln_pds_direct_ch4_co2_emissions_saved(),
        soln_pds_direct_n2o_co2_emissions_saved=self.ua.soln_pds_direct_n2o_co2_emissions_saved(),
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
        conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        fuel_in_liters=False)

    self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014, 'World'],
        soln_avg_annual_use=self.ac.soln_avg_annual_use,
        conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #5
0
ファイル: __init__.py プロジェクト: scottwedge/solutions
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Low', 'Low', 'Medium', 'Medium', 'Low', 'Medium',
                'Medium', 'Low', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'What a Waste Solid Waste Management Static':
                THISDIR.joinpath(
                    'tam',
                    'tam_What_a_Waste_Solid_Waste_Management_Static.csv'),
                'What a Waste Solid Waste Management Dynamic':
                THISDIR.joinpath(
                    'tam',
                    'tam_What_a_Waste_Solid_Waste_Management_Dynamic.csv'),
                'What a Waste Solid Waste Management Dynamic Organic Fraction':
                THISDIR.joinpath(
                    'tam',
                    'tam_What_a_Waste_Solid_Waste_Management_Dynamic_Organic_Fraction.csv'
                ),
            },
            'Conservative Cases': {
                'Bahor et al (2009) DOI: 10.1177/0734242X09350485 - interpolated and organic fraction from What a  Waste applied':
                THISDIR.joinpath(
                    'tam',
                    'tam_Bahor_et_al_2009_DOI_10_11770734242X09350485_interpolated_and_organic_fraction_from_What_95c7eead.csv'
                ),
                'IPCC, 2006 - Calculated based on bottom up analysis':
                THISDIR.joinpath(
                    'tam',
                    'tam_IPCC_2006_Calculated_based_on_bottom_up_analysis.csv'
                ),
                'IPCC, 2006 - Calculated based on top down analysis':
                THISDIR.joinpath(
                    'tam',
                    'tam_IPCC_2006_Calculated_based_on_top_down_analysis.csv'),
            },
            'Ambitious Cases': {
                'Hoornweg et al 2015':
                THISDIR.joinpath('tam', 'tam_Hoornweg_et_al_2015.csv'),
            },
            'Region: OECD90': {
                'Baseline Cases': {
                    'What a Waste Solid Waste Management Static':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Static.csv'),
                    'What a Waste Solid Waste Management Dynamic':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Dynamic.csv'),
                    'Hoornweg et al 2015':
                    THISDIR.joinpath('tam', 'tam_Hoornweg_et_al_2015.csv'),
                },
                'Conservative Cases': {
                    'Bahor et al (2009) DOI: 10.1177/0734242X09350485 - interpolated and organic fraction from What a  Waste applied':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Bahor_et_al_2009_DOI_10_11770734242X09350485_interpolated_and_organic_fraction_from_What_95c7eead.csv'
                    ),
                    'OECD Data. http://www.eea.europa.eu/data-and-maps/figures/municipal-waste-generation-within-the-oecd-area':
                    THISDIR.joinpath(
                        'tam',
                        'tam_OECD_Data__httpwww_eea_europa_eudataandmapsfiguresmunicipalwastegenerationwithintheoecdarea.csv'
                    ),
                },
                'Ambitious Cases': {
                    'What a Waste Solid Waste Management Dynamic Organic Fraction':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Dynamic_Organic_Fraction.csv'
                    ),
                    'IPCC, 2006 - Calculated based on bottom up analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_bottom_up_analysis.csv'
                    ),
                    'IPCC, 2006 - Calculated based on top down analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_top_down_analysis.csv'
                    ),
                },
            },
            'Region: Eastern Europe': {
                'Baseline Cases': {
                    'What a Waste Solid Waste Management Static':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Static.csv'),
                    'What a Waste Solid Waste Management Dynamic Organic Fraction':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Dynamic_Organic_Fraction.csv'
                    ),
                    'Bahor et al (2009) DOI: 10.1177/0734242X09350485 - interpolated and organic fraction from What a  Waste applied':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Bahor_et_al_2009_DOI_10_11770734242X09350485_interpolated_and_organic_fraction_from_What_95c7eead.csv'
                    ),
                },
                'Conservative Cases': {
                    'What a Waste Solid Waste Management Dynamic':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Dynamic.csv'),
                },
                'Ambitious Cases': {
                    'Hoornweg et al 2015':
                    THISDIR.joinpath('tam', 'tam_Hoornweg_et_al_2015.csv'),
                    'IPCC, 2006 - Calculated based on bottom up analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_bottom_up_analysis.csv'
                    ),
                    'IPCC, 2006 - Calculated based on top down analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_top_down_analysis.csv'
                    ),
                },
            },
            'Region: Middle East and Africa': {
                'Baseline Cases': {
                    'What a Waste Solid Waste Management Static':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Static.csv'),
                    'Bahor et al (2009) DOI: 10.1177/0734242X09350485 - interpolated and organic fraction from What a  Waste applied':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Bahor_et_al_2009_DOI_10_11770734242X09350485_interpolated_and_organic_fraction_from_What_95c7eead.csv'
                    ),
                    'Hoornweg et al 2015':
                    THISDIR.joinpath('tam', 'tam_Hoornweg_et_al_2015.csv'),
                },
                'Conservative Cases': {
                    'IPCC, 2006 - Calculated based on top down analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_top_down_analysis.csv'
                    ),
                    'IPCC, 2006 - Calculated based on bottom up analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_bottom_up_analysis.csv'
                    ),
                    'Bahor et al (2009) DOI: 10.1177/0734242X09350485 - interpolated and organic fraction from What a  Waste applied.1':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Bahor_et_al_2009_DOI_10_11770734242X09350485_interpolated_and_organic_fraction_from_What_35ed52f6.csv'
                    ),
                },
                'Ambitious Cases': {
                    'What a Waste Solid Waste Management Dynamic':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Dynamic.csv'),
                },
            },
            'Region: Latin America': {
                'Baseline Cases': {
                    'What a Waste Solid Waste Management Static':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Static.csv'),
                    'What a Waste Solid Waste Management Dynamic':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Dynamic.csv'),
                    'Bahor et al (2009) DOI: 10.1177/0734242X09350485 - interpolated and organic fraction from What a  Waste applied':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Bahor_et_al_2009_DOI_10_11770734242X09350485_interpolated_and_organic_fraction_from_What_95c7eead.csv'
                    ),
                },
                'Conservative Cases': {
                    'What a Waste Solid Waste Management Dynamic Organic Fraction':
                    THISDIR.joinpath(
                        'tam',
                        'tam_What_a_Waste_Solid_Waste_Management_Dynamic_Organic_Fraction.csv'
                    ),
                },
                'Ambitious Cases': {
                    'IPCC, 2006 - Calculated based on top down analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_top_down_analysis.csv'
                    ),
                    'IPCC, 2006 - Calculated based on bottom up analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_bottom_up_analysis.csv'
                    ),
                    'Hoornweg et al 2015':
                    THISDIR.joinpath('tam', 'tam_Hoornweg_et_al_2015.csv'),
                },
            },
            'Region: China': {
                'Baseline Cases': {
                    'World Bank': THISDIR.joinpath('tam',
                                                   'tam_World_Bank.csv'),
                },
                'Conservative Cases': {
                    'What a Waste':
                    THISDIR.joinpath('tam', 'tam_What_a_Waste.csv'),
                    'IPCC, 2006 - Calculated based on bottom up analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_bottom_up_analysis.csv'
                    ),
                },
            },
            'Region: India': {
                'Baseline Cases': {
                    'Kumar, Sunil. Municipal Solid Waste Management in India: Present Practices and Future Challenge. Clean Development Mechanism, United Nations Framework Convention on Climate Change':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Kumar_Sunil__Municipal_Solid_Waste_Management_in_India_Present_Practices_and_Future_Chal_a1d3f433.csv'
                    ),
                    'IPCC, 2006 - Calculated based on bottom up analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_bottom_up_analysis.csv'
                    ),
                    'IPCC, 2006 - Calculated based on top down analysis':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IPCC_2006_Calculated_based_on_top_down_analysis.csv'
                    ),
                },
                'Maximum Cases': {
                    'CPCB, Satus of MSW India, 2000':
                    THISDIR.joinpath('tam',
                                     'tam_CPCB_Satus_of_MSW_India_2000.csv'),
                },
            },
            'Region: EU': {
                'Baseline Cases': {
                    'IPCC, 2006 Calculated':
                    THISDIR.joinpath('tam', 'tam_IPCC_2006_Calculated.csv'),
                },
                'Maximum Cases': {
                    'EUROSTAT, Municipal Solid Waste Statistics, 2016':
                    THISDIR.joinpath(
                        'tam',
                        'tam_EUROSTAT_Municipal_Solid_Waste_Statistics_2016.csv'
                    ),
                },
            },
            'Region: USA': {
                'Baseline Cases': {
                    'EPA, Municipal Solid Waste Generation, Recycling, and Disposal in the United States: Facts and Figures for 2012':
                    THISDIR.joinpath(
                        'tam',
                        'tam_EPA_Municipal_Solid_Waste_Generation_Recycling_and_Disposal_in_the_United_States_Facts_a_7fa2141a.csv'
                    ),
                },
                'Ambitious Cases': {
                    'OECD.stat (http://stats.oecd.org/Index.aspx?DataSetCode=MUNW)':
                    THISDIR.joinpath(
                        'tam',
                        'tam_OECD_stat_httpstats_oecd_orgIndex_aspxDataSetCodeMUNW.csv'
                    ),
                },
                'Maximum Cases': {
                    'IPCC, 2006 Calculated':
                    THISDIR.joinpath('tam', 'tam_IPCC_2006_Calculated.csv'),
                },
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          main_includes_regional=True,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Baseline Cases': {
                'Calculated based on What a Waste and USA as PDS Benchmark (See Adoption Factoring)':
                THISDIR.joinpath(
                    'ad',
                    'ad_Calculated_based_on_What_a_Waste_and_USA_as_PDS_Benchmark_See_Adoption_Factoring.csv'
                ),
            },
            'Conservative Cases': {
                'IPCC, 2006 Calculated':
                THISDIR.joinpath('ad', 'ad_IPCC_2006_Calculated.csv'),
            },
            'Ambitious Cases': {
                'Calculated based on What a Waste and EU as PDS Benchmark (See Adoption Factoring)':
                THISDIR.joinpath(
                    'ad',
                    'ad_Calculated_based_on_What_a_Waste_and_EU_as_PDS_Benchmark_See_Adoption_Factoring.csv'
                ),
            },
            'Region: OECD90': {
                'Baseline Cases': {
                    'OECD.stat (http://stats.oecd.org/Index.aspx?DataSetCode=MUNW)':
                    THISDIR.joinpath(
                        'ad',
                        'ad_OECD_stat_httpstats_oecd_orgIndex_aspxDataSetCodeMUNW.csv'
                    ),
                },
                'Conservative Cases': {
                    'IPCC, 2006 Calculated':
                    THISDIR.joinpath('ad', 'ad_IPCC_2006_Calculated.csv'),
                },
                'Ambitious Cases': {
                    'OECD.stat (http://stats.oecd.org/Index.aspx?DataSetCode=MUNW).1':
                    THISDIR.joinpath(
                        'ad',
                        'ad_OECD_stat_httpstats_oecd_orgIndex_aspxDataSetCodeMUNW_1.csv'
                    ),
                },
            },
            'Region: Asia (Sans Japan)': {
                'Baseline Cases': {
                    'IPCC, 2006 Calculated':
                    THISDIR.joinpath('ad', 'ad_IPCC_2006_Calculated.csv'),
                },
                'Conservative Cases': {
                    'Calculated based on What a Waste and USA as PDS Benchmark (See Adoption Factoring)':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Calculated_based_on_What_a_Waste_and_USA_as_PDS_Benchmark_See_Adoption_Factoring.csv'
                    ),
                },
                'Ambitious Cases': {
                    'Calculated based on What a Waste and EU as PDS Benchmark (See Adoption Factoring)':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Calculated_based_on_What_a_Waste_and_EU_as_PDS_Benchmark_See_Adoption_Factoring.csv'
                    ),
                },
            },
            'Region: Middle East and Africa': {
                'Baseline Cases': {
                    'IPCC, 2006 Calculated':
                    THISDIR.joinpath('ad', 'ad_IPCC_2006_Calculated.csv'),
                    'Calculated based on What a Waste and USA as PDS Benchmark (See Adoption Factoring)':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Calculated_based_on_What_a_Waste_and_USA_as_PDS_Benchmark_See_Adoption_Factoring.csv'
                    ),
                },
                'Ambitious Cases': {
                    'Calculated based on What a Waste and EU as PDS Benchmark (See Adoption Factoring)':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Calculated_based_on_What_a_Waste_and_EU_as_PDS_Benchmark_See_Adoption_Factoring.csv'
                    ),
                },
            },
            'Region: China': {
                'Baseline Cases': {
                    'Song, L. et al. Study on the Current Situation of Municipal Solid Waste Composting in China and Development Trend. 2012':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Song_L__et_al__Study_on_the_Current_Situation_of_Municipal_Solid_Waste_Composting_in_Chi_f57570b9.csv'
                    ),
                },
                'Conservative Cases': {
                    'IPCC, 2006 Calculated':
                    THISDIR.joinpath('ad', 'ad_IPCC_2006_Calculated.csv'),
                },
            },
            'Region: India': {
                'Baseline Cases': {
                    'Kharvel, R. Sustainable Solid Waste Management in Inidia. SEAS, Columbia Thesis. 2012':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Kharvel_R__Sustainable_Solid_Waste_Management_in_Inidia__SEAS_Columbia_Thesis__2012.csv'
                    ),
                },
            },
            'Region: EU': {
                'Baseline Cases': {
                    'EUROSTAT, 2016. http://ec.europa.eu/eurostat/statistics-explained/index.php/Municipal_waste_statistics':
                    THISDIR.joinpath(
                        'ad',
                        'ad_EUROSTAT_2016__httpec_europa_eueurostatstatisticsexplainedindex_phpMunicipal_waste_statistics.csv'
                    ),
                    'OECD.stat (http://stats.oecd.org/Index.aspx?DataSetCode=MUNW)':
                    THISDIR.joinpath(
                        'ad',
                        'ad_OECD_stat_httpstats_oecd_orgIndex_aspxDataSetCodeMUNW.csv'
                    ),
                },
            },
            'Region: USA': {
                'Baseline Cases': {
                    'EPA, MSW trends, 2012 https://www.epa.gov/sites/production/files/2015-09/documents/2012_msw_fs.pdf':
                    THISDIR.joinpath(
                        'ad',
                        'ad_EPA_MSW_trends_2012_httpswww_epa_govsitesproductionfiles201509documents2012_msw_fs_pdf.csv'
                    ),
                    'IPCC, 2006 Calculated':
                    THISDIR.joinpath('ad', 'ad_IPCC_2006_Calculated.csv'),
                    'OECD.stat (http://stats.oecd.org/Index.aspx?DataSetCode=MUNW)':
                    THISDIR.joinpath(
                        'ad',
                        'ad_OECD_stat_httpstats_oecd_orgIndex_aspxDataSetCodeMUNW.csv'
                    ),
                },
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            main_includes_regional=True,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Drawdown Customized Scenario 1',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Customized_Scenario_1.csv')
            },
            {
                'name':
                'Drawdown Customized Scenario 2',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Customized_Scenario_2.csv')
            },
            {
                'name':
                'Drawdown Customized Scenario 3',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Customized_Scenario_3.csv')
            },
            {
                'name':
                'Drawdown Customized Scenario 4',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Customized_Scenario_4.csv')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=pds_tam_per_region)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(
            [120.0, 69.02, 4.13, 13.0, 5.66, 14.0, 2.75, 7.29, 36.8, 20.84],
            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #6
0
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'High', 'High', 'High', 'High'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Ambitious Cases': {
                'IEA, 2013, "Transition to Sustainable Buildings" – see TAM Factoring':
                THISDIR.joinpath(
                    'tam',
                    'tam_IEA_2013_Transition_to_Sustainable_Buildings_see_TAM_Factoring.csv'
                ),
                'Ürge-Vorsatz et al. (2015) – see TAM Factoring':
                THISDIR.joinpath(
                    'tam',
                    'tam_ÜrgeVorsatz_et_al__2015_see_TAM_Factoring.csv'),
            },
            'Region: China': {
                'Ambitious Cases': {
                    'IEA, 2013, "Transition to Sustainable Buildings" – see TAM Factoring':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IEA_2013_Transition_to_Sustainable_Buildings_see_TAM_Factoring.csv'
                    ),
                    'Hong et al. (2014) – see TAM Factoring':
                    THISDIR.joinpath(
                        'tam', 'tam_Hong_et_al__2014_see_TAM_Factoring.csv'),
                },
            },
            'Region: India': {
                'Ambitious Cases': {
                    'IEA, 2013, "Transition to Sustainable Buildings" – see TAM Factoring':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IEA_2013_Transition_to_Sustainable_Buildings_see_TAM_Factoring.csv'
                    ),
                    'Chaturvedi et al (2014) – see TAM Factoring':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Chaturvedi_et_al_2014_see_TAM_Factoring.csv'),
                },
            },
            'Region: EU': {
                'Ambitious Cases': {
                    'IEA, 2013, "Transition to Sustainable Buildings" – see TAM Factoring':
                    THISDIR.joinpath(
                        'tam',
                        'tam_IEA_2013_Transition_to_Sustainable_Buildings_see_TAM_Factoring.csv'
                    ),
                    'Boermans et al. (2012); BPIE (2014) – see TAM Factoring':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Boermans_et_al__2012_BPIE_2014_see_TAM_Factoring.csv'
                    ),
                },
            },
            'Region: USA': {
                'Baseline Cases': {
                    'EIA, 2016, "Annual Energy Outlook 2016" – Reference Case':
                    THISDIR.joinpath(
                        'tam',
                        'tam_EIA_2016_Annual_Energy_Outlook_2016_Reference_Case.csv'
                    ),
                    'EIA, 2016, "Annual Energy Outlook 2016" – Reference Case w/o CPP':
                    THISDIR.joinpath(
                        'tam',
                        'tam_EIA_2016_Annual_Energy_Outlook_2016_Reference_Case_wo_CPP.csv'
                    ),
                },
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        sconfig_list = [['region', 'base_year', 'last_year'],
                        ['World', 2014, 2050], ['OECD90', 2014, 2050],
                        ['Eastern Europe', 2014, 2050],
                        ['Asia (Sans Japan)', 2014, 2050],
                        ['Middle East and Africa', 2014, 2050],
                        ['Latin America', 2014, 2050], ['China', 2014, 2050],
                        ['India', 2014, 2050], ['EU', 2014, 2050],
                        ['USA', 2014, 2050]]
        sconfig = pd.DataFrame(sconfig_list[1:],
                               columns=sconfig_list[0],
                               dtype=np.object).set_index('region')
        sconfig['pds_tam_2050'] = pds_tam_per_region.loc[[2050]].T
        sc_regions, sc_percentages = zip(*self.ac.pds_base_adoption)
        sconfig['base_adoption'] = pd.Series(list(sc_percentages),
                                             index=list(sc_regions))
        sconfig['base_percent'] = sconfig[
            'base_adoption'] / pds_tam_per_region.loc[2014]
        sc_regions, sc_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        sconfig['last_percent'] = pd.Series(list(sc_percentages),
                                            index=list(sc_regions))
        if self.ac.pds_adoption_s_curve_innovation is not None:
            sc_regions, sc_percentages = zip(
                *self.ac.pds_adoption_s_curve_innovation)
            sconfig['innovation'] = pd.Series(list(sc_percentages),
                                              index=list(sc_regions))
        if self.ac.pds_adoption_s_curve_imitation is not None:
            sc_regions, sc_percentages = zip(
                *self.ac.pds_adoption_s_curve_imitation)
            sconfig['imitation'] = pd.Series(list(sc_percentages),
                                             index=list(sc_regions))
        self.sc = s_curve.SCurve(transition_period=16, sconfig=sconfig)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Logistic S-Curve':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = self.sc.logistic_adoption()
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Bass Diffusion S-Curve':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = self.sc.bass_diffusion_adoption()
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()
        elif self.ac.soln_pds_adoption_basis == 'Linear':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = None
            pds_adoption_is_single_source = None

        ht_ref_adoption_initial = pd.Series([
            16577.82591670033, 14915.99, 0.0, 1087.7709445216651, 0.0, 0.0,
            1087.7709445216651, 0.0, 3622.85, 11293.14
        ],
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            repeated_cost_for_iunits=False,
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1000000.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #7
0
ファイル: __init__.py プロジェクト: scottwedge/solutions
  def __init__(self, scenario=None):
    if scenario is None:
      scenario = list(scenarios.keys())[0]
    self.scenario = scenario
    self.ac = scenarios[scenario]

    # TAM
    tamconfig_list = [
      ['param', 'World', 'PDS World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['source_until_2014', self.ac.source_until_2014, self.ac.source_until_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['source_after_2014', self.ac.ref_source_post_2014, self.ac.pds_source_post_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['trend', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    tamconfig = pd.DataFrame(tamconfig_list[1:], columns=tamconfig_list[0], dtype=np.object).set_index('param')
    self.tm = tam.TAM(tamconfig=tamconfig, tam_ref_data_sources=rrs.energy_tam_1_ref_data_sources,
      tam_pds_data_sources=rrs.energy_tam_1_pds_data_sources)
    ref_tam_per_region=self.tm.ref_tam_per_region()
    pds_tam_per_region=self.tm.pds_tam_per_region()

    adconfig_list = [
      ['param', 'World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['trend', self.ac.soln_pds_adoption_prognostication_trend, '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', self.ac.soln_pds_adoption_prognostication_growth, 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    adconfig = pd.DataFrame(adconfig_list[1:], columns=adconfig_list[0], dtype=np.object).set_index('param')
    ad_data_sources = {
      'Baseline Cases': {
          'Based on: IEA ETP 2016 6DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
          'Based on: AMPERE 2014 MESSAGE MACRO Reference': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_Reference.csv'),
          'Based on: AMPERE 2014 GEM E3 Reference': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_GEM_E3_Reference.csv'),
          'Based on: Greenpeace Wind Outlook 2014 New Policies Scenario': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_Wind_Outlook_2014_New_Policies_Scenario.csv'),
      },
      'Conservative Cases': {
          'Based on: IEA ETP 2016 4DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
          'Based on: AMPERE 2014 MESSAGE MACRO 550': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_550.csv'),
          'Based on: AMPERE 2014 GEM E3 550': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_GEM_E3_550.csv'),
          'Based on: AMPERE 2014 IMAGE TIMER 550': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_550.csv'),
          'Based on: Greenpeace Wind Outlook 2014 Moderate Scenario': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_Wind_Outlook_2014_Moderate_Scenario.csv'),
      },
      'Ambitious Cases': {
          'Based on: IEA ETP 2016 2DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
          'Based on: AMPERE 2014 MESSAGE MACRO 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_450.csv'),
          'Based on: AMPERE 2014 GEM E3 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_GEM_E3_450.csv'),
          'Based on: AMPERE 2014 IMAGE TIMER 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_450.csv'),
          'Based on: Greenpeace Wind Outlook 2014 Advanced Scenario': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_Wind_Outlook_2014_Advanced_Scenario.csv'),
          'Based on: Greenpeace 2015 Energy Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
      },
      '100% RES2050 Case': {
          'Based on: Greenpeace 2015 Advanced Revolution': THISDIR.joinpath('ad', 'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
      },
      'Region: USA': {
        'Conservative Cases': {
          'Based on: IEA ETP 2016 4DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
          'Based on: AMPERE 2014 MESSAGE MACRO 550': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_550.csv'),
          'Based on: AMPERE 2014 IMAGE TIMER 550': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_550.csv'),
        },
        'Ambitious Cases': {
          'Based on: IEA ETP 2016 2DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
          'Based on: AMPERE 2014 GEM E3 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_GEM_E3_450.csv'),
          'Based on: AMPERE 2014 MESSAGE MACRO 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_450.csv'),
          'Based on: AMPERE 2014 IMAGE TIMER 450': THISDIR.joinpath('ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_450.csv'),
          'DOE WIND Vision Report (2015) - Study Central': THISDIR.joinpath('ad', 'ad_DOE_WIND_Vision_Report_2015_Study_Central.csv'),
          '2016 NREL Wind Technology market report': THISDIR.joinpath('ad', 'ad_2016_NREL_Wind_Technology_market_report.csv'),
        },
      },
    }
    self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
        adconfig=adconfig)

    ref_adoption_data_per_region = None

    if False:
      # One may wonder why this is here. This file was code generated.
      # This 'if False' allows subsequent conditions to all be elif.
      pass
    elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
      pds_adoption_data_per_region = self.ad.adoption_data_per_region()
      pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
      pds_adoption_is_single_source = self.ad.adoption_is_single_source()

    ht_ref_adoption_initial = pd.Series(
      [689.0, 443.891, 1.901, 194.66, 5.326,
       18.675, 157.379, 33.455, 230.075, 183.892],
       index=dd.REGIONS)
    ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
    ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
    ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
    ht_pds_adoption_initial = ht_ref_adoption_initial
    ht_regions, ht_percentages = zip(*self.ac.pds_adoption_final_percentage)
    ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages), index=list(ht_regions))
    ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[2050]
    ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
    ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
    self.ht = helpertables.HelperTables(ac=self.ac,
        ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
        pds_adoption_data_per_region=pds_adoption_data_per_region,
        ref_adoption_limits=ref_tam_per_region, pds_adoption_limits=pds_tam_per_region,
        pds_adoption_trend_per_region=pds_adoption_trend_per_region,
        pds_adoption_is_single_source=pds_adoption_is_single_source)

    self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

    self.ua = unitadoption.UnitAdoption(ac=self.ac,
        ref_total_adoption_units=ref_tam_per_region, pds_total_adoption_units=pds_tam_per_region,
        soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
        soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
        bug_cfunits_double_count=True)
    soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
    soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
    conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
    soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

    self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
        ref_learning_increase_mult=2, conv_learning_increase_mult=2,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_tot_iunits=conv_ref_tot_iunits,
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        fc_convert_iunit_factor=rrs.TERAWATT_TO_KILOWATT)

    self.oc = operatingcost.OperatingCost(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
        soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
        soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
        conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
        single_iunit_purchase_year=2017,
        soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
        conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
        conversion_factor=rrs.TERAWATT_TO_KILOWATT)

    self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

    self.c2 = co2calcs.CO2Calcs(ac=self.ac,
        ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
        soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
        soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
        soln_pds_direct_co2_emissions_saved=self.ua.soln_pds_direct_co2_emissions_saved(),
        soln_pds_direct_ch4_co2_emissions_saved=self.ua.soln_pds_direct_ch4_co2_emissions_saved(),
        soln_pds_direct_n2o_co2_emissions_saved=self.ua.soln_pds_direct_n2o_co2_emissions_saved(),
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
        conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        fuel_in_liters=False)

    self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014, 'World'],
        soln_avg_annual_use=self.ac.soln_avg_annual_use,
        conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #8
0
ファイル: __init__.py プロジェクト: benibienz/drawdown
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'Custom (See TAM Factoring) based on  http://www.gbpn.org/databases-tools/mrv-tool/methodology.':
                THISDIR.joinpath(
                    'tam',
                    'tam_Custom_See_TAM_Factoring_based_on_httpwww_gbpn_orgdatabasestoolsmrvtoolmethodology_.csv'
                ),
                'Based on GBPN - BEST PRACTICE POLICIES FOR LOW CARBON & ENERGY BUILDINGS BASED ON SCENARIO ANALYSIS May 2012':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_GBPN_BEST_PRACTICE_POLICIES_FOR_LOW_CARBON_ENERGY_BUILDINGS_BASED_ON_SCENARIO_A_c7e92439.csv'
                ),
                'IEA (2013)':
                THISDIR.joinpath('tam', 'tam_IEA_2013.csv'),
            },
            'Conservative Cases': {
                'McKinsey':
                THISDIR.joinpath('tam', 'tam_McKinsey.csv'),
                'Navigant (2014)':
                THISDIR.joinpath('tam', 'tam_Navigant_2014.csv'),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        sconfig_list = [['region', 'base_year', 'last_year'],
                        ['World', 2014, 2050], ['OECD90', 2014, 2050],
                        ['Eastern Europe', 2014, 2050],
                        ['Asia (Sans Japan)', 2014, 2050],
                        ['Middle East and Africa', 2014, 2050],
                        ['Latin America', 2014, 2050], ['China', 2014, 2050],
                        ['India', 2014, 2050], ['EU', 2014, 2050],
                        ['USA', 2014, 2050]]
        sconfig = pd.DataFrame(sconfig_list[1:],
                               columns=sconfig_list[0],
                               dtype=np.object).set_index('region')
        sconfig['pds_tam_2050'] = pds_tam_per_region.loc[[2050]].T
        sc_regions, sc_percentages = zip(*self.ac.pds_base_adoption)
        sconfig['base_adoption'] = pd.Series(list(sc_percentages),
                                             index=list(sc_regions))
        sconfig['base_percent'] = sconfig[
            'base_adoption'] / pds_tam_per_region.loc[2014]
        sc_regions, sc_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        sconfig['last_percent'] = pd.Series(list(sc_percentages),
                                            index=list(sc_regions))
        if self.ac.pds_adoption_s_curve_innovation is not None:
            sc_regions, sc_percentages = zip(
                *self.ac.pds_adoption_s_curve_innovation)
            sconfig['innovation'] = pd.Series(list(sc_percentages),
                                              index=list(sc_regions))
        if self.ac.pds_adoption_s_curve_imitation is not None:
            sc_regions, sc_percentages = zip(
                *self.ac.pds_adoption_s_curve_imitation)
            sconfig['imitation'] = pd.Series(list(sc_percentages),
                                             index=list(sc_regions))
        self.sc = s_curve.SCurve(transition_period=16, sconfig=sconfig)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Logistic S-Curve':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = self.sc.logistic_adoption()
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Bass Diffusion S-Curve':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = self.sc.bass_diffusion_adoption()
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series([
            165284837.0, 153214036.0, 2001574.0, 10001070.0, 1759.0, 66398.0,
            10000000.0, 1070.0, 129000000.0, 21532448.0
        ],
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #9
0
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '2nd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions (2015-2020, 2020-2030 and 2030-2045).':
                THISDIR.joinpath(
                    'tam',
                    'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__651dff99.csv'
                ),
                'See sheet FAO 2009, annual growth rates in Drawdown regions (2015-2020, 2020-2030 and 2030-2045) from RISI':
                THISDIR.joinpath(
                    'tam',
                    'tam_See_sheet_FAO_2009_annual_growth_rates_in_Drawdown_regions_20152020_20202030_and_2030204_01422925.csv'
                ),
            },
            'Ambitious Cases': {
                'See McKinnsey & Co 2013 sheet (annual growth after 2030 2,7%':
                THISDIR.joinpath(
                    'tam',
                    'tam_See_McKinnsey_Co_2013_sheet_annual_growth_after_2030_27.csv'
                ),
            },
            'Maximum Cases': {
                'See McKinnsey & Co 2013 sheet (annual growth after 2030 2,2%':
                THISDIR.joinpath(
                    'tam',
                    'tam_See_McKinnsey_Co_2013_sheet_annual_growth_after_2030_22.csv'
                ),
            },
            'Region: OECD90': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__651dff99.csv'
                    ),
                    'See sheet FAO 2009':
                    THISDIR.joinpath('tam', 'tam_See_sheet_FAO_2009.csv'),
                },
            },
            'Region: Eastern Europe': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__651dff99.csv'
                    ),
                    'See sheet FAO 2009':
                    THISDIR.joinpath('tam', 'tam_See_sheet_FAO_2009.csv'),
                },
            },
            'Region: Asia (Sans Japan)': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__651dff99.csv'
                    ),
                    'See sheet FAO 2009':
                    THISDIR.joinpath('tam', 'tam_See_sheet_FAO_2009.csv'),
                },
            },
            'Region: Middle East and Africa': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__651dff99.csv'
                    ),
                    'See sheet FAO 2009':
                    THISDIR.joinpath('tam', 'tam_See_sheet_FAO_2009.csv'),
                },
            },
            'Region: Latin America': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__651dff99.csv'
                    ),
                    'See sheet FAO 2009':
                    THISDIR.joinpath('tam', 'tam_See_sheet_FAO_2009.csv'),
                },
            },
            'Region: China': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions and countries (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__f4ea722f.csv'
                    ),
                },
                'Ambitious Cases': {
                    'See sheet PÖYRY 2013. Linear interpolation 2011-2025 is used. After 2025 annual growth rate of 3,6% is used according to FAO 2009 Asia and the Pacific region annual growth rate 2020-2030.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_See_sheet_PÖYRY_2013__Linear_interpolation_20112025_is_used__After_2025_annual_growth_ra_5f611a03.csv'
                    ),
                },
            },
            'Region: India': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions and countries (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__f4ea722f.csv'
                    ),
                },
            },
            'Region: EU': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions and countries (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__f4ea722f.csv'
                    ),
                },
            },
            'Region: USA': {
                'Baseline Cases': {
                    '[FAO Stat 2014] Original data from webpage FAO Stat 2014. See RIGI data on the same sheet for annual growth rates in Drawdown regions and countries (2015-2020, 2020-2030 and 2030-2045).':
                    THISDIR.joinpath(
                        'tam',
                        'tam_FAO_Stat_2014_Original_data_from_webpage_FAO_Stat_2014__See_RIGI_data_on_the_same_sheet__f4ea722f.csv'
                    ),
                    'See sheet FAO 2015-2020, prognostication based on RIGI -0.9% annum growth':
                    THISDIR.joinpath(
                        'tam',
                        'tam_See_sheet_FAO_20152020_prognostication_based_on_RIGI_0_9_annum_growth.csv'
                    ),
                },
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          world_includes_regional=True,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Baseline Cases': {
                'See sheet FAO Stat 2014, recycling target rates specially defined for each region and country based on current recycling rate and EU target 2030 recycling rate of 70% or closest best country/region recycling rate':
                THISDIR.joinpath(
                    'ad',
                    'ad_See_sheet_FAO_Stat_2014_recycling_target_rates_specially_defined_for_each_region_and_cou_45c9627f.csv'
                ),
            },
            'Conservative Cases': {
                'See PÖYRY 2013 sheet':
                THISDIR.joinpath('ad', 'ad_See_PÖYRY_2013_sheet.csv'),
                'See McKinsey and Co. 2013 (adoption doubles every 25 years), 3rd Polynomial prognostication':
                THISDIR.joinpath(
                    'ad',
                    'ad_See_McKinsey_and_Co__2013_adoption_doubles_every_25_years_3rd_Polynomial_prognostication.csv'
                ),
            },
            'Ambitious Cases': {
                'Sheet FAO Stat 2014, ceiling 75%':
                THISDIR.joinpath('ad',
                                 'ad_Sheet_FAO_Stat_2014_ceiling_75.csv'),
            },
            'Maximum Cases': {
                'Sheet FAO Stat 2014, ceiling 81%':
                THISDIR.joinpath('ad',
                                 'ad_Sheet_FAO_Stat_2014_ceiling_81.csv'),
                'See McKinsey and Co. 2013 (adoption doubles every 15 years), 3rd Polynomial prognostication':
                THISDIR.joinpath(
                    'ad',
                    'ad_See_McKinsey_and_Co__2013_adoption_doubles_every_15_years_3rd_Polynomial_prognostication.csv'
                ),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Custom Scenario No.1 - Using Medium Trend of Prognostications',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Custom_Scenario_No_1_Using_Medium_Trend_of_Prognostications.csv'
                )
            },
            {
                'name':
                'Custom Scenario No.2 - Using High Trend of Existing Prognostications',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Custom_Scenario_No_2_Using_High_Trend_of_Existing_Prognostications.csv'
                )
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=pds_tam_per_region)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(
            [207.0, 125.0, 6.3, 78.0, 2.75, 12.21, 44.0, 3.0, 69.0, 46.5],
            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #10
0
ファイル: __init__.py プロジェクト: gitter-badger/solutions-1
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'Project Drawdown Estimated based on World Bank and WHO. Water Use Regression against GDP/capita used to estimate GL of water used for populations with at least US$10,000 GDP capita assuming Gini distribution of wealth.',
                'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'Project Drawdown Estimated based on World Bank and WHO. Water Use Regression against GDP/capita used to estimate GL of water used for populations with at least US$10,000 GDP capita assuming Gini distribution of wealth.',
                'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'Project Drawdown Estimated based on World Bank and WHO. Water Use Regression against GDP/capita used to estimate GL of water used for populations with at least US$10,000 GDP capita assuming Gini distribution of wealth.':
                THISDIR.joinpath(
                    'tam',
                    'tam_Project_Drawdown_Estimated_based_on_World_Bank_and_WHO__Water_Use_Regression_against_GDP_f76a56c1.csv'
                ),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Rapid Conversion of Old Fixtures and 70% Maximum Adoption',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Rapid_Conversion_of_Old_Fixtures_and_70_Maximum_Adoption.csv'
                )
            },
            {
                'name':
                'Very Rapid Conversion of Old Fixtures and 80% Maximum Adoption',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Very_Rapid_Conversion_of_Old_Fixtures_and_80_Maximum_Adoption.csv'
                )
            },
            {
                'name':
                'Very Rapid Conversion of Old Fixtures and 95% Maximum Adoption',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Very_Rapid_Conversion_of_Old_Fixtures_and_95_Maximum_Adoption.csv'
                )
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=pds_tam_per_region)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series([
            86258.8944386277, 47682.03190261271, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0
        ],
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #11
0
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'Based on: IEA ETP 2016 6DS':
                THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2016_6DS.csv'),
                'ICCT (2012) Global Roadmap Model':
                THISDIR.joinpath('tam',
                                 'tam_ICCT_2012_Global_Roadmap_Model.csv'),
            },
            'Conservative Cases': {
                'Based on: IEA ETP 2016 4DS':
                THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2016_4DS.csv'),
            },
            'Ambitious Cases': {
                'Based on: IEA ETP 2016 2DS':
                THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2016_2DS.csv'),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'PDS1 - Drawdown Projection of Production of Efficient Aircraft of Airbus and Boeing and Third Manufacturer at 13%',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS1_Drawdown_Projection_of_Production_of_Efficient_Aircraft_of_Airbus_and_Boeing_and_Th_0625227c.csv'
                )
            },
            {
                'name':
                'PDS2 - Drawdown Projection of Production of Efficient Aircraft of Airbus and Boeing and Third Manufacturer at 18%',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS2_Drawdown_Projection_of_Production_of_Efficient_Aircraft_of_Airbus_and_Boeing_and_Th_c6a70599.csv'
                )
            },
            {
                'name':
                'PDS3 - Drawdown Projection of Production of Efficient Aircraft of Airbus and Boeing and Third Manufacturer at 20%',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS3_Drawdown_Projection_of_Production_of_Efficient_Aircraft_of_Airbus_and_Boeing_and_Th_42d0f286.csv'
                )
            },
            {
                'name':
                'Book Ed.1 Scenario 1',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Book_Ed_1_Scenario_1.csv')
            },
            {
                'name':
                'Book Ed.1 Scenario 2',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Book_Ed_1_Scenario_2.csv')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=pds_tam_per_region)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(
            [490.5239834755743, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            repeated_cost_for_iunits=False,
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #12
0
ファイル: __init__.py プロジェクト: gitter-badger/solutions-1
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TLA
        self.ae = aez.AEZ(solution_name=self.name, cohort=2020,
                regimes=dd.THERMAL_MOISTURE_REGIMES8)
        if self.ac.use_custom_tla and self.ac.custom_tla_fixed_value is not None:
            self.c_tla = tla.CustomTLA(fixed_value=self.ac.custom_tla_fixed_value)
            custom_world_vals = self.c_tla.get_world_values()
        elif self.ac.use_custom_tla:
            self.c_tla = tla.CustomTLA(filename=THISDIR.joinpath('custom_tla_data.csv'))
            custom_world_vals = self.c_tla.get_world_values()
        else:
            custom_world_vals = None
        self.tla_per_region = tla.tla_per_region(self.ae.get_land_distribution(),
            custom_world_values=custom_world_vals)

        adconfig_list = [
            ['param', 'World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
             'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
            ['trend', self.ac.soln_pds_adoption_prognostication_trend, 'Medium',
             'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
             'Medium', 'Medium', 'Medium'],
            ['growth', self.ac.soln_pds_adoption_prognostication_growth, 'NOTE',
             'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE',
             'NOTE', 'NOTE', 'NOTE'],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
        adconfig = pd.DataFrame(adconfig_list[1:], columns=adconfig_list[0],
            dtype=np.object).set_index('param')
        ad_data_sources = {
            'Raw Data for ALL LAND TYPES': {
                'RR 2018, https://rightsandresources.org/wp-content/uploads/2018/09/At-A-Crossroads_RRI_Sept-2018.pdf': THISDIR.joinpath('ad', 'ad_RR_2018_httpsrightsandresources_orgwpcontentuploads201809AtACrossroads_RRI_Sept2018_pdf.csv'),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
            main_includes_regional=True,
            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_columns = ['Year'] + dd.REGIONS
        tla_world_2050 = self.tla_per_region.loc[2050, 'World']
        ad_2018 = self.ac.ref_base_adoption['World']
        ad_2012 = 431.635465343388  # current adoption in year 2012 (refer U46, adoption data sheet)

        # https://rightsandresources.org/wp-content/uploads/2018/09/At-A-Crossroads_RRI_Sept-2018.pdf
        lmic_18_3 = 337.0  # 18.3% adoption in 33 Low and Middle Income Countries
        lmic_22_1 = 425.0  # 22.1% adoption in 33 Low and Middle Income Countries
        lmic_23_0 = 458.0  # 23% adoption in 33 Low and Middle Income Countries
        lmic_24_1 = 484.0  # 24.1% adoption in 33 Low and Middle Income Countries
        tla_lmic = (lmic_18_3 / 18.3) * 100
        lmic_50_0 = tla_lmic * 0.5   # 50% adoption in 33 Low and Middle Income Countries
        lmic_75_0 = tla_lmic * 0.75   # 75% adoption in 33 Low and Middle Income Countries
        wtla_50 = tla_world_2050 * 0.5
        wtla_75 = tla_world_2050 * 0.75

        def constrained_tla(datapoints):
            (slope, intercept) = np.polyfit(x=datapoints.index, y=datapoints['World'], deg=1)
            degrade_df = pd.DataFrame(0, index=range(2014, 2061), columns=[
                'Total undegraded land at the start of the year',
                'Degraded land at the end of the year',
                'Total undegraded land at the end of the year', 'Constrained TLA'])
            for year in range(2014, 2061):
                if year == 2014:
                    undeg_start = tla_world_2050 - ad_2012
                else:
                    last = degrade_df.loc[year-1, 'Total undegraded land at the end of the year']
                    undeg_start = last - slope
                degrade_df.loc[year, 'Total undegraded land at the start of the year'] = undeg_start
                degraded_end = max(0, undeg_start * self.ac.degradation_rate)
                degrade_df.loc[year, 'Degraded land at the end of the year'] = degraded_end
                degrade_df.loc[year, 'Total undegraded land at the end of the year'] = (
                        undeg_start - degraded_end)
                degrade_df.loc[year, 'Constrained TLA'] = (tla_world_2050 -
                        degrade_df['Degraded land at the end of the year'].sum())
            return degrade_df

        # Data Source 1
        ds1_datapoints = pd.DataFrame([
            [2002, lmic_18_3, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2008, lmic_22_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2013, lmic_23_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2017, lmic_24_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2030, lmic_50_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            ], columns=ca_pds_columns).set_index('Year')
        ds1_maximum = constrained_tla(datapoints=ds1_datapoints)['Constrained TLA'].min()

        ds2_datapoints = pd.DataFrame([
            [2002, lmic_18_3, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2008, lmic_22_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2013, lmic_23_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2017, lmic_24_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2030, lmic_50_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2050, lmic_75_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            ], columns=ca_pds_columns).set_index('Year')
        ds2_maximum = constrained_tla(datapoints=ds2_datapoints)['Constrained TLA'].min()

        ds3_datapoints = pd.DataFrame([
            [2002, lmic_18_3, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2008, lmic_22_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2013, lmic_23_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2017, lmic_24_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2030, tla_lmic, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2050, tla_lmic, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            ], columns=ca_pds_columns).set_index('Year')
        ds3_maximum = constrained_tla(datapoints=ds3_datapoints)['Constrained TLA'].min()

        ds4_datapoints = pd.DataFrame([
            [2002, lmic_18_3, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2008, lmic_22_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2013, lmic_23_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2017, lmic_24_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2030, wtla_50, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            ], columns=ca_pds_columns).set_index('Year')
        ds4_maximum = constrained_tla(datapoints=ds4_datapoints)['Constrained TLA'].min()

        ds5_datapoints = pd.DataFrame([
            [2002, lmic_18_3, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2008, lmic_22_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2013, lmic_23_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2017, lmic_24_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2030, wtla_50, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2050, wtla_75, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            ], columns=ca_pds_columns).set_index('Year')
        ds5_maximum = constrained_tla(datapoints=ds5_datapoints)['Constrained TLA'].min()

        ds6_datapoints = pd.DataFrame([
            [2002, lmic_18_3, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2008, lmic_22_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2013, lmic_23_0, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2017, lmic_24_1, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2030, wtla_50, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            [2050, tla_world_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
            ], columns=ca_pds_columns).set_index('Year')
        ds6_maximum = constrained_tla(datapoints=ds6_datapoints)['Constrained TLA'].min()

        ca_pds_data_sources = [
            {'name': 'Moderate growth, Linear Trend', 'include': True,
                'description': (
                    'Future adoption of forest area under Indigenous People (IP) management was '
                    'built based on the adoption in Low and Middle Income Countries given for '
                    'the year 2002, 2008, 2013, and targeted percentage for the year 2030 by '
                    'Rights and Resources 2018  publication. '
                    ),
                'datapoints_degree': 1, 'datapoints': ds1_datapoints, 'maximum': ds1_maximum},
            {'name': 'High growth, Linear Trend', 'include': True,
                'description': (
                    'Future adoption of forest area under Indigenous People (IP) management was '
                    'built based on the adoption in Low and Middle Income Countries given for '
                    'the year 2002, 2008, 2013, and targeted percentage for the year 2030 by '
                    'Rights and Resources 2018  publication. Further assumption was made that '
                    'the forest area under indigenous people management will increase to 75% by '
                    '2050 in Low and Middle Income Countries. '
                    ),
                'datapoints_degree': 1, 'datapoints': ds2_datapoints, 'maximum': ds2_maximum},
            {'name': 'Max growth, Linear Trend', 'include': True,
                'description': (
                    'Future adoption of forest area under Indigenous People (IP) management was '
                    'built based on the adoption in Low and Middle Income Countries given for '
                    'the year 2002, 2008, 2013, and targeted percentage for the year 2030 by '
                    'Rights and Resources 2018  publication. Further assumption was made that '
                    'the forest area under indigenous people management will increase to 100% by '
                    '2050 in Low and Middle Income Countries. '
                    ),
                'datapoints_degree': 1, 'datapoints': ds3_datapoints, 'maximum': ds3_maximum},
            {'name': 'Moderate growth, AEZ TLA, Linear Trend', 'include': True,
                'description': (
                    'Future adoption of forest area under Indigenous People (IP) management was '
                    'built based on the adoption in Low and Middle Income Countries given for '
                    'the year 2002, 2008, 2013, and targeted percentage for the year 2030 by '
                    'Rights and Resources 2018  publication. However, the 2030 projected area is '
                    'calculated with reference to the assigned TLA of the solution and not by '
                    'the total area as calculated for theLow and Middle Income Countries. '
                    ),
                'datapoints_degree': 1, 'datapoints': ds4_datapoints, 'maximum': ds4_maximum},
            {'name': 'High growth, AEZ TLA, Linear Trend', 'include': True,
                'description': (
                    'Future adoption of forest area under Indigenous People (IP) management was '
                    'built based on the adoption in Low and Middle Income Countries given for '
                    'the year 2002, 2008, 2013, and targeted percentage for the year 2030 by '
                    'Rights and Resources 2018  publication. Further assumption was made that '
                    'the forest area under indigenous people management will increase to 75% by '
                    '2050 in Low and Middle Income Countries.  However, the 2030 and 2050 '
                    'projected area is calculated with reference to the assigned TLA of the '
                    'solution and not by the total area as calculated for the Low and Middle '
                    'Income Countries. '
                    ),
                'datapoints_degree': 1, 'datapoints': ds5_datapoints, 'maximum': ds5_maximum},
            {'name': 'Max growth, AEZ TLA, Linear Trend', 'include': True,
                'description': (
                    'Future adoption of forest area under Indigenous People (IP) management was '
                    'built based on the adoption in Low and Middle Income Countries given for '
                    'the year 2002, 2008, 2013, and targeted percentage for the year 2030 by '
                    'Rights and Resources 2018  publication. Further assumption was made that '
                    'the forest area under indigenous people management will increase to 100% by '
                    '2050 in Low and Middle Income Countries.  However, the 2030 and 2050 '
                    'projected area is calculated with reference to the assigned TLA of the '
                    'solution and not by the total area as calculated for the Low and Middle '
                    'Income Countries. '
                    ),
                'datapoints_degree': 1, 'datapoints': ds6_datapoints, 'maximum': ds6_maximum},
        ]
        self.pds_ca = customadoption.CustomAdoption(data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0, low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2012, 'World'] = 431.635465343388
            df.loc[2013, 'World'] = 442.123227592586
            df.loc[2014, 'World'] = 453.987693921633
            df.loc[2015, 'World'] = 464.65888472248
            df.loc[2016, 'World'] = df.loc[2015, 'World']
            df.loc[2017, 'World'] = 486.074210468988
            df.loc[2018, 'World'] = 496.809418409265

        # Custom REF Data
        ca_ref_data_sources = [
            {'name': '[Type Scenario 1 Name Here (REF CASE)...]', 'include': True,
                'description': (
                    'Reference adoption wrt change in current adoption from 2014 to 2018 '
                    ),
                'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Type_Scenario_1_Name_Here_REF_CASE_.csv')},
        ]
        self.ref_ca = customadoption.CustomAdoption(data_sources=ca_ref_data_sources,
            soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
            high_sd_mult=1.0, low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        if self.ac.soln_ref_adoption_basis == 'Custom':
            ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region()
        else:
            ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region()
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region()
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(
            list(self.ac.ref_base_adoption.values()), index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (ht_ref_adoption_initial /
            self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_pds_adoption_final_percentage = pd.Series(
            list(self.ac.pds_adoption_final_percentage.values()),
            index=list(self.ac.pds_adoption_final_percentage.keys()))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2018] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(ac=self.ac,
            ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=self.tla_per_region, pds_adoption_limits=self.tla_per_region,
            ref_adoption_data_per_region=ref_adoption_data_per_region,
            use_first_pds_datapoint_main=False,
            adoption_base_year=2018,
            copy_pds_to_ref=False,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(ac=self.ac,
            ref_total_adoption_units=self.tla_per_region,
            pds_total_adoption_units=self.tla_per_region,
            electricity_unit_factor=1000000.0,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

        self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
            ref_learning_increase_mult=2, conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_first_cost_uses_tot_units=True,
            fc_convert_iunit_factor=land.MHA_TO_HA)

        self.oc = operatingcost.OperatingCost(ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
            conversion_factor=land.MHA_TO_HA)

        self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.direct_ch4_co2_emissions_saved_land(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            tot_red_in_deg_land=self.ua.cumulative_reduction_in_total_degraded_land(),
            pds_protected_deg_land=self.ua.pds_cumulative_degraded_land_protected(),
            ref_protected_deg_land=self.ua.ref_cumulative_degraded_land_protected(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
コード例 #13
0
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            ['param', 'World', 'PDS World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
                'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
            ['source_until_2014', self.ac.source_until_2014, self.ac.source_until_2014,
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
            ['source_after_2014', self.ac.ref_source_post_2014, self.ac.pds_source_post_2014,
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
            ['trend', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly'],
            ['growth', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
        tamconfig = pd.DataFrame(tamconfig_list[1:], columns=tamconfig_list[0],
            dtype=np.object).set_index('param')
        tam_ref_data_sources = {
              'Baseline Cases': {
                  'Project Drawdown - Based on Data from Several Sources. (See HVFAC Links Sheet and HVFAC Material Availability Models)': THISDIR.joinpath('tam', 'tam_Project_Drawdown_based_on_Data_from_Several_Sources__See_HVFAC_Links_Sheet_and_HVFAC_Mat_2961774c.csv'),
            },
              'Conservative Cases': {
                  'IEA 2018 Low-Variability': THISDIR.joinpath('tam', 'tam_IEA_2018_LowVariability.csv'),
                  'Farfan et al. 2019': THISDIR.joinpath('tam', 'tam_Farfan_et_al__2019.csv'),
                  'van Ruijven et al. 2016': THISDIR.joinpath('tam', 'tam_van_Ruijven_et_al__2016.csv'),
            },
              'Ambitious Cases': {
                  'IEA 2018 High-Variability': THISDIR.joinpath('tam', 'tam_IEA_2018_HighVariability.csv'),
            },
              'Maximum Cases': {
                  'WBCSD Cement 2002': THISDIR.joinpath('tam', 'tam_WBCSD_Cement_2002.csv'),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig, tam_ref_data_sources=tam_ref_data_sources,
            tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region=self.tm.ref_tam_per_region()
        pds_tam_per_region=self.tm.pds_tam_per_region()

        adconfig_list = [
            ['param', 'World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
             'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
            ['trend', self.ac.soln_pds_adoption_prognostication_trend, '3rd Poly',
             '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
             '3rd Poly', '3rd Poly', '3rd Poly'],
            ['growth', self.ac.soln_pds_adoption_prognostication_growth, 'Medium',
             'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
             'Medium', 'Medium', 'Medium'],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
        adconfig = pd.DataFrame(adconfig_list[1:], columns=adconfig_list[0],
            dtype=np.object).set_index('param')
        ad_data_sources = {
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
            adconfig=adconfig)

        # Custom PDS Data
        wb = xlrd.open_workbook(filename=THISDIR.joinpath('data.xlsx'), on_demand=True)
        def isint(x):
            try:
                int(x)
                return True
            except ValueError:
                return False
        def demangle(name):
            # Pandas tries to be helpful by mangling duplicate column names, so the first
            # read_excel returns 'Latin America' and the second 'Latin America.1'
            if not '.' in name:
                return name
            new, suffix = name.rsplit('.', 1)
            return new if isint(suffix) else name
        clinker_pct = self.ac.lookup_vma(vma_title='Clinker to Cement Ratio in Year 2')

        # Data Source 1
        hvfac_mmt_pds1 = pd.read_excel(io=wb, sheet_name='HVFAC Links', header=0, index_col=0,
                usecols='B:L', dtype='float', engine='xlrd', skiprows=62, nrows=46
                ).rename(mapper=demangle, axis='columns').rename(columns={
                    'Asia (sans Japan)': 'Asia (Sans Japan)',
                    'Middle East & Africa': 'Middle East and Africa',
                    })
        hvfac_mmt_pds1.index.name = 'Year'
        hvfac_mmt_pds1.loc[2014] = 0.0
        ds1_df = hvfac_mmt_pds1.sort_index() / clinker_pct

        # Data Source 2
        hvfac_mmt_pds2 = pd.read_excel(io=wb, sheet_name='HVFAC Links', header=0, index_col=0,
                usecols='O:Y', dtype='float', engine='xlrd', skiprows=62, nrows=46
                ).rename(mapper=demangle, axis='columns').rename(columns={
                    'Asia (sans Japan)': 'Asia (Sans Japan)',
                    'Middle East & Africa': 'Middle East and Africa',
                    })
        hvfac_mmt_pds2.index.name = 'Year'
        hvfac_mmt_pds2.loc[2014] = 0.0
        ds2_df = hvfac_mmt_pds2.sort_index() / clinker_pct

        # Data Source 3
        hvfac_mmt_pds3 = pd.read_excel(io=wb, sheet_name='HVFAC Links', header=0, index_col=0,
                usecols='AB:AL', dtype='float', engine='xlrd', skiprows=62, nrows=46
                ).rename(mapper=demangle, axis='columns').rename(columns={
                    'Asia (sans Japan)': 'Asia (Sans Japan)',
                    'Middle East & Africa': 'Middle East and Africa',
                    })
        hvfac_mmt_pds3.index.name = 'Year'
        hvfac_mmt_pds3.loc[2014] = 0.0
        ds3_df = hvfac_mmt_pds3.sort_index() / clinker_pct

        # Data Source 4
        filename_ds4 = THISDIR.joinpath('ca_pds_data', 'pds_adoption_scenario_4.csv')
        book_mmt = pd.read_csv(filename_ds4, header=0, index_col=0, skipinitialspace=True,
                         skip_blank_lines=True, comment='#', dtype=np.float64)
        book_mmt.index = book_mmt.index.astype(int)
        ds4_df = book_mmt / clinker_pct

        ca_pds_data_sources = [
            {'name': 'Adoption Based on Fly Ash Availability Analysis/ PDS 1', 'include': True,
                'description': (
                    'Fly Ash (FA) is a waste product of coal fired power stations. FA that is '
                    'not reused, is disposed in dry landfills or wet ponds. FA is valuable '
                    'because it can be used to replace Ordinary Portland Cement (OPC) in the '
                    'cement mix (up to a certain percentage) and hence it can be used to reduce '
                    'the CO2 footprint of concrete. The separate HVFAC model evaluates the total '
                    'amount of FA available in a market based on projected coal demand and '
                    "coal's fly ash concentration. The model divides the total FA supply into "
                    "three streams (i) landfill; (ii)  'other uses' (i.e. reuse but not cement); "
                    'and (iii) cement mixes. The total addressable market for cement '
                    'production/demand is initially defined as the total cement demand (assumed '
                    'OPC) plus that portion of FA that is reused for cement. A higher ratio of '
                    'FA:OPC (e.g. 45%:55%) for the cement mix is the adopted solution for CO2 '
                    'mitigation. The target FA:OPC ratio is input into the model to define the '
                    'PDS scenario. The model calculates the annual mass of OPC that can be '
                    'avoided, the energy saved, and the CO2 emissions avoided.  There are two '
                    'factors (cement demand and FA supply) that have the potential to limit OPC '
                    'replacement with FA. Model input includes the PDS transition period (e.g. 5 '
                    'years) to implement the new policy for cement production, concrete '
                    'standards, and FA reuse infrastructure. The model allows an addtional '
                    'policy option: to utilise FA in landfill when the 100% of FA waste stream '
                    'is utilised in cement production and other uses. For this scenario, '
                    'reduction of coal demand for electricity generation in the PDS1 affects the '
                    'total amount of fly ash available. '
                    ),
                'dataframe': ds1_df},
            {'name': 'Adoption Based on Fly Ash Availability Analysis/ PDS 2', 'include': True,
                'description': (
                    'Fly Ash (FA) is a waste product of coal fired power stations. FA that is '
                    'not reused, is disposed in dry landfills or wet ponds. FA is valuable '
                    'because it can be used to replace Ordinary Portland Cement (OPC) in the '
                    'cement mix (up to a certain percentage) and hence it can be used to reduce '
                    'the CO2 footprint of concrete. The separate HVFAC model evaluates the total '
                    'amount of FA available in a market based on projected coal demand and '
                    "coal's fly ash concentration. The model divides the total FA supply into "
                    "three streams (i) landfill; (ii)  'other uses' (i.e. reuse but not cement); "
                    'and (iii) cement mixes. The total addressable market for cement '
                    'production/demand is initially defined as the total cement demand (assumed '
                    'OPC) plus that portion of FA that is reused for cement. A higher ratio of '
                    'FA:OPC (e.g. 45%:55%) for the cement mix is the adopted solution for CO2 '
                    'mitigation. The target FA:OPC ratio is input into the model to define the '
                    'PDS scenario. The model calculates the annual mass of OPC that can be '
                    'avoided, the energy saved, and the CO2 emissions avoided.  There are two '
                    'factors (cement demand and FA supply) that have the potential to limit OPC '
                    'replacement with FA. Model input includes the PDS transition period (e.g. 5 '
                    'years) to implement the new policy for cement production, concrete '
                    'standards, and FA reuse infrastructure. The model allows an addtional '
                    'policy option: to utilise FA in landfill when the 100% of FA waste stream '
                    'is utilised in cement production and other uses. For this scenario, '
                    'reduction of coal demand for electricity generation in the PDS2 affects the '
                    'total amount of fly ash available. '
                    ),
                'dataframe': ds2_df},
            {'name': 'Adoption Based on Fly Ash Availability Analysis/ PDS 3', 'include': True,
                'description': (
                    'Fly Ash (FA) is a waste product of coal fired power stations. FA that is '
                    'not reused, is disposed in dry landfills or wet ponds. FA is valuable '
                    'because it can be used to replace Ordinary Portland Cement (OPC) in the '
                    'cement mix (up to a certain percentage) and hence it can be used to reduce '
                    'the CO2 footprint of concrete. The separate HVFAC model evaluates the total '
                    'amount of FA available in a market based on projected coal demand and '
                    "coal's fly ash concentration. The model divides the total FA supply into "
                    "three streams (i) landfill; (ii)  'other uses' (i.e. reuse but not cement); "
                    'and (iii) cement mixes. The total addressable market for cement '
                    'production/demand is initially defined as the total cement demand (assumed '
                    'OPC) plus that portion of FA that is reused for cement. A higher ratio of '
                    'FA:OPC (e.g. 45%:55%) for the cement mix is the adopted solution for CO2 '
                    'mitigation. The target FA:OPC ratio is input into the model to define the '
                    'PDS scenario. The model calculates the annual mass of OPC that can be '
                    'avoided, the energy saved, and the CO2 emissions avoided.  There are two '
                    'factors (cement demand and FA supply) that have the potential to limit OPC '
                    'replacement with FA. Model input includes the PDS transition period (e.g. 5 '
                    'years) to implement the new policy for cement production, concrete '
                    'standards, and FA reuse infrastructure. The model allows an addtional '
                    'policy option: to utilise FA in landfill when the 100% of FA waste stream '
                    'is utilised in cement production and other uses. For this scenario, '
                    'reduction of coal demand for electricity generation in the PDS3 affects the '
                    'total amount of fly ash available. '
                    ),
                'dataframe': ds3_df},
            {'name': 'Drawdown Book Edition 1 PDS 1, 2 and 3', 'include': True,
                'description': (
                    'Fly Ash (FA) is a waste product of coal fired power stations. FA that is '
                    'not reused, is disposed in dry landfills or wet ponds. FA is valuable '
                    'because it can be used to replace Ordinary Portland Cement (OPC) in the '
                    'cement mix (up to a certain percentage) and hence it can be used to reduce '
                    'the CO2 footprint of concrete. The separate HVFAC model evaluates the total '
                    'amount of FA available in a market based on projected coal demand and '
                    "coal's fly ash concentration. The model divides the total FA supply into "
                    "three streams (i) landfill; (ii)  'other uses' (i.e. reuse but not cement); "
                    'and (iii) cement mixes. The total addressable market for cement '
                    'production/demand is initially defined as the total cement demand (assumed '
                    'OPC) plus that portion of FA that is reused for cement. A higher ratio of '
                    'FA:OPC (e.g. 45%:55%) for the cement mix is the adopted solution for CO2 '
                    'mitigation. The target FA:OPC ratio is input into the model to define the '
                    'PDS scenario. The model calculates the annual mass of OPC that can be '
                    'avoided, the energy saved, and the CO2 emissions avoided.  There are two '
                    'factors (cement demand and FA supply) that have the potential to limit OPC '
                    'replacement with FA. Model input includes the PDS transition period (e.g. 5 '
                    'years) to implement the new policy for cement production, concrete '
                    'standards, and FA reuse infrastructure. The model allows an addtional '
                    'policy option: to utilise FA in landfill when the 100% of FA waste stream '
                    'is utilised in cement production and other uses. This scenario uses inputs '
                    'calculated for the Drawdown book edition 1, some of which have been updated '
                    'with newer data. '
                    ),
                'dataframe': ds4_df},
        ]
        self.pds_ca = customadoption.CustomAdoption(data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=self.ac.soln_pds_adoption_custom_high_sd_mult,
            low_sd_mult=self.ac.soln_pds_adoption_custom_low_sd_mult,
            total_adoption_limit=pds_tam_per_region)

        # Custom REF Data
        # Data Source 1
        hvfac_mmt_ref = pd.read_excel(io=wb, sheet_name='HVFAC Links', header=0, index_col=0,
                usecols='B:L', dtype='float', engine='xlrd', skiprows=113, nrows=46
                ).rename(mapper=demangle, axis='columns').rename(columns={
                    'Asia (sans Japan)': 'Asia (Sans Japan)',
                    'Middle East & Africa': 'Middle East and Africa',
                    })
        hvfac_mmt_ref.index.name = 'Year'
        hvfac_mmt_ref.loc[2014] = 0.0
        ref1_df = hvfac_mmt_ref.sort_index() / clinker_pct

        # Data Source 2
        filename_ref2 = THISDIR.joinpath('ca_ref_data', 'ref_adoption_scenario_2.csv')
        book_ref_mmt = pd.read_csv(filename_ref2, header=0, index_col=0, skipinitialspace=True,
                         skip_blank_lines=True, comment='#', dtype=np.float64)
        book_ref_mmt.index = book_ref_mmt.index.astype(int)
        ref2_df = book_ref_mmt / clinker_pct

        ca_ref_data_sources = [
            {'name': 'REF Custom Adoption Based on Fly Ash Availability Analysis', 'include': True,
                'description': (
                    'Fly Ash (FA) is a waste product of coal fired power stations. FA that is '
                    'not reused, is disposed in dry landfills or wet ponds. FA is valuable '
                    'because it can be used to replace Ordinary Portland Cement (OPC) in the '
                    'cement mix (up to a certain percentage) and hence it can be used to reduce '
                    'the CO2 footprint of concrete. The separate HVFAC model evaluates the total '
                    'amount of FA available in a market based on projected coal demand and '
                    "coal's fly ash concentration. The model divides the total FA supply into "
                    "three streams (i) landfill; (ii)  'other uses' (i.e. reuse but not cement); "
                    'and (iii) cement mixes. The total addressable market for cement '
                    'production/demand is initially defined as the total cement demand (assumed '
                    'OPC) plus that portion of FA that is reused for cement. A higher ratio of '
                    'FA:OPC (e.g. 45%:55%) for the cement mix is the adopted solution for CO2 '
                    'mitigation. The target FA:OPC ratio is input into the model to define the '
                    'PDS scenario. The model calculates the annual mass of OPC that can be '
                    'avoided, the energy saved, and the CO2 emissions avoided.  There are two '
                    'factors (cement demand and FA supply) that have the potential to limit OPC '
                    'replacement with FA. Model input includes the PDS transition period (e.g. 5 '
                    'years) to implement the new policy for cement production, concrete '
                    'standards, and FA reuse infrastructure. The model allows an addtional '
                    'policy option: to utilise FA in landfill when the 100% of FA waste stream '
                    'is utilised in cement production and other uses. '
                    ),
                'dataframe': ref1_df},
            {'name': 'Drawdown Book Edition 1 Scenario REF Adoption', 'include': True,
                'description': (
                    'Fly Ash (FA) is a waste product of coal fired power stations. FA that is '
                    'not reused, is disposed in dry landfills or wet ponds. FA is valuable '
                    'because it can be used to replace Ordinary Portland Cement (OPC) in the '
                    'cement mix (up to a certain percentage) and hence it can be used to reduce '
                    'the CO2 footprint of concrete. The separate HVFAC model evaluates the total '
                    'amount of FA available in a market based on projected coal demand and '
                    "coal's fly ash concentration. The model divides the total FA supply into "
                    "three streams (i) landfill; (ii)  'other uses' (i.e. reuse but not cement); "
                    'and (iii) cement mixes. The total addressable market for cement '
                    'production/demand is initially defined as the total cement demand (assumed '
                    'OPC) plus that portion of FA that is reused for cement. A higher ratio of '
                    'FA:OPC (e.g. 45%:55%) for the cement mix is the adopted solution for CO2 '
                    'mitigation. The target FA:OPC ratio is input into the model to define the '
                    'PDS scenario. The model calculates the annual mass of OPC that can be '
                    'avoided, the energy saved, and the CO2 emissions avoided.  There are two '
                    'factors (cement demand and FA supply) that have the potential to limit OPC '
                    'replacement with FA. Model input includes the PDS transition period (e.g. 5 '
                    'years) to implement the new policy for cement production, concrete '
                    'standards, and FA reuse infrastructure. The model allows an addtional '
                    'policy option: to utilise FA in landfill when the 100% of FA waste stream '
                    'is utilised in cement production and other uses. This scenario uses inputs '
                    'calculated for the Drawdown book edition 1, some of which have been updated '
                    'with newer data. '
                    ),
                'dataframe': ref2_df},
        ]
        self.ref_ca = customadoption.CustomAdoption(data_sources=ca_ref_data_sources,
            soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
            high_sd_mult=1.0, low_sd_mult=1.0,
            total_adoption_limit=ref_tam_per_region)

        if self.ac.soln_ref_adoption_basis == 'Custom':
            ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region()
        else:
            ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region()
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region()
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()
        elif self.ac.soln_pds_adoption_basis == 'Linear':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = None
            pds_adoption_is_single_source = None

        ht_ref_adoption_initial = pd.Series(
            list(self.ac.ref_base_adoption.values()), index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (ht_ref_adoption_initial /
            ref_tam_per_region.loc[2018])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_pds_adoption_final_percentage = pd.Series(
            list(self.ac.pds_adoption_final_percentage.values()),
            index=list(self.ac.pds_adoption_final_percentage.keys()))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2018] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(ac=self.ac,
            ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region, pds_adoption_limits=pds_tam_per_region,
            ref_adoption_data_per_region=ref_adoption_data_per_region,
            use_first_pds_datapoint_main=False,
            copy_pds_to_ref=False, copy_ref_datapoint=False, copy_pds_datapoint=False,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac, grid_emissions_version=4)

        self.ua = unitadoption.UnitAdoption(ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            repeated_cost_for_iunits=True,
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

        self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
            ref_learning_increase_mult=2, conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014, 'World'],
            soln_avg_annual_use=self.ac.soln_avg_annual_use,
            conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #14
0
ファイル: __init__.py プロジェクト: scottwedge/solutions
  def __init__(self, scenario=None):
    if scenario is None:
      scenario = list(scenarios.keys())[0]
    self.scenario = scenario
    self.ac = scenarios[scenario]

    # TAM
    tamconfig_list = [
      ['param', 'World', 'PDS World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['source_until_2014', self.ac.source_until_2014, self.ac.source_until_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['source_after_2014', self.ac.ref_source_post_2014, self.ac.pds_source_post_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['trend', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    tamconfig = pd.DataFrame(tamconfig_list[1:], columns=tamconfig_list[0], dtype=np.object).set_index('param')
    tam_ref_data_sources = {
      'Baseline Cases': {
          'ETP 2016, URBAN 6 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_6_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ICCT, 2012, "Global Transportation Roadmap Model" + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ICCT_2012_Global_Transportation_Roadmap_Model_Nonmotorized_Travel_Adjustment.csv'),
      },
      'Conservative Cases': {
          'ETP 2016, URBAN 4 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_4_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ITDP/UC Davis 2014 Global High Shift Baseline': THISDIR.joinpath('tam', 'tam_ITDPUC_Davis_2014_Global_High_Shift_Baseline.csv'),
      },
      'Ambitious Cases': {
          'ETP 2016, URBAN 2 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_2_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ITDP/UC Davis 2014 Global High Shift HighShift': THISDIR.joinpath('tam', 'tam_ITDPUC_Davis_2014_Global_High_Shift_HighShift.csv'),
      },
      'Region: OECD90': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
      'Region: Eastern Europe': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
      'Region: Asia (Sans Japan)': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
      'Region: Middle East and Africa': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
      'Region: Latin America': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
      'Region: China': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
      'Region: India': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
      'Region: EU': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
      'Region: USA': {
        'Baseline Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Baseline_Scenario.csv'),
        },
        'Ambitious Cases': {
          'ITDP, UC Davis (2015) A Global High Shift Cycling Scenario, High shift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_High_shift_Scenario.csv'),
        },
      },
    }
    self.tm = tam.TAM(tamconfig=tamconfig, tam_ref_data_sources=tam_ref_data_sources,
      tam_pds_data_sources=tam_ref_data_sources)
    ref_tam_per_region=self.tm.ref_tam_per_region()
    pds_tam_per_region=self.tm.pds_tam_per_region()

    # Custom PDS Data
    ca_pds_data_sources = [
      {'name': 'Book Ed.1 Scenario 1', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Book_Ed_1_Scenario_1.csv')},
      {'name': 'Book Ed.1 Scenario 2', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Book_Ed_1_Scenario_2.csv')},
    ]
    self.pds_ca = customadoption.CustomAdoption(data_sources=ca_pds_data_sources,
        soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
        high_sd_mult=1.0, low_sd_mult=1.0,
        total_adoption_limit=pds_tam_per_region)

    # Custom REF Data
    ca_ref_data_sources = [
      {'name': 'Book Reference Scenario', 'include': False,
          'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Book_Reference_Scenario.csv')},
    ]
    self.ref_ca = customadoption.CustomAdoption(data_sources=ca_ref_data_sources,
        soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
        high_sd_mult=1.0, low_sd_mult=1.0,
        total_adoption_limit=ref_tam_per_region)

    ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region()

    if False:
      # One may wonder why this is here. This file was code generated.
      # This 'if False' allows subsequent conditions to all be elif.
      pass
    elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
      pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region()
      pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region()
      pds_adoption_is_single_source = None
    elif self.ac.soln_pds_adoption_basis == 'Linear':
      pds_adoption_data_per_region = None
      pds_adoption_trend_per_region = None
      pds_adoption_is_single_source = None

    ht_ref_adoption_initial = pd.Series(
      [561.0, 35.63818652262168, 1.9927024684919843, 441.0159122922099, 1.248023339153054,
       3.6014881104912106, 277.7410283849392, 5.674389798859366, 28.00294411913302, 7.901342605929202],
       index=dd.REGIONS)
    ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
    ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
    ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
    ht_pds_adoption_initial = ht_ref_adoption_initial
    ht_regions, ht_percentages = zip(*self.ac.pds_adoption_final_percentage)
    ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages), index=list(ht_regions))
    ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[2050]
    ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
    ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
    self.ht = helpertables.HelperTables(ac=self.ac,
        ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
        pds_adoption_data_per_region=pds_adoption_data_per_region,
        ref_adoption_limits=ref_tam_per_region, pds_adoption_limits=pds_tam_per_region,
        ref_adoption_data_per_region=ref_adoption_data_per_region,
        pds_adoption_trend_per_region=pds_adoption_trend_per_region,
        pds_adoption_is_single_source=pds_adoption_is_single_source)

    self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

    self.ua = unitadoption.UnitAdoption(ac=self.ac,
        ref_total_adoption_units=ref_tam_per_region, pds_total_adoption_units=pds_tam_per_region,
        soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
        soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
        bug_cfunits_double_count=True)
    soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
    soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
    conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
    soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

    self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
        ref_learning_increase_mult=2, conv_learning_increase_mult=2,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_tot_iunits=conv_ref_tot_iunits,
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        fc_convert_iunit_factor=1.0)

    self.oc = operatingcost.OperatingCost(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
        soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
        soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
        conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
        single_iunit_purchase_year=2017,
        soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
        conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
        conversion_factor=1.0)

    self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

    self.c2 = co2calcs.CO2Calcs(ac=self.ac,
        ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
        soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
        soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
        soln_pds_direct_co2_emissions_saved=self.ua.soln_pds_direct_co2_emissions_saved(),
        soln_pds_direct_ch4_co2_emissions_saved=self.ua.soln_pds_direct_ch4_co2_emissions_saved(),
        soln_pds_direct_n2o_co2_emissions_saved=self.ua.soln_pds_direct_n2o_co2_emissions_saved(),
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
        conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        fuel_in_liters=False)

    self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014, 'World'],
        soln_avg_annual_use=self.ac.soln_avg_annual_use,
        conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #15
0
ファイル: __init__.py プロジェクト: scottwedge/solutions
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'Drawdown Team Calculations based on: US BLS, StatCan, Data on Driving Distance':
                THISDIR.joinpath(
                    'tam',
                    'tam_Drawdown_Team_Calculations_based_on_US_BLS_StatCan_Data_on_Driving_Distance.csv'
                ),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Conservative Cases': {
                'PDS1 - Drawdown Team Calculations based on:Polzin & Pisarski (2015), US Census Bureau, and Statistic Brain and Labor Force Data from US BLS and StatCan - 15% adoption by Car commuters  in 2050':
                THISDIR.joinpath(
                    'ad',
                    'ad_PDS1_Drawdown_Team_Calculations_based_onPolzin_Pisarski_2015_US_Census_Bureau_and_Statis_bd22f196.csv'
                ),
                'PDS2 - Drawdown Team Calculations based on:Polzin & Pisarski (2015), US Census Bureau, and Statistic Brain and Labor Force Data from US BLS and StatCan - 20% adoption by Car commuters in 2050':
                THISDIR.joinpath(
                    'ad',
                    'ad_PDS2_Drawdown_Team_Calculations_based_onPolzin_Pisarski_2015_US_Census_Bureau_and_Statis_fc19b619.csv'
                ),
            },
            'Ambitious Cases': {
                'PDS Ambitious - Drawdown Team Calculations based on:Polzin & Pisarski (2015), US Census Bureau, and Statistic Brain and Labor Force Data from US BLS and StatCan - 30% adoption by Car commuters  in 2050':
                THISDIR.joinpath(
                    'ad',
                    'ad_PDS_Ambitious_Drawdown_Team_Calculations_based_onPolzin_Pisarski_2015_US_Census_Bureau_a_0cbed033.csv'
                ),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'PDS1 (15%) - Drawdown Book Edition 1',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS1_15_Drawdown_Book_Edition_1.csv')
            },
            {
                'name':
                'PDS2 (20%) - Drawdown Book Edition 1',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS2_20_Drawdown_Book_Edition_1.csv')
            },
            {
                'name':
                'PDS3 (30%) - Drawdown Book Edition 1',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS3_30_Drawdown_Book_Edition_1.csv')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=pds_tam_per_region)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()
        elif self.ac.soln_pds_adoption_basis == 'Linear':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = None
            pds_adoption_is_single_source = None

        ht_ref_adoption_initial = pd.Series(
            [167778037799.2084, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #16
0
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TLA
        self.ae = aez.AEZ(solution_name=self.name,
                          cohort=2020,
                          regimes=dd.THERMAL_MOISTURE_REGIMES8)
        if self.ac.use_custom_tla and self.ac.custom_tla_fixed_value is not None:
            self.c_tla = tla.CustomTLA(
                fixed_value=self.ac.custom_tla_fixed_value)
            custom_world_vals = self.c_tla.get_world_values()
        elif self.ac.use_custom_tla:
            self.c_tla = tla.CustomTLA(
                filename=THISDIR.joinpath('custom_tla_data.csv'))
            custom_world_vals = self.c_tla.get_world_values()
        else:
            custom_world_vals = None
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution(),
            custom_world_values=custom_world_vals)

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE',
                'NOTE'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Raw Data for ALL LAND TYPES': {
                'Henwood 1994 and Henwood 2010':
                THISDIR.joinpath('ad', 'ad_Henwood_1994_and_Henwood_2010.csv'),
                'Henwood 2010':
                THISDIR.joinpath('ad', 'ad_Henwood_2010.csv'),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            main_includes_regional=True,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_columns = ['Year'] + dd.REGIONS
        tla_world_2050 = self.tla_per_region.loc[2050, 'World']
        ad_2014 = 132.860079407797  # adoption in year 2014 (refer B647, adoption data sheet)
        ad_2018 = self.ac.ref_base_adoption['World']
        total_temperate_grassland = 1209.098

        # In Excel, the Custom PDS Scenarios tab columns AC:AF compute a limit on adoption
        # based on the amount of degraded land remaining. We compute the same limit here.
        def constrained_tla(ad_2050):
            (slope, intercept) = np.polyfit(x=[2018, 2050],
                                            y=[ad_2018, ad_2050],
                                            deg=1)
            degrade_df = pd.DataFrame(
                0,
                index=range(2014, 2061),
                columns=[
                    'Total undegraded land at the start of the year',
                    'Degraded land at the end of the year',
                    'Total undegraded land at the end of the year',
                    'Constrained TLA'
                ])
            for year in range(2014, 2061):
                if year == 2014:
                    undeg_start = tla_world_2050 - ad_2014
                else:
                    last = degrade_df.loc[
                        year - 1,
                        'Total undegraded land at the end of the year']
                    undeg_start = last - slope
                degrade_df.loc[
                    year,
                    'Total undegraded land at the start of the year'] = undeg_start
                degraded_end = max(0, undeg_start * self.ac.degradation_rate)
                degrade_df.loc[
                    year,
                    'Degraded land at the end of the year'] = degraded_end
                degrade_df.loc[
                    year, 'Total undegraded land at the end of the year'] = (
                        undeg_start - degraded_end)
                degrade_df.loc[year, 'Constrained TLA'] = (
                    tla_world_2050 -
                    degrade_df['Degraded land at the end of the year'].sum())
            return degrade_df['Constrained TLA'].min()

        # Data Source 1: Linear growth, conservative
        # SOURCE: Henwood, W. D. (2010). Toward a strategy for the conservation and
        # protection of the world's temperate grasslands. Great Plains Research, 121-134.
        ds1_commit_2014 = 0.25  # % commitment for protection of temperate grassland by 2014
        ds1_adoption_2050 = total_temperate_grassland * ds1_commit_2014
        ds1_constrained_tla = constrained_tla(ad_2050=ds1_adoption_2050)

        # Data Source 3: Linear growth, High
        # SOURCE: Henwood, W. D. (2010). Toward a strategy for the conservation and
        # protection of the world's temperate grasslands. Great Plains Research, 121-134.
        ds3_commit_2014 = 0.5  # % commitment for protection of temperate grassland by 2014
        ds3_adoption_2018 = self.ac.ref_base_adoption['World']
        ds3_adoption_2050 = total_temperate_grassland * ds3_commit_2014
        ds3_constrained_tla = constrained_tla(ad_2050=ds3_adoption_2050)

        # Data Source 4: Linear growth, High
        # SOURCE: Henwood, W. D. (2010). Toward a strategy for the conservation and
        # protection of the world's temperate grasslands. Great Plains Research, 121-134.
        ds4_commit_2014 = 1.0  # % commitment for protection of temperate grassland by 2014
        ds4_adoption_2018 = self.ac.ref_base_adoption['World']
        ds4_adoption_2050 = total_temperate_grassland * ds4_commit_2014
        ds4_constrained_tla = constrained_tla(ad_2050=ds4_adoption_2050)

        ca_pds_data_sources = [
            {
                'name':
                'Linear growth, conservative',
                'include':
                True,
                'maximum':
                ds1_constrained_tla,
                'description':
                ('The future adoption is projected based on the protection commitment made '
                 'for the temperate grassland, which is 10% of the total temperate grassland '
                 'area. Since, the current protection is much higher than the 10% commitment, '
                 'so 25% commitment target is considered for this projection. '
                 ),
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [
                        2050, ds1_adoption_2050, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Exsisting progonostication',
                'include':
                True,
                'maximum':
                ds1_constrained_tla,
                'description':
                ('The future adoption value was projected using the data interpolator and '
                 'adoption data sheet based on the data available on protected grassland area '
                 'globally in the temperate in the year 1994/2010 and 1996/2009. '
                 'NOTE: in actual implementation, this scenario is set equal to the "Linear '
                 'Growth, conservative" scenario not from adoption data.'),
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [
                        2050, ds1_adoption_2050, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Linear growth, High',
                'include':
                True,
                'maximum':
                ds3_constrained_tla,
                'description':
                ('The future adoption is projected based on the protection commitment made '
                 'for the temperate grassland, which is 10% of the total temperate grassland '
                 'area. Since, the current protection is much higher than the 10% commitment, '
                 'so 50% commitment target is considered for this projection. '
                 ),
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [
                        2050, ds3_adoption_2050, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Max adoption, linear trend',
                'include':
                True,
                'maximum':
                ds4_constrained_tla,
                'description':
                ('In this scenario, it is assumed that 100% of the grassland as per the TLA '
                 'will be protected by 2050 '),
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [
                        2050, ds4_adoption_2050, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2014, 'World'] = 132.860079407797
            df.loc[2015, 'World'] = 139.475887288368
            df.loc[2016, 'World'] = 146.114200458296
            df.loc[2017, 'World'] = 152.77501982823
            df.loc[2018, 'World'] = 159.457782791276

        # Custom REF Data
        ca_ref_data_sources = [
            {
                'name':
                '[Type Scenario 1 Name Here (REF CASE)...]',
                'include':
                True,
                'description':
                ('[PLEASE DESCRIBE IN DETAIL  THE METHODOLOGY YOU USED IN THIS ANALYSIS. BE '
                 'SURE TO INCLUDE ANY ADDITIONAL EQUATIONS YOU UTILIZED] '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Type_Scenario_1_Name_Here_REF_CASE_.csv')
            },
        ]
        self.ref_ca = customadoption.CustomAdoption(
            data_sources=ca_ref_data_sources,
            soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        if self.ac.soln_ref_adoption_basis == 'Custom':
            ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region(
            )
        else:
            ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(list(
            self.ac.ref_base_adoption.values()),
                                            index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (
            ht_ref_adoption_initial / self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_pds_adoption_final_percentage = pd.Series(
            list(self.ac.pds_adoption_final_percentage.values()),
            index=list(self.ac.pds_adoption_final_percentage.keys()))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=self.tla_per_region,
            pds_adoption_limits=self.tla_per_region,
            ref_adoption_data_per_region=ref_adoption_data_per_region,
            use_first_pds_datapoint_main=False,
            adoption_base_year=2018,
            copy_pds_to_ref=False,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=self.tla_per_region,
            pds_total_adoption_units=self.tla_per_region,
            electricity_unit_factor=1000000.0,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_first_cost_uses_tot_units=True,
            fc_convert_iunit_factor=land.MHA_TO_HA)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=land.MHA_TO_HA)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            tot_red_in_deg_land=self.ua.
            cumulative_reduction_in_total_degraded_land(),
            pds_protected_deg_land=self.ua.
            pds_cumulative_degraded_land_protected(),
            ref_protected_deg_land=self.ua.
            ref_cumulative_degraded_land_protected(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
コード例 #17
0
ファイル: __init__.py プロジェクト: gitter-badger/solutions-1
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TLA
        self.ae = aez.AEZ(solution_name=self.name,
                          cohort=2020,
                          regimes=dd.THERMAL_MOISTURE_REGIMES8)
        if self.ac.use_custom_tla:
            self.c_tla = tla.CustomTLA(
                filename=THISDIR.joinpath('custom_tla_data.csv'))
            custom_world_vals = self.c_tla.get_world_values()
        else:
            custom_world_vals = None
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution(),
            custom_world_values=custom_world_vals)

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE',
                'NOTE'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Raw Data for ALL LAND TYPES': {
                'FAOSTAT 2016 + Literature (Exponential)':
                THISDIR.joinpath('ad',
                                 'ad_FAOSTAT_2016_Literature_Exponential.csv'),
                'FAOSTAT 2016 + Literature (2nd order)':
                THISDIR.joinpath('ad',
                                 'ad_FAOSTAT_2016_Literature_2nd_order.csv'),
                'FAOSTAT 2016 + Literature (linear)':
                THISDIR.joinpath('ad',
                                 'ad_FAOSTAT_2016_Literature_linear.csv'),
            },
            'Region: OECD90': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT 2016 + Literature (Exponential)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_Exponential.csv'),
                    'FAOSTAT 2016 + Literature (2nd order)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_2nd_order.csv'),
                    'FAOSTAT 2016 + Literature (3rd order)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_3rd_order.csv'),
                },
            },
            'Region: Asia (Sans Japan)': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT 2016 + Literature (Exponential)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_Exponential.csv'),
                    'FAOSTAT 2016 + Literature (2nd order)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_2nd_order.csv'),
                    'FAOSTAT 2016 + Literature (3rd order)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_3rd_order.csv'),
                },
            },
            'Region: Middle East and Africa': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT 2016 + Literature (Exponential)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_Exponential.csv'),
                    'FAOSTAT 2016 + Literature (2nd order)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_2nd_order.csv'),
                    'FAOSTAT 2016 + Literature (3rd order)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_3rd_order.csv'),
                },
            },
            'Region: Latin America': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT 2016 + Literature (Exponential)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_Exponential.csv'),
                    'FAOSTAT 2016 + Literature (2nd order)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_2nd_order.csv'),
                    'FAOSTAT 2016 + Literature (3rd order)':
                    THISDIR.joinpath(
                        'ad', 'ad_FAOSTAT_2016_Literature_3rd_order.csv'),
                },
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            main_includes_regional=True,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_columns = ['Year'] + dd.REGIONS
        tla_2050 = self.tla_per_region.loc[2050]
        ref_base_2018 = pd.Series(self.ac.ref_base_adoption)

        # Data Source 1: Jong 2018
        # (https://link.springer.com/content/pdf/10.1007%2F978-981-10-5269-9.pdf);
        # FAOSTAT, accessed in 2018

        # 2050 medium adoption value based on historical data interpolation, based on FAOSTAT data
        ds1_adoption_data = self.ad.adoption_data(region='World')
        ds1_ad_2050 = ds1_adoption_data.loc[
            2050, 'FAOSTAT 2016 + Literature (Exponential)']
        ds1_percent = ds1_ad_2050 / tla_2050['World']

        ds1_percentages = pd.Series([
            0.0, ds1_percent, ds1_percent, ds1_percent, ds1_percent,
            ds1_percent, 0.0, 0.0, 0.0, 0.0
        ],
                                    index=dd.REGIONS)
        ds1_regional = tla_2050 * ds1_percentages
        ds1_regional.clip(lower=ref_base_2018, inplace=True)
        ds1_regional['World'] = 0.0
        ds1_world_2050 = ds1_regional.sum(axis=0)
        # Excel uses regional TLA to compute World, but doesn't populate regional adoption
        ds1_2050 = [
            ds1_world_2050, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
        ]

        # Data Source 2: Jong 2018
        # (https://link.springer.com/content/pdf/10.1007%2F978-981-10-5269-9.pdf);
        # FAOSTAT, accessed in 2018

        # 2050 average adoption value based on historical data interpolation,
        # based on FAOSTAT data (without TLA limitation)
        ds2_adoption_data = self.ad.adoption_data(region='World')
        ds2_ad_2050 = ds2_adoption_data.loc[
            2050, 'FAOSTAT 2016 + Literature (2nd order)']
        ds2_percent = ds2_ad_2050 / tla_2050['World']

        ds2_percentages = pd.Series([
            0.0, ds2_percent, ds2_percent, ds2_percent, ds2_percent,
            ds2_percent, 0.0, 0.0, 0.0, 0.0
        ],
                                    index=dd.REGIONS)
        ds2_regional = tla_2050 * ds2_percentages
        ds2_regional.clip(lower=ref_base_2018, inplace=True)
        ds2_regional['World'] = 0.0
        ds2_world_2050 = ds2_regional.sum(axis=0)
        # Excel uses regional TLA to compute World, but doesn't populate regional adoption
        ds2_2050 = [
            ds2_world_2050, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
        ]

        # Data Source 3: Jong 2018
        # (https://link.springer.com/content/pdf/10.1007%2F978-981-10-5269-9.pdf);
        # FAOSTAT, accessed in 2018

        # 2050 minimum adoption value based on historical data interpolation,
        # based on FAOSTAT data (without TLA limitation)
        ds3_adoption_data = self.ad.adoption_data(region='World')
        ds3_ad_2050 = ds3_adoption_data.loc[
            2050, 'FAOSTAT 2016 + Literature (linear)']
        ds3_percent = ds3_ad_2050 / tla_2050['World']

        ds3_percentages = pd.Series([
            0.0, ds3_percent, ds3_percent, ds3_percent, ds3_percent,
            ds3_percent, 0.0, 0.0, 0.0, 0.0
        ],
                                    index=dd.REGIONS)
        ds3_regional = tla_2050 * ds3_percentages
        ds3_regional.clip(lower=ref_base_2018, inplace=True)
        ds3_regional['World'] = 0.0
        ds3_world_2050 = ds3_regional.sum(axis=0)
        # Excel uses regional TLA to compute World, but doesn't populate regional adoption
        ds3_2050 = [
            ds3_world_2050, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
        ]

        ca_pds_data_sources = [
            {
                'name':
                'Medium growth based on exponential interpolation of historical data, linear trend',
                'include':
                True,
                # This scenario is built on the historical (1962-2016) average global
                # growth rate of tropical staple crops based on FAOSTAT 2018 and Jong
                # et al. 2018 data (see "Master - Adoption Data" sheet for details).
                # Future projections up to 2060 were interpolated based on an exponential
                # best-curve fit applied to historical data available at decadal intervals
                # for the given time-period.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2050] + ds1_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'High growth based on 2nd order polynomial interpolation of historical data, linear trend',
                'include':
                True,
                # This scenario is built on the historical (1962-2016) average global
                # growth rate of tropical staple crops based on FAOSTAT 2018 and Jong
                # et al. 2018 data (see "Master - Adoption Data" sheet for details).
                # Future projections up to 2060 were interpolated based on a 2nd order
                # polynomial best-curve fit applied to historical data available at
                # decadal intervals for the given time-period.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2050] + ds2_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Low growth based on linear interpolation of historical data, linear trend',
                'include':
                True,
                # This scenario is built on the historical (1962-2016) average global
                # growth rate of tropical staple crops based on FAOSTAT 2018 and Jong
                # et al. 2018 data (see "Master - Adoption Data" sheet for details).
                # Future projections up to 2060 were interpolated based on a linear
                # best-curve fit applied to historical data available at decadal
                # intervals for the given time-period.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2050] + ds3_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Medium growth with 70% adoption 2030 (based on exponential interpolations of historical data), linear trend',
                'include':
                True,
                # Scenario 1, with 70% adoption by 2030
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2030] + [0.7 * x for x in ds1_2050],
                    [2050] + ds1_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'High growth with 70% adoption 2030 (based on 2nd order polynomial interpolations of historical data), linear trend',
                'include':
                True,
                # Scenario 2, with 70% adoption by 2030
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2030] + [0.7 * x for x in ds2_2050],
                    [2050] + ds2_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Low growth with 70% adoption 2030 (based on linear interpolations of historical data), linear trend',
                'include':
                True,
                # Scenario 3, with 70% adoption by 2030
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2030] + [0.7 * x for x in ds3_2050],
                    [2050] + ds3_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Max adoption, linear growth',
                'include':
                True,
                # "100% adoption by 2050
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2050] + [
                        tla_2050['World'], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        for s in self.pds_ca.scenarios.values():
            df = s['df']
            for y in range(2012, 2019):
                df.loc[y] = [
                    0.0001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
                ]

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(list(
            self.ac.ref_base_adoption.values()),
                                            index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (
            ht_ref_adoption_initial / self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_pds_adoption_final_percentage = pd.Series(
            list(self.ac.pds_adoption_final_percentage.values()),
            index=list(self.ac.pds_adoption_final_percentage.keys()))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=self.tla_per_region,
            pds_adoption_limits=self.tla_per_region,
            use_first_pds_datapoint_main=True,
            adoption_base_year=2018,
            copy_pds_to_ref=False,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=self.tla_per_region,
            pds_total_adoption_units=self.tla_per_region,
            electricity_unit_factor=1000000.0,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_first_cost_uses_tot_units=True,
            fc_convert_iunit_factor=land.MHA_TO_HA)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=land.MHA_TO_HA)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
コード例 #18
0
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'Based on Smith et al, 2014 (max scenario); Fig 82,83 Pg 159,160':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_Smith_et_al_2014_max_scenario_Fig_8283_Pg_159160.csv'
                ),
                'Based on Buhaug et al,2009 (max scenario) Table 7.4 pg 94':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_Buhaug_et_al2009_max_scenario_Table_7_4_pg_94.csv'
                ),
                'Based on  RACE (max) Table 30 pg 126':
                THISDIR.joinpath('tam',
                                 'tam_based_on_RACE_max_Table_30_pg_126.csv'),
            },
            'Ambitious Cases': {
                'Based on Smith et al, 2014 (min BAU scenario); Fig 82,83 Pg 159,160':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_Smith_et_al_2014_min_BAU_scenario_Fig_8283_Pg_159160.csv'
                ),
                'Based on Buhaug et al,2009 (min BAU) Table 7.4 pg 94':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_Buhaug_et_al2009_min_BAU_Table_7_4_pg_94.csv'
                ),
                'Based on RACE (min BAU) Table 30 pg 126':
                THISDIR.joinpath(
                    'tam', 'tam_based_on_RACE_min_BAU_Table_30_pg_126.csv'),
            },
            'Maximum Cases': {
                'OPRF study Pg 30 Appdx 1':
                THISDIR.joinpath('tam', 'tam_OPRF_study_Pg_30_Appdx_1.csv'),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'PDS1 - Drawdown Team Calculations based on Projections from Smith et al (2014) - 3rd GHG Report of the IMO - Mean of projected EEOI values',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS1_Drawdown_Team_Calculations_based_on_Projections_from_Smith_et_al_2014_3rd_GHG_Repor_3eb1a907.csv'
                )
            },
            {
                'name':
                'PDS2 - Drawdown Team Calculations based on Projections from Smith et al (2014) - 3rd GHG Report of the IMO - 1 StDev more Ambitious than mean in EEOI terms',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS2_Drawdown_Team_Calculations_based_on_Projections_from_Smith_et_al_2014_3rd_GHG_Repor_e1bf2fbd.csv'
                )
            },
            {
                'name':
                'PDS3 - Drawdown Team Calculations based on Projections from Smith et al (2014) - 3rd GHG Report of the IMO - most ambitious values from all scenarios',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS3_Drawdown_Team_Calculations_based_on_Projections_from_Smith_et_al_2014_3rd_GHG_Repor_40d75a6d.csv'
                )
            },
            {
                'name':
                'Drawdown Book Edition 1 Scenario 1',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Book_Edition_1_Scenario_1.csv')
            },
            {
                'name':
                'Drawdown Book Edition 1 Scenario 2',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Book_Edition_1_Scenario_2.csv')
            },
            {
                'name':
                'Drawdown Book Edition 1 Scenario 3',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Book_Edition_1_Scenario_3.csv')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=pds_tam_per_region)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(
            [14427.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #19
0
ファイル: __init__.py プロジェクト: gitter-badger/solutions-1
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TLA
        self.ae = aez.AEZ(solution_name=self.name)
        if self.ac.use_custom_tla:
            self.c_tla = tla.CustomTLA(
                filename=THISDIR.joinpath('custom_tla_data.csv'))
            custom_world_vals = self.c_tla.get_world_values()
        else:
            custom_world_vals = None
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution(),
            custom_world_values=custom_world_vals)

        # Custom PDS Data
        ca_pds_columns = ['Year'] + dd.REGIONS
        commit_13_dec_2016 = 136.32  # commitment to reforestation made Dec 13, 2016.
        commit_13_dec_2016_tmr = 0.93  # % commitment that are projects in tropical TMR (based on country level commitments)
        commit_13_dec_2016_mha = commit_13_dec_2016 * commit_13_dec_2016_tmr  # Mha of current commitments in tropical TMR
        intact_13_dec_2016 = 0.328  # % commitment in tropical TMR available are for intact forest
        #                                restoration (based on country level commitments)
        max_land_bonn = 350.0  # Max land Expected total land commited under Bonn Challenge and NY Declaration
        max_land_wri = self.tla_per_region.loc[
            2050, 'World']  # Total degraded land suitable for
        #                                restoration, considered to be in tropical TMRs by WRI

        commit_1_mha_new = max_land_bonn - commit_13_dec_2016  # Mha of total degraded land available for
        #         new commitments in tropical TMR + additional degraded land available from the Forest
        #         Protection solution, for which exact area has to be estimated.
        final_adoption_1 = (commit_13_dec_2016_mha *
                            intact_13_dec_2016) + (commit_1_mha_new * 1.0)
        data_source_1 = {
            'name':
            'Optimistic-Achieve Commitment in 15 years w/ 100% intact, NYDF/2030 (Charlotte Wheeler, 2016)',
            'include':
            True,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million
            #       hectares (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario.This scenario projects the future adoption
            # of the solution considering, (1) 100% intact forest restoration, (2) 350 million
            # hectare land availability for future restoration of tropical forests, and
            # (3) the commitments will be realized by the year 2030.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2030, final_adoption_1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
                [
                    2031, final_adoption_1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        commit_2_mha_new = max_land_wri - (commit_13_dec_2016 *
                                           commit_13_dec_2016_tmr)
        final_adoption_2 = (commit_13_dec_2016_mha *
                            intact_13_dec_2016) + (commit_2_mha_new * 1.0)
        data_source_2 = {
            'name':
            'Optimistic-Achieve Commitment in 15 years w/ 100% intact, WRI/2030 (Charlotte Wheeler, 2016)',
            'include':
            True,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million hectares
            #       (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario.This scenario projects the future adoption
            # of the solution considering, (1) 100% intact forest restoration, (2) 304 million
            # hectare land availability for future restoration of tropical forests, and (3) the
            # commitments will be realized by the year 2030.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2030, final_adoption_2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
                [
                    2031, final_adoption_2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        future_3_tmr = 0.328  # % of future commitments in tropical thermal moisture regime available are for intact forest restoration
        final_adoption_3 = ((commit_13_dec_2016_mha * intact_13_dec_2016) + (
            (max_land_wri - commit_13_dec_2016_mha) * future_3_tmr))
        data_source_3 = {
            'name':
            'Conservative-Achieve Commitment in 15 years w/ 32.8% intact, WRI/2030 (Charlotte Wheeler,2016)',
            'include':
            True,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million hectares
            #       (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario.This scenario projects the future
            # adoption of the solution considering, (1) 32.8% intact forest restoration,
            # (2) 304 million hectare land availability for future restoration of tropical forests,
            # and (3) the commitments will be realized by the year 2030.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2030, final_adoption_3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
                [
                    2031, final_adoption_3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        future_4_tmr = 0.328  # % of future commitments in tropical thermal moisture regime available are for intact forest restoration
        final_adoption_4 = ((commit_13_dec_2016_mha * intact_13_dec_2016) + (
            (max_land_wri - commit_13_dec_2016_mha) * future_4_tmr))
        data_source_4 = {
            'name':
            'Conservative-Achieve Commitment in 15 years w/ 32.8% intact with continued growth post-2030, WRI/2030 and beyond (Charlotte Wheeler,2016)',
            'include':
            True,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million hectares
            #       (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario.This scenario projects the future
            # adoption of the solution considering, (1) 32.8% intact forest restoration,
            # (2) 304 million hectare land availability for future restoration of tropical forests,
            # and (3) the commitments will be realized by the year 2030.
            #
            # This is scenario 3, except, it is also assumed that the adoption of the solution
            # will continue post 2030 as well.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2030, final_adoption_4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        future_5_tmr = 1.0  # % of future commitments in tropical thermal moisture regime available are for intact forest restoration
        final_adoption_5 = ((commit_13_dec_2016_mha * intact_13_dec_2016) + (
            (max_land_wri - commit_13_dec_2016_mha) * future_5_tmr))
        data_source_5 = {
            'name':
            'Conservative-Achieve Commitment in 30 years w/ 100% intact, WRI/2045 (Charlotte Wheeler,2016)',
            'include':
            True,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million hectares
            #       (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario.This scenario projects the future
            # adoption of the solution considering, (1) 100% intact forest restoration,
            # (2) 304 million hectare land availability for future restoration of tropical forests,
            # and (3) the commitments will be realized by the year 2045.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2045, final_adoption_5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
                [
                    2046, final_adoption_5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        future_6_tmr = 0.328  # % of future commitments in tropical thermal moisture regime available are for intact forest restoration
        final_adoption_6 = ((commit_13_dec_2016_mha * intact_13_dec_2016) + (
            (max_land_wri - commit_13_dec_2016_mha) * future_6_tmr))
        data_source_6 = {
            'name':
            'Conservative-Achieve Commitment in 30 years w/ 32.8% intact, WRI/2045 (Charlotte Wheeler,2016)',
            'include':
            True,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million hectares
            #       (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario.This scenario projects the future
            # adoption of the solution considering, (1) 32.8% intact forest restoration,
            # (2) 304 million hectare land availability for future restoration of tropical forests,
            # and (3) the commitments will be realized by the year 2045.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2045, final_adoption_6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
                [
                    2046, final_adoption_6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        future_7_tmr = 0.328  # % of future commitments in tropical thermal moisture regime available are for intact forest restoration
        final_adoption_7 = ((commit_13_dec_2016_mha * intact_13_dec_2016) + (
            (max_land_wri - commit_13_dec_2016_mha) * future_7_tmr))
        data_source_7 = {
            'name':
            'Conservative-Achieve Commitment in 30 years w/ 32.8% intact with continued growth, WRI/2045 (Charlotte Wheeler,2016)',
            'include':
            True,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million hectares
            #       (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario. This scenario projects the future
            # adoption of the solution considering, (1) 32.8% intact forest restoration,
            # (2) 304 million hectare land availability for future restoration of tropical forests,
            # and (3) the commitments will be realized by the year 2045.
            #
            # This is scenario 6, except, it is also assumed that the adoption of the solution
            # will continue post 2045 as well.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2045, final_adoption_7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        future_8_tmr = 1.0  # % of future commitments in tropical thermal moisture regime available are for intact forest restoration
        final_adoption_8 = ((commit_13_dec_2016_mha * intact_13_dec_2016) + (
            (max_land_wri - commit_13_dec_2016_mha) * future_8_tmr))
        data_source_8 = {
            'name':
            'Conservative-Achieve Commitment in 45 years w/ 100% intact, WRI/2060 (Charlotte Wheeler,2016)',
            'include':
            False,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million hectares
            #       (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario.
            #
            # This scenario projects the future adoption of the solution considering,
            # (1) 100% intact forest restoration, (2) 304 million hectare land availability
            # for future restoration of tropical forests, and (3) the commitments will be
            # realized by the year 2060.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2060, final_adoption_8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        future_9_tmr = 0.328  # % of future commitments in tropical thermal moisture regime available are for intact forest restoration
        final_adoption_9 = ((commit_13_dec_2016_mha * intact_13_dec_2016) + (
            (max_land_wri - commit_13_dec_2016_mha) * future_9_tmr))
        data_source_9 = {
            'name':
            'Conservative-Achieve Commitment in 45 years w/ 32.8% intact, WRI/2060 (Charlotte Wheeler,2016)',
            'include':
            False,
            # The adoption scenarios are calculated using the linear trendline based on
            #   (i) current restoration commitments to date (as taken on 13/12/2016 from Bonn
            #       Challenge website);
            #  (ii) potential future commitments for intact forest restoration in tropics {32.80%
            #       (based on current commitments) or 100% (projected)};
            # (iii) the proportion of committed land restored to intact forest {304 million hectares
            #       (based on WRI calculation) or 350 million hectares (based on New York
            #       Declaration)}; and
            #  (iv) the year commitments are realized (2030, 2045 or 2060).
            # The current restoration commitments is fixed in all custom scenarios, while the rest
            # variables changes from scenario to scenario.
            #
            # This scenario projects the future adoption of the solution considering,
            # (1) 32.8% intact forest restoration, (2) 304 million hectare land availability
            # for future restoration of tropical forests, and (3) the commitments will be realized
            # by the year 2060.
            'datapoints':
            pd.DataFrame([
                [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                [
                    2060, final_adoption_9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0, 0.0
                ],
            ],
                         columns=ca_pds_columns).set_index('Year')
        }

        ca_pds_data_sources = [
            data_source_1, data_source_2, data_source_3, data_source_4,
            data_source_5, data_source_6, data_source_7, data_source_8,
            data_source_9
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None

        ht_ref_adoption_initial = pd.Series(
            [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (
            ht_ref_adoption_initial / self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=self.tla_per_region,
            pds_adoption_limits=self.tla_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=self.tla_per_region,
            pds_total_adoption_units=self.tla_per_region,
            electricity_unit_factor=1000000.0,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_first_cost_uses_tot_units=True,
            fc_convert_iunit_factor=land.MHA_TO_HA)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=land.MHA_TO_HA)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution())
コード例 #20
0
ファイル: __init__.py プロジェクト: benibienz/drawdown
  def __init__(self, scenario=None):
    if scenario is None:
      scenario = list(scenarios.keys())[0]
    self.scenario = scenario
    self.ac = scenarios[scenario]

    # TAM
    tamconfig_list = [
      ['param', 'World', 'PDS World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['source_until_2014', self.ac.source_until_2014, self.ac.source_until_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['source_after_2014', self.ac.ref_source_post_2014, self.ac.pds_source_post_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['trend', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    tamconfig = pd.DataFrame(tamconfig_list[1:], columns=tamconfig_list[0], dtype=np.object).set_index('param')
    tam_ref_data_sources = {
      'Baseline Cases': {
          'ETP 2016, URBAN 6 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_6_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ICCT, 2012, "Global Transportation Roadmap Model" + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ICCT_2012_Global_Transportation_Roadmap_Model_Nonmotorized_Travel_Adjustment.csv'),
      },
      'Conservative Cases': {
          'ETP 2016, URBAN 4 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_4_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ITDP - UC Davis (2015)  A Global High Shift Cycling Scenario Updated Report Data - Baseline Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Updated_Report_Data_Baseline_Scenario.csv'),
      },
      'Ambitious Cases': {
          'ETP 2016, URBAN 2 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_2_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ITDP - UC Davis (2015)  A Global High Shift Cycling Scenario Updated Report Data - HighShift Scenario': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Updated_Report_Data_HighShift_Scenario.csv'),
      },
      'Region: OECD90': {
        'Ambitious Cases': {
          'ITDP - UC Davis (2015)  A Global High Shift Cycling Scenario Updated Report Data - High shift': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Updated_Report_Data_High_shift.csv'),
        },
      },
      'Region: Eastern Europe': {
        'Ambitious Cases': {
          'ITDP - UC Davis (2015)  A Global High Shift Cycling Scenario Updated Report Data - High shift': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Updated_Report_Data_High_shift.csv'),
        },
      },
      'Region: Asia (Sans Japan)': {
        'Ambitious Cases': {
          'ITDP - UC Davis (2015)  A Global High Shift Cycling Scenario Updated Report Data - High shift': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Updated_Report_Data_High_shift.csv'),
        },
      },
      'Region: Middle East and Africa': {
        'Ambitious Cases': {
          'ITDP - UC Davis (2015)  A Global High Shift Cycling Scenario Updated Report Data - High shift': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Updated_Report_Data_High_shift.csv'),
        },
      },
      'Region: Latin America': {
        'Ambitious Cases': {
          'ITDP - UC Davis (2015)  A Global High Shift Cycling Scenario Updated Report Data - High shift': THISDIR.joinpath('tam', 'tam_ITDP_UC_Davis_2015_A_Global_High_Shift_Cycling_Scenario_Updated_Report_Data_High_shift.csv'),
        },
      },
    }
    self.tm = tam.TAM(tamconfig=tamconfig, tam_ref_data_sources=tam_ref_data_sources,
      tam_pds_data_sources=tam_ref_data_sources)
    ref_tam_per_region=self.tm.ref_tam_per_region()
    pds_tam_per_region=self.tm.pds_tam_per_region()

    # Custom PDS Data
    ca_pds_data_sources = [
      {'name': 'Drawdown Book Edition 1 Scenario 1', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Drawdown_Book_Edition_1_Scenario_1.csv')},
      {'name': 'Drawdown Book Edition 1 Scenario 2', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Drawdown_Book_Edition_1_Scenario_2.csv')},
    ]
    self.pds_ca = customadoption.CustomAdoption(data_sources=ca_pds_data_sources,
        soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
        high_sd_mult=1.0, low_sd_mult=1.0,
        total_adoption_limit=pds_tam_per_region)

    # Custom REF Data
    ca_ref_data_sources = [
      {'name': 'Custom REF Adoption - Fixed Mass Transit Pass-km Annually', 'include': False,
          'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Custom_REF_Adoption_Fixed_Mass_Transit_Passkm_Annually.csv')},
      {'name': 'Adoption Based on IEA 6DS', 'include': False,
          'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Adoption_based_on_IEA_6DS.csv')},
    ]
    self.ref_ca = customadoption.CustomAdoption(data_sources=ca_ref_data_sources,
        soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
        high_sd_mult=1.0, low_sd_mult=1.0,
        total_adoption_limit=ref_tam_per_region)

    ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region()

    if False:
      # One may wonder why this is here. This file was code generated.
      # This 'if False' allows subsequent conditions to all be elif.
      pass
    elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
      pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region()
      pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region()
      pds_adoption_is_single_source = None
    elif self.ac.soln_pds_adoption_basis == 'Linear':
      pds_adoption_data_per_region = None
      pds_adoption_trend_per_region = None
      pds_adoption_is_single_source = None

    ht_ref_adoption_initial = pd.Series(
      [9607070620938.643, 2177533057697.923, 575975431282.0925, 4506889445113.769, 1416146219920.7346,
       1334877448730.5225, 0.0, 0.0, 0.0, 0.0],
       index=dd.REGIONS)
    ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
    ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
    ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
    ht_pds_adoption_initial = ht_ref_adoption_initial
    ht_regions, ht_percentages = zip(*self.ac.pds_adoption_final_percentage)
    ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages), index=list(ht_regions))
    ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[2050]
    ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
    ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
    self.ht = helpertables.HelperTables(ac=self.ac,
        ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
        pds_adoption_data_per_region=pds_adoption_data_per_region,
        ref_adoption_limits=ref_tam_per_region, pds_adoption_limits=pds_tam_per_region,
        ref_adoption_data_per_region=ref_adoption_data_per_region,
        pds_adoption_trend_per_region=pds_adoption_trend_per_region,
        pds_adoption_is_single_source=pds_adoption_is_single_source)

    self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

    self.ua = unitadoption.UnitAdoption(ac=self.ac,
        ref_total_adoption_units=ref_tam_per_region, pds_total_adoption_units=pds_tam_per_region,
        soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
        soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
        bug_cfunits_double_count=True)
    soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
    soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
    conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
    soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

    self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
        ref_learning_increase_mult=2, conv_learning_increase_mult=2,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_tot_iunits=conv_ref_tot_iunits,
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        fc_convert_iunit_factor=1.0)

    self.oc = operatingcost.OperatingCost(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
        soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
        soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
        conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
        single_iunit_purchase_year=2017,
        soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
        conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
        conversion_factor=1.0)

    self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

    self.c2 = co2calcs.CO2Calcs(ac=self.ac,
        ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
        soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
        soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
        soln_pds_direct_co2_emissions_saved=self.ua.soln_pds_direct_co2_emissions_saved(),
        soln_pds_direct_ch4_co2_emissions_saved=self.ua.soln_pds_direct_ch4_co2_emissions_saved(),
        soln_pds_direct_n2o_co2_emissions_saved=self.ua.soln_pds_direct_n2o_co2_emissions_saved(),
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
        conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        fuel_in_liters=False)

    self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014, 'World'],
        soln_avg_annual_use=self.ac.soln_avg_annual_use,
        conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #21
0
  def __init__(self, scenario=None):
    if scenario is None:
      scenario = list(scenarios.keys())[0]
    self.scenario = scenario
    self.ac = scenarios[scenario]

    # TAM
    tamconfig_list = [
      ['param', 'World', 'PDS World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
       'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
      ['source_until_2014', self.ac.source_until_2014, self.ac.source_until_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['source_after_2014', self.ac.ref_source_post_2014, self.ac.pds_source_post_2014,
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
       'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'],
      ['trend', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
       '3rd Poly', '3rd Poly', '3rd Poly'],
      ['growth', 'Medium', 'Medium', 'Medium', 'Medium',
       'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'],
      ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
      ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
    tamconfig = pd.DataFrame(tamconfig_list[1:], columns=tamconfig_list[0], dtype=np.object).set_index('param')
    tam_ref_data_sources = {
      'Baseline Cases': {
          'ETP 2016, URBAN 6 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_6_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ICCT, 2012, "Global Transportation Roadmap Model" + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ICCT_2012_Global_Transportation_Roadmap_Model_Nonmotorized_Travel_Adjustment.csv'),
      },
      'Conservative Cases': {
          'ETP 2016, URBAN 4 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_4_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ITDP/UC Davis 2014 Global High Shift Baseline': THISDIR.joinpath('tam', 'tam_ITDPUC_Davis_2014_Global_High_Shift_Baseline.csv'),
      },
      'Ambitious Cases': {
          'ETP 2016, URBAN 2 DS + Non-motorized Travel Adjustment': THISDIR.joinpath('tam', 'tam_ETP_2016_URBAN_2_DS_Nonmotorized_Travel_Adjustment.csv'),
          'ITDP/UC Davis 2014 Global High Shift HighShift': THISDIR.joinpath('tam', 'tam_ITDPUC_Davis_2014_Global_High_Shift_HighShift.csv'),
      },
    }
    self.tm = tam.TAM(tamconfig=tamconfig, tam_ref_data_sources=tam_ref_data_sources,
      tam_pds_data_sources=tam_ref_data_sources)
    ref_tam_per_region=self.tm.ref_tam_per_region()
    pds_tam_per_region=self.tm.pds_tam_per_region()

    # Custom PDS Data
    ca_pds_data_sources = [
      {'name': '(OPT2) Drawdown Team projections based on a weighted average of Several Sources', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_OPT2_Drawdown_Team_projections_based_on_a_weighted_average_of_Several_Sources.csv')},
      {'name': '(OPT3) Drawdown Theoretical linear growth until 10% urban transport adoption in 2050', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_OPT3_Drawdown_Theoretical_linear_growth_until_10_urban_transport_adoption_in_2050.csv')},
      {'name': 'Drawdown Book Edition 1 Scenario 1', 'include': False,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Drawdown_Book_Edition_1_Scenario_1.csv')},
    ]
    self.pds_ca = customadoption.CustomAdoption(data_sources=ca_pds_data_sources,
        soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
        high_sd_mult=1.0, low_sd_mult=1.0,
        total_adoption_limit=pds_tam_per_region)

    # Custom REF Data
    ca_ref_data_sources = [
      {'name': 'Drawdown Book Ed.1 Reference Scenario', 'include': False,
          'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Drawdown_Book_Ed_1_Reference_Scenario.csv')},
    ]
    self.ref_ca = customadoption.CustomAdoption(data_sources=ca_ref_data_sources,
        soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
        high_sd_mult=1.0, low_sd_mult=1.0,
        total_adoption_limit=ref_tam_per_region)

    ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region()

    if False:
      # One may wonder why this is here. This file was code generated.
      # This 'if False' allows subsequent conditions to all be elif.
      pass
    elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
      pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region()
      pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region()
      pds_adoption_is_single_source = None

    ht_ref_adoption_initial = pd.Series(
      [856.0, 233.98839923734755, 3.173527202810714, 859.4513386529659, 48.52296834532601,
       157.5563510884852, 311.3487952155772, 185.19183304641325, 138.07360106730914, 13.301055629175583],
       index=dd.REGIONS)
    ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
    ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
    ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
    ht_pds_adoption_initial = ht_ref_adoption_initial
    ht_regions, ht_percentages = zip(*self.ac.pds_adoption_final_percentage)
    ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages), index=list(ht_regions))
    ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[2050]
    ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
    ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
    ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
    self.ht = helpertables.HelperTables(ac=self.ac,
        ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
        pds_adoption_data_per_region=pds_adoption_data_per_region,
        ref_adoption_limits=ref_tam_per_region, pds_adoption_limits=pds_tam_per_region,
        ref_adoption_data_per_region=ref_adoption_data_per_region,
        pds_adoption_trend_per_region=pds_adoption_trend_per_region,
        pds_adoption_is_single_source=pds_adoption_is_single_source)

    self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

    self.ua = unitadoption.UnitAdoption(ac=self.ac,
        ref_total_adoption_units=ref_tam_per_region, pds_total_adoption_units=pds_tam_per_region,
        soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
        soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
        repeated_cost_for_iunits=False,
        bug_cfunits_double_count=False)
    soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
    soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
    conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
    soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

    self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
        ref_learning_increase_mult=2, conv_learning_increase_mult=2,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_tot_iunits=conv_ref_tot_iunits,
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        fc_convert_iunit_factor=1.0)

    self.oc = operatingcost.OperatingCost(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
        soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
        conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
        soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
        soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
        conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
        single_iunit_purchase_year=2017,
        soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
        conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
        conversion_factor=1.0)

    self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

    self.c2 = co2calcs.CO2Calcs(ac=self.ac,
        ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
        soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
        soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
        soln_pds_direct_co2_emissions_saved=self.ua.soln_pds_direct_co2_emissions_saved(),
        soln_pds_direct_ch4_co2_emissions_saved=self.ua.soln_pds_direct_ch4_co2_emissions_saved(),
        soln_pds_direct_n2o_co2_emissions_saved=self.ua.soln_pds_direct_n2o_co2_emissions_saved(),
        soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
        soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
        conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
        conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
        conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
        soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
        fuel_in_liters=False)

    self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014, 'World'],
        soln_avg_annual_use=self.ac.soln_avg_annual_use,
        conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #22
0
ファイル: __init__.py プロジェクト: scottwedge/solutions
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'IEA (2016), "Energy Technology Perspectives - 6DS", IEA/OECD':
                THISDIR.joinpath(
                    'tam',
                    'tam_IEA_2016_Energy_Technology_Perspectives_6DS_IEAOECD.csv'
                ),
                'ICCT (2012) "Global Transport Roadmap Model", http://www.theicct.org/global-transportation-roadmap-model':
                THISDIR.joinpath(
                    'tam',
                    'tam_ICCT_2012_Global_Transport_Roadmap_Model_httpwww_theicct_orgglobaltransportationroadmapmodel.csv'
                ),
            },
            'Conservative Cases': {
                'IEA (2016), "Energy Technology Perspectives - 4DS", IEA/OECD':
                THISDIR.joinpath(
                    'tam',
                    'tam_IEA_2016_Energy_Technology_Perspectives_4DS_IEAOECD.csv'
                ),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'PDS1 - Projecting HSR Travel based on announced Track building plans',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS1_Projecting_HSR_Travel_based_on_announced_Track_building_plans.csv'
                )
            },
            {
                'name':
                'PDS2 - Projecting HSR Travel based on announced Track building plans',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS2_Projecting_HSR_Travel_based_on_announced_Track_building_plans.csv'
                )
            },
            {
                'name':
                'PDS3 - Projecting HSR Travel based on announced Track building plans',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS3_Projecting_HSR_Travel_based_on_announced_Track_building_plans.csv'
                )
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=pds_tam_per_region)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series([
            614.0, 202.18263170296004, 2.738, 409.376, 0.0, 0.0, 386.3, 0.0,
            107.5006306909091, 0.7167517029599999
        ],
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #23
0
ファイル: __init__.py プロジェクト: scottwedge/solutions
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        self.tm = tam.TAM(
            tamconfig=tamconfig,
            tam_ref_data_sources=rrs.energy_tam_1_ref_data_sources,
            tam_pds_data_sources=rrs.energy_tam_1_pds_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Baseline Cases': {
                'Based on: IRENA (2016)':
                THISDIR.joinpath('ad', 'ad_based_on_IRENA_2016.csv'),
                'Based on: IEA ETP 2016 6DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
            },
            'Conservative Cases': {
                'Based on: IEA ETP 2016 4DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
                'Based on: Greenpeace (2015) - Reference Scenario':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Greenpeace_2015_Reference_Scenario.csv'),
            },
            'Ambitious Cases': {
                'Based on: IEA ETP 2016 2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
                'Based on: Greenpeace 2015 Energy Revolution':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
                'Based on: Greenpeace 2015 Energy Revolution with Drawdown perennials':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Greenpeace_2015_Energy_Revolution_with_Drawdown_perennials.csv'
                ),
                'Based on: Greenpeace 2015 Advanced Revolution with Drawdown perennials':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Greenpeace_2015_Advanced_Revolution_with_Drawdown_perennials.csv'
                ),
                'Based on: IEA ETP 2016 2DS with OPT2 perennials':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEA_ETP_2016_2DS_with_OPT2_perennials.csv'),
            },
            '100% RES2050 Case': {
                'Based on: Greenpeace 2015 Advanced Revolution':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series([
            55.418723948374556, 1.374902800958828, 0.049897295303677716,
            4.292985516188078, 0.41937969656046536, 12.138577652661485,
            4.6261055160089875, 3.3303919448438495, 17.146488383747197,
            9.810373894058708
        ],
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=rrs.TERAWATT_TO_KILOWATT)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=rrs.TERAWATT_TO_KILOWATT)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #24
0
ファイル: __init__.py プロジェクト: gitter-badger/solutions-1
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'ETP 2016, URBAN 6 DS + Non-motorized Travel Adjustment':
                THISDIR.joinpath(
                    'tam',
                    'tam_ETP_2016_URBAN_6_DS_Nonmotorized_Travel_Adjustment.csv'
                ),
                'ICCT, 2012, "Global Transportation Roadmap Model" + Non-motorized Travel Adjustment':
                THISDIR.joinpath(
                    'tam',
                    'tam_ICCT_2012_Global_Transportation_Roadmap_Model_Nonmotorized_Travel_Adjustment.csv'
                ),
            },
            'Conservative Cases': {
                'ETP 2016, URBAN 4 DS + Non-motorized Travel Adjustment':
                THISDIR.joinpath(
                    'tam',
                    'tam_ETP_2016_URBAN_4_DS_Nonmotorized_Travel_Adjustment.csv'
                ),
                'ITDP/UC Davis 2014 Global High Shift Baseline':
                THISDIR.joinpath(
                    'tam',
                    'tam_ITDPUC_Davis_2014_Global_High_Shift_Baseline.csv'),
            },
            'Ambitious Cases': {
                'ETP 2016, URBAN 2 DS + Non-motorized Travel Adjustment':
                THISDIR.joinpath(
                    'tam',
                    'tam_ETP_2016_URBAN_2_DS_Nonmotorized_Travel_Adjustment.csv'
                ),
                'ITDP/UC Davis 2014 Global High Shift HighShift':
                THISDIR.joinpath(
                    'tam',
                    'tam_ITDPUC_Davis_2014_Global_High_Shift_HighShift.csv'),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Ambitious Cases': {
                '(PDS1) Based on ITDP/UCD (2015) A Global High Shift Cycling Scenario (with recent historical data included)':
                THISDIR.joinpath(
                    'ad',
                    'ad_PDS1_based_on_ITDPUCD_2015_A_Global_High_Shift_Cycling_Scenario_with_recent_historical_d_7e6e1325.csv'
                ),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                '(PDS2) Drawdown Team projections based on a weighted average of Several Sources',
                'include':
                True,
                'description':
                ("Taking Published projections for each of Project Drawdown's five regions, "
                 "we estimate the regional growth in bike infrastructure usage and then sum "
                 "each year after interpolations. These sources exclude the ITDP data which "
                 "are used for the Plausible (PDS1) Scenario "),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS2_Drawdown_Team_projections_based_on_a_weighted_average_of_Several_Sources.csv'
                )
            },
            {
                'name':
                '(PDS3) Drawdown Theoretical linear growth until 10% urban transport adoption in 2050',
                'include':
                True,
                'description':
                ('This scenario was developed for the Drawdown Book Edition 1 and differs '
                 'slightly to the updated adoption scenarios. This scenario uses a linear '
                 'projeciton to 10% adoption in 2050 to estimate an adoption curve. '
                 ),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS3_Drawdown_Theoretical_linear_growth_until_10_urban_transport_adoption_in_2050.csv'
                )
            },
            {
                'name':
                'Drawdown Book Edition 1 Scenario 1',
                'include':
                False,
                'description':
                ('This scenario was developed for the Drawdown Book Edition 1 and differs '
                 'slightly to the updated adoption scenarios. This scenario uses ITDP/UCDavis '
                 'Global High Shift Cycling Scenario (2015) data (with interpolation) to '
                 'estimate an adoption. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Book_Edition_1_Scenario_1.csv')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=self.ac.soln_pds_adoption_custom_high_sd_mult,
            low_sd_mult=self.ac.soln_pds_adoption_custom_low_sd_mult,
            total_adoption_limit=pds_tam_per_region)

        # Custom REF Data
        ca_ref_data_sources = [
            {
                'name':
                'Drawdown Book Ed.1 Reference Scenario',
                'include':
                True,
                'description':
                ('As the reference adoption case assumes (like most Drawdown solution) that '
                 'the reference adoption remains fixed in percentage terms of the TAM, if the '
                 'TAM calculationschange, the reference adoption also changes. The original '
                 'reference adoption used for the models developed for the Drawdown book '
                 '(edition 1) are stored here for those scenarios. '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Drawdown_Book_Ed_1_Reference_Scenario.csv')
            },
            {
                'name':
                'Linear REF Growth Integrated with Recent Historical Adoption',
                'include':
                True,
                'description':
                ('We take the Default Project Drawdown REF adoption using Average Baseline '
                 'TAM data and then adjust the years 2012-2018 to be the estimated historical '
                 'adoptions from the Modeshare URBAN tab (with each year calculated by '
                 'changing the current year input). '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Linear_REF_Growth_Integrated_with_Recent_Historical_Adoption.csv'
                )
            },
        ]
        self.ref_ca = customadoption.CustomAdoption(
            data_sources=ca_ref_data_sources,
            soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=ref_tam_per_region)

        ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region()

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()
        elif self.ac.soln_pds_adoption_basis == 'Linear':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = None
            pds_adoption_is_single_source = None

        ht_ref_adoption_initial = pd.Series(list(
            self.ac.ref_base_adoption.values()),
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_pds_adoption_final_percentage = pd.Series(
            list(self.ac.pds_adoption_final_percentage.values()),
            index=list(self.ac.pds_adoption_final_percentage.keys()))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2018] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            ref_adoption_data_per_region=ref_adoption_data_per_region,
            use_first_pds_datapoint_main=False,
            copy_pds_to_ref=False,
            copy_ref_datapoint=False,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(
            ac=self.ac, grid_emissions_version=3)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            repeated_cost_for_iunits=False,
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #25
0
ファイル: __init__.py プロジェクト: benibienz/drawdown
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'Calculated  from 2 sources - World Bank (2015) The State of the global Clean and Improved Cooking Sector, https://openknowledge.worldbank.org/bitstream/handle/10986/21878/96499.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                THISDIR.joinpath(
                    'tam',
                    'tam_Calculated_from_2_sources_World_Bank_2015_The_State_of_the_global_Clean_and_Improved_Coo_bef286f6.csv'
                ),
                'Calculated  from 2 sources - REN21 (2015) Renewables 2015 - Global Status Report, http://www.ren21.net/wp-content/uploads/2015/07/REN12-GSR2015_Onlinebook_low1.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                THISDIR.joinpath(
                    'tam',
                    'tam_Calculated_from_2_sources_REN21_2015_Renewables_2015_Global_Status_Report_httpwww_ren21__ee9a59ea.csv'
                ),
                'Drawdown Summation: Regional Sum':
                THISDIR.joinpath('tam',
                                 'tam_Drawdown_Summation_Regional_Sum.csv'),
            },
            'Conservative Cases': {
                'Based on IEA (2013) World Energy Outlook':
                THISDIR.joinpath(
                    'tam', 'tam_based_on_IEA_2013_World_Energy_Outlook.csv'),
            },
            'Region: Asia (Sans Japan)': {
                'Baseline Cases': {
                    'Calculated  from summing India and China from 2 sources - World Bank (2015) The State of the global Clean and Improved Cooking Sector, https://openknowledge.worldbank.org/bitstream/handle/10986/21878/96499.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_summing_India_and_China_from_2_sources_World_Bank_2015_The_State_of_the__778b8aac.csv'
                    ),
                    'Calculated  from 2 sources - World Bank (2015) The State of the global Clean and Improved Cooking Sector, https://openknowledge.worldbank.org/bitstream/handle/10986/21878/96499.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_2_sources_World_Bank_2015_The_State_of_the_global_Clean_and_Improved_Coo_bef286f6.csv'
                    ),
                    'Calculated  from 2 sources - REN21 (2015) Renewables 2015 - Global Status Report, http://www.ren21.net/wp-content/uploads/2015/07/REN12-GSR2015_Onlinebook_low1.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_2_sources_REN21_2015_Renewables_2015_Global_Status_Report_httpwww_ren21__ee9a59ea.csv'
                    ),
                },
                'Conservative Cases': {
                    'Based on IEA (2013) World Energy Outlook':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_IEA_2013_World_Energy_Outlook.csv'),
                },
            },
            'Region: Middle East and Africa': {
                'Baseline Cases': {
                    'Based on Ibitoye, F. I. (2013). The millennium development goals and household energy requirements in Nigeria. SpringerPlus, 2(1), 529.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_Ibitoye_F__I__2013__The_millennium_development_goals_and_household_energy_requi_26c73895.csv'
                    ),
                    'Calculated  from 2 sources - World Bank (2015) The State of the global Clean and Improved Cooking Sector, https://openknowledge.worldbank.org/bitstream/handle/10986/21878/96499.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_2_sources_World_Bank_2015_The_State_of_the_global_Clean_and_Improved_Coo_bef286f6.csv'
                    ),
                    'Calculated  from 2 sources - REN21 (2015) Renewables 2015 - Global Status Report, http://www.ren21.net/wp-content/uploads/2015/07/REN12-GSR2015_Onlinebook_low1.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_2_sources_REN21_2015_Renewables_2015_Global_Status_Report_httpwww_ren21__ee9a59ea.csv'
                    ),
                },
                'Conservative Cases': {
                    'Based on IEA (2013) World Energy Outlook':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_IEA_2013_World_Energy_Outlook.csv'),
                },
            },
            'Region: China': {
                'Baseline Cases': {
                    'Calculated  from 2 sources - World Bank (2015) The State of the global Clean and Improved Cooking Sector, https://openknowledge.worldbank.org/bitstream/handle/10986/21878/96499.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_2_sources_World_Bank_2015_The_State_of_the_global_Clean_and_Improved_Coo_bef286f6.csv'
                    ),
                    'Calculated  from 2 sources - REN21 (2015) Renewables 2015 - Global Status Report, http://www.ren21.net/wp-content/uploads/2015/07/REN12-GSR2015_Onlinebook_low1.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_2_sources_REN21_2015_Renewables_2015_Global_Status_Report_httpwww_ren21__ee9a59ea.csv'
                    ),
                },
                'Conservative Cases': {
                    'Based on Yuan, Y., & Zhao, I. (2013). Energy in Rural Areas of Northern China. Journal of Applied Sciences, 13(9), 1449-1454.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_Yuan_Y__Zhao_I__2013__Energy_in_Rural_Areas_of_Northern_China__Journal_of_Appli_91a28afa.csv'
                    ),
                },
                'Ambitious Cases': {
                    'Based on IEA (2013) World Energy Outlook':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_IEA_2013_World_Energy_Outlook.csv'),
                    'Based on Mainali, B., Pachauri, S., & Nagai, Y. (2012). Analyzing cooking fuel and stove choices in China till 2030. Journal of Renewable and Sustainable Energy, 4(3), 031805.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_Mainali_B__Pachauri_S__Nagai_Y__2012__Analyzing_cooking_fuel_and_stove_choices__e3f8fc59.csv'
                    ),
                },
            },
            'Region: India': {
                'Baseline Cases': {
                    'Based on Nakagami, H., Murakoshi, C., & Iwafune, Y. (2008). International comparison of household energy consumption and its indicator. Proceedings of the 2008 ACEEE Summer Study on Energy Efficiency in Buildings, 214-224.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_Nakagami_H__Murakoshi_C__Iwafune_Y__2008__International_comparison_of_household_58b0d8c2.csv'
                    ),
                    'Calculated  from 2 sources - World Bank (2015) The State of the global Clean and Improved Cooking Sector, https://openknowledge.worldbank.org/bitstream/handle/10986/21878/96499.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_2_sources_World_Bank_2015_The_State_of_the_global_Clean_and_Improved_Coo_bef286f6.csv'
                    ),
                    'Calculated  from 2 sources - REN21 (2015) Renewables 2015 - Global Status Report, http://www.ren21.net/wp-content/uploads/2015/07/REN12-GSR2015_Onlinebook_low1.pdf AND Daioglou, V., Van Ruijven, B. J., & Van Vuuren, D. P. (2012). Model projections for household energy use in developing countries. Energy, 37(1), 601-615.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculated_from_2_sources_REN21_2015_Renewables_2015_Global_Status_Report_httpwww_ren21__ee9a59ea.csv'
                    ),
                },
                'Conservative Cases': {
                    'Based on IEA (2013) World Energy Outlook':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_IEA_2013_World_Energy_Outlook.csv'),
                },
                'Maximum Cases': {
                    'Based on Venkataraman, C., Sagar, A. D., Habib, G., Lam, N., & Smith, K. R. (2010). The Indian national initiative for advanced biomass cookstoves: the benefits of clean combustion. Energy for Sustainable Development, 14(2), 63-72.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_based_on_Venkataraman_C__Sagar_A__D__Habib_G__Lam_N__Smith_K__R__2010__The_Indian_nation_114cfe53.csv'
                    ),
                },
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 0.25, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Baseline Cases': {
                'Global alliance For Clean cookstoves -  Interpolated':
                THISDIR.joinpath(
                    'ad',
                    'ad_Global_alliance_For_Clean_cookstoves_Interpolated.csv'
                ),
                'International Energy Agency  -  Interpolated':
                THISDIR.joinpath(
                    'ad', 'ad_International_Energy_Agency_Interpolated.csv'),
                'The World Bank':
                THISDIR.joinpath('ad', 'ad_The_World_Bank.csv'),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()
        elif self.ac.soln_pds_adoption_basis == 'Linear':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = None
            pds_adoption_is_single_source = None

        ht_ref_adoption_initial = pd.Series([
            20.308819914652318, 0.0, 0.0, 25.04194984517459, 5.337266131329677,
            36.925127117549664, 0.0, 0.0, 0.0, 0.0
        ],
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #26
0
ファイル: __init__.py プロジェクト: gitter-badger/solutions-1
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        self.tm = tam.TAM(
            tamconfig=tamconfig,
            tam_ref_data_sources=rrs.energy_tam_2_ref_data_sources,
            tam_pds_data_sources=rrs.energy_tam_2_pds_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Baseline Cases': {
                'Based on IEA, WEO-2018, Current Policies Scenario (CPS)':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEA_WEO2018_Current_Policies_Scenario_CPS.csv'
                ),
                'Based on: IEA ETP 2017 Ref Tech':
                THISDIR.joinpath('ad',
                                 'ad_based_on_IEA_ETP_2017_Ref_Tech.csv'),
                'Based on Equinor (2018), Rivalry Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Equinor_2018_Rivalry_Scenario.csv'),
                'Based on IEEJ Outlook - 2019, Ref Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_IEEJ_Outlook_2019_Ref_Scenario.csv'),
            },
            'Conservative Cases': {
                'Based on IEA, WEO-2018, New Policies Scenario (NPS)':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEA_WEO2018_New_Policies_Scenario_NPS.csv'),
                'Based on Equinor (2018), Reform Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Equinor_2018_Reform_Scenario.csv'),
                'Based on IEEJ Outlook - 2019, Advanced Tech Scenario':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEEJ_Outlook_2019_Advanced_Tech_Scenario.csv'
                ),
            },
            'Ambitious Cases': {
                'Based on IEA, WEO-2018, SDS Scenario':
                THISDIR.joinpath('ad',
                                 'ad_based_on_IEA_WEO2018_SDS_Scenario.csv'),
                'Based on: IEA ETP 2017 B2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2017_B2DS.csv'),
                'Based on IRENA. 2018) Roadmap-2050, REmap Case':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IRENA__2018_Roadmap2050_REmap_Case.csv'),
                'Based on: IEA ETP 2017 2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2017_2DS.csv'),
                'Based on Equinor (2018), Renewal Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Equinor_2018_Renewal_Scenario.csv'),
            },
            '100% RES2050 Case': {
                'Based on average of: LUT/EWG 2019 100% RES, Ecofys 2018 1.5C and Greenpeace 2015 Advanced Revolution':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_average_of_LUTEWG_2019_100_RES_Ecofys_2018_1_5C_and_Greenpeace_2015_Advanced_Revolution.csv'
                ),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Legacy Book Scenario - High Ambitious, double growth by 2030 & 2050',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Legacy_Book_Scenario_High_Ambitious_double_growth_by_2030_2050.csv'
                )
            },
            {
                'name':
                'Legacy Book Scenario - Conservative Growth of 2.5% annum',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Legacy_Book_Scenario_Conservative_Growth_of_2_5_annum.csv'
                )
            },
            {
                'name':
                'Legacy Book Scenario. Low Ambitious Growth, 10% higher compared to REF case',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Legacy_Book_Scenario__Low_Ambitious_Growth_10_higher_compared_to_REF_case.csv'
                )
            },
            {
                'name':
                'Ambitious Cases (Legacy Book and February 2019 Update)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Ambitious_Cases_Legacy_Book_and_February_2019_Update.csv'
                )
            },
            {
                'name':
                'Conservative Cases (Legacy Book and February 2019 Update)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Conservative_Cases_Legacy_Book_and_February_2019_Update.csv'
                )
            },
            {
                'name':
                'Baseline Cases (Legacy Book and February 2019 Update)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Baseline_Cases_Legacy_Book_and_February_2019_Update.csv'
                )
            },
            {
                'name':
                '100% RE Cases',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_100_RE_Cases.csv')
            },
            {
                'name':
                'High growth  Scenario @ 1.6% per annum (Feb 2019 update)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_High_growth_Scenario_1_6_per_annum_Feb_2019_update.csv'
                )
            },
            {
                'name':
                'Medium Growth Scenario @ 1.33% per annum (Feb 2019 update)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Medium_Growth_Scenario_1_33_per_annum_Feb_2019_update.csv'
                )
            },
            {
                'name':
                'Low Growth Scenario @ 10.8% per annum (Feb 2019 update)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Low_Growth_Scenario_10_8_per_annum_Feb_2019_update.csv'
                )
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=pds_tam_per_region)

        # Custom REF Data
        ca_ref_data_sources = [
            {
                'name':
                '[Type Scenario 1 Name Here (REF CASE)...]',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Type_Scenario_1_Name_Here_REF_CASE_.csv')
            },
            {
                'name':
                '[Type Scenario 2 Name Here (REF CASE)...]',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Type_Scenario_2_Name_Here_REF_CASE_.csv')
            },
            {
                'name':
                '[Type Scenario 3 Name Here (REF CASE)...]',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Type_Scenario_3_Name_Here_REF_CASE_.csv')
            },
            {
                'name':
                '[Type Scenario 4 Name Here (REF CASE)...]',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Type_Scenario_4_Name_Here_REF_CASE_.csv')
            },
        ]
        self.ref_ca = customadoption.CustomAdoption(
            data_sources=ca_ref_data_sources,
            soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=ref_tam_per_region)

        if self.ac.soln_ref_adoption_basis == 'Custom':
            ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region(
            )
        else:
            ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(list(
            self.ac.ref_base_adoption.values()),
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            ref_adoption_data_per_region=ref_adoption_data_per_region,
            use_first_pds_datapoint_main=False,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source,
            adoption_base_year=2018,
            copy_pds_to_ref=True)

        self.ef = emissionsfactors.ElectricityGenOnGrid(
            ac=self.ac, grid_emissions_version=2)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=rrs.TERAWATT_TO_KILOWATT)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=rrs.TERAWATT_TO_KILOWATT)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #27
0
ファイル: __init__.py プロジェクト: quinn-p-mchugh/solutions
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        self.tm = tam.TAM(
            tamconfig=tamconfig,
            tam_ref_data_sources=rrs.energy_tam_2_ref_data_sources,
            tam_pds_data_sources=rrs.energy_tam_2_pds_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Baseline Cases': {
                'Based on IEA, WEO-2018, Current Policies Scenario (CPS)':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEA_WEO2018_Current_Policies_Scenario_CPS.csv'
                ),
                'Based on: IEA ETP 2017 Ref Tech':
                THISDIR.joinpath('ad',
                                 'ad_based_on_IEA_ETP_2017_Ref_Tech.csv'),
                'Based on Equinor (2018), Rivalry Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Equinor_2018_Rivalry_Scenario.csv'),
                'Based on IEEJ Outlook - 2019, Ref Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_IEEJ_Outlook_2019_Ref_Scenario.csv'),
            },
            'Conservative Cases': {
                'Based on IEA, WEO-2018, New Policies Scenario (NPS)':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEA_WEO2018_New_Policies_Scenario_NPS.csv'),
                'Based on Equinor (2018), Reform Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Equinor_2018_Reform_Scenario.csv'),
                'Based on: Grantham Institute and Carbon Tracker (2017) Strong_PVEV_Med. Scenario':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Grantham_Institute_and_Carbon_Tracker_2017_Strong_PVEV_Med__Scenario.csv'
                ),
                'Based on IEEJ Outlook - 2019, Advanced Tech Scenario':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEEJ_Outlook_2019_Advanced_Tech_Scenario.csv'
                ),
            },
            'Ambitious Cases': {
                'Based on IEA, WEO-2018, SDS Scenario':
                THISDIR.joinpath('ad',
                                 'ad_based_on_IEA_WEO2018_SDS_Scenario.csv'),
                'Based on: IEA ETP 2017 2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2017_2DS.csv'),
                'Based on: IEA ETP 2017 B2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2017_B2DS.csv'),
                'Based on Equinor (2018), Renewal Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Equinor_2018_Renewal_Scenario.csv'),
            },
            '100% RES2050 Case': {
                'Based on: Greenpeace 2015 Advanced Revolution':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
            },
            'Region: OECD90': {
                'Conservative Cases': {
                    'Based on: AMPERE 2014 GEM E3 550':
                    THISDIR.joinpath('ad',
                                     'ad_based_on_AMPERE_2014_GEM_E3_550.csv'),
                    'Based on: AMPERE 2014 MESSAGE MACRO 550':
                    THISDIR.joinpath(
                        'ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_550.csv'),
                    'Based on: AMPERE 2014 IMAGE TIMER 550':
                    THISDIR.joinpath(
                        'ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_550.csv'),
                },
                'Ambitious Cases': {
                    'Based on: AMPERE 2014 GEM E3 450':
                    THISDIR.joinpath('ad',
                                     'ad_based_on_AMPERE_2014_GEM_E3_450.csv'),
                    'Based on: AMPERE 2014 MESSAGE MACRO 450':
                    THISDIR.joinpath(
                        'ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_450.csv'),
                    'Based on: AMPERE 2014 IMAGE TIMER 450':
                    THISDIR.joinpath(
                        'ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_450.csv'),
                },
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(list(
            self.ac.ref_base_adoption.values()),
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            use_first_pds_datapoint_main=False,
            adoption_base_year=2018,
            copy_pds_to_ref=True,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(
            ac=self.ac, grid_emissions_version=2)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=rrs.TERAWATT_TO_KILOWATT)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=rrs.TERAWATT_TO_KILOWATT)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #28
0
ファイル: __init__.py プロジェクト: gitter-badger/solutions-1
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TLA
        self.ae = aez.AEZ(solution_name=self.name,
                          cohort=2020,
                          regimes=dd.THERMAL_MOISTURE_REGIMES8)
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution())

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE',
                'NOTE'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Raw Data for ALL LAND TYPES': {
                'Organic annual cropland estimate (sum of low growth by regions)':
                THISDIR.joinpath(
                    'ad',
                    'ad_Organic_annual_cropland_estimate_sum_of_low_growth_by_regions.csv'
                ),
                'Organic annual cropland estimate (sum of medium growth by region)':
                THISDIR.joinpath(
                    'ad',
                    'ad_Organic_annual_cropland_estimate_sum_of_medium_growth_by_region.csv'
                ),
                'Organic annual cropland estimate (sum of high growth by region)':
                THISDIR.joinpath(
                    'ad',
                    'ad_Organic_annual_cropland_estimate_sum_of_high_growth_by_region.csv'
                ),
            },
            'Region: OECD90': {
                'Raw Data for ALL LAND TYPES': {
                    'Willer 2018 SEI calc RA lin':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_lin.csv'),
                    'Willer 2018 SEI calc RA exp':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_exp.csv'),
                    'Willer 2018 SEI calc RA 3rd poly':
                    THISDIR.joinpath(
                        'ad', 'ad_Willer_2018_SEI_calc_RA_3rd_poly.csv'),
                },
            },
            'Region: Eastern Europe': {
                'Raw Data for ALL LAND TYPES': {
                    'Willer 2018 SEI calc RA lin':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_lin.csv'),
                    'Willer 2018 SEI calc RA 3rd poly':
                    THISDIR.joinpath(
                        'ad', 'ad_Willer_2018_SEI_calc_RA_3rd_poly.csv'),
                    'Willer 2018 SEI calc RA exp':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_exp.csv'),
                },
            },
            'Region: Asia (Sans Japan)': {
                'Raw Data for ALL LAND TYPES': {
                    'Willer 2018 SEI calc RA lin':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_lin.csv'),
                    'Willer 2018 SEI calc RA exp':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_exp.csv'),
                    'Willer 2018 SEI calc RA 3rd poly':
                    THISDIR.joinpath(
                        'ad', 'ad_Willer_2018_SEI_calc_RA_3rd_poly.csv'),
                },
            },
            'Region: Middle East and Africa': {
                'Raw Data for ALL LAND TYPES': {
                    'Willer 2018 SEI calc RA lin':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_lin.csv'),
                    'Willer 2018 SEI calc RA 3rd poly':
                    THISDIR.joinpath(
                        'ad', 'ad_Willer_2018_SEI_calc_RA_3rd_poly.csv'),
                    'Willer 2018 SEI calc RA exp':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_exp.csv'),
                },
            },
            'Region: Latin America': {
                'Raw Data for ALL LAND TYPES': {
                    'Willer 2018 SEI calc RA lin':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_lin.csv'),
                    'Willer 2018 SEI calc RA exp':
                    THISDIR.joinpath('ad',
                                     'ad_Willer_2018_SEI_calc_RA_exp.csv'),
                    'Willer 2018 SEI calc RA 3rd poly':
                    THISDIR.joinpath(
                        'ad', 'ad_Willer_2018_SEI_calc_RA_3rd_poly.csv'),
                },
            },
            'Region: USA': {
                'Tropical-Humid Land': {
                    'USDA NASS Organic Surv; Cropland area 2016, 2008 summaries':
                    THISDIR.joinpath(
                        'ad',
                        'ad_USDA_NASS_Organic_Surv_Cropland_area_2016_2008_summaries.csv'
                    ),
                },
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            main_includes_regional=True,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_columns = ['Year'] + dd.REGIONS
        tla_2050 = self.tla_per_region.loc[2050]
        world_2014 = self.tla_per_region.loc[2014, 'World']
        ad_2018 = list(self.ac.ref_base_adoption.values())

        # % smallholder area, based on updates to smallholder area VMA sheet
        # (34.1% was estimated in Book Ed1)
        smallholder_pct = 0.315909724971454

        # Maximum technical potential adoption area available for conservation agriculture,
        # based on % large farmers  (Note: not a typo, we're accounting for leftover
        # Conservation Agriculture land here)
        max_adoption = smallholder_pct * world_2014

        def _get_datapoints(percent, extra=0.0):
            w = self.tla_per_region.loc[2014, 'World']
            dp = [
                0.0,  # World is the sum of the regions.
                ((percent['OECD90'] + extra) *
                 self.tla_per_region.loc[2050, 'OECD90']),
                ((percent['Eastern Europe'] + extra) *
                 self.tla_per_region.loc[2050, 'Eastern Europe']),
                ((percent['Asia (Sans Japan)'] + extra) *
                 self.tla_per_region.loc[2050, 'Asia (Sans Japan)']),
                ((percent['Middle East and Africa'] + extra) *
                 self.tla_per_region.loc[2050, 'Middle East and Africa']),
                ((percent['Latin America'] + extra) *
                 self.tla_per_region.loc[2050, 'Latin America']),
                0.0,
                0.0,
                0.0,
                0.0
            ]  # China, India, USA, EU
            dp[0] = sum(dp)
            return dp

        # Data Source 1
        lin = 'Willer 2018 SEI calc RA lin'
        ds1_percent = {
            'OECD90':
            self.ad.adoption_data(region='OECD90').loc[2050, lin] / world_2014,
            'Eastern Europe':
            self.ad.adoption_data(region='Eastern Europe').loc[2050, lin] /
            world_2014,
            'Asia (Sans Japan)':
            self.ad.adoption_data(region='Asia (Sans Japan)').loc[2050, lin] /
            world_2014,
            'Middle East and Africa':
            self.ad.adoption_data(region='Middle East and Africa').loc[2050,
                                                                       lin] /
            world_2014,
            'Latin America':
            self.ad.adoption_data(region='Latin America').loc[2050, lin] /
            world_2014,
            'China':
            0.0,
            'India':
            0.0,
            'EU':
            0.0,
            'USA':
            0.0
        }
        ds1_regen = 0.2  # RA adoption in addition to organic agriculture adoption
        ds1_2050 = _get_datapoints(percent=ds1_percent, extra=ds1_regen)
        ds1_2030 = [x * 0.6 for x in ds1_2050]

        # Data Source 2
        ply = 'Willer 2018 SEI calc RA 3rd poly'
        exp = 'Willer 2018 SEI calc RA exp'
        ds2_percent = {
            'OECD90':
            self.ad.adoption_data(region='OECD90').loc[2050, ply] / world_2014,
            'Eastern Europe':
            self.ad.adoption_data(region='Eastern Europe').loc[2050, exp] /
            world_2014,
            'Asia (Sans Japan)':
            self.ad.adoption_data(region='Asia (Sans Japan)').loc[2050, ply] /
            world_2014,
            'Middle East and Africa':
            self.ad.adoption_data(region='Middle East and Africa').loc[2050,
                                                                       exp] /
            world_2014,
            'Latin America':
            self.ad.adoption_data(region='Latin America').loc[2050, ply] /
            world_2014,
            'China':
            0.0,
            'India':
            0.0,
            'EU':
            0.0,
            'USA':
            0.0
        }
        ds2_regen = 0.2  # RA adoption in addition to organic agriculture adoption
        ds2_2050 = _get_datapoints(percent=ds2_percent, extra=ds2_regen)
        ds2_2030 = [x * 0.6 for x in ds2_2050]

        # Data Source 3
        ds3_percent = {
            'OECD90': 0.6,
            'Eastern Europe': 0.6,
            'Asia (Sans Japan)': 0.6,
            'Middle East and Africa': 0.6,
            'Latin America': 0.6,
            'China': 0.0,
            'India': 0.0,
            'EU': 0.0,
            'USA': 0.0
        }
        ds3_2050 = _get_datapoints(percent=ds3_percent)
        ds3_2030 = [x * 0.8 for x in ds3_2050]

        # Data Source 4
        ds4_regen = 0.3  # RA adoption in addition to organic agriculture adoption
        ds4_2050 = _get_datapoints(percent=ds2_percent, extra=ds4_regen)
        ds4_2030 = [x * 0.8 for x in ds4_2050]

        # Data Source 5, SOURCE: Project Drawdown 2016, constrained TLA for RA
        ds5_regen = 0.3  # RA adoption in addition to organic agriculture adoption
        ds5_2050 = _get_datapoints(percent=ds1_percent, extra=ds5_regen)
        ds5_2030 = [x * 0.8 for x in ds5_2050]

        # Data Source 6
        ds6_2050 = ds3_2050
        ds6_2040 = [x * 0.75 for x in ds6_2050]

        # Data Source 7
        ds7_2050 = ds3_2050
        ds7_2040 = [x * 0.8 for x in ds7_2050]

        # Data Source 8
        ds8_percent = {}
        for region in ds1_percent.keys():
            ds8_percent[region] = (ds1_percent[region] +
                                   ds2_percent[region]) / 2.0
        ds8_2050 = _get_datapoints(percent=ds8_percent)

        # Shrinkage in land area used for the Conservation Agriculture solution are added to
        # the land area available for Regenerative Agriculture.
        cons_ag_dataframes = {}
        for idx in range(1, 9):
            if 'BookVersion1' in self.ac.name:
                fname = f'ds{idx}_incr_change_in_cons_ag_book.csv'
            else:
                fname = f'ds{idx}_incr_change_in_cons_ag_current.csv'
            cons_ag_file = THISDIR.joinpath('ca_pds_data', fname)
            key = f'ds{idx}_cons_ag'
            if cons_ag_file.is_file():
                cons_ag_adopt = pd.read_csv(str(cons_ag_file),
                                            header=0,
                                            index_col=0,
                                            comment='#',
                                            skipinitialspace=True,
                                            skip_blank_lines=True,
                                            dtype=np.float64)
                cons_ag_adopt['China'] = 0.0
                cons_ag_adopt['India'] = 0.0
                cons_ag_adopt['EU'] = 0.0
                cons_ag_adopt['USA'] = 0.0
                # growth in Conservation Agriculture is not a factor, only reduction in area
                cons_ag_adopt[cons_ag_adopt >= 0.0] = 0.0
                cons_ag_dataframes[key] = cons_ag_adopt.abs()
            else:
                cons_ag_dataframes[key] = None

        ca_pds_data_sources = [
            {
                'name':
                'Low, Linear Trend',
                'include':
                False,
                'description':
                ('This scenario projected the future growth of regenerative agriculture based '
                 'on the low historical growth rate of the organic agriculture in different '
                 'regions (Willer et al 2016). In addition, it was assumed that the adoption '
                 'of RA will be higher (20%) than that of the organic agriculture and 60% of '
                 'the estimated adoption by 2050 will be achieved by 2030. Along with this, '
                 'this scenario also includes the leftover area from conservation '
                 'agriculture, as discussed above. Current adoption values for the year '
                 '2012-2017 are taken from the sheet "org adoption by country". This change '
                 'was made in response to the new year set for the currrent adoption, i.e., '
                 '2018. '),
                'dataframe':
                cons_ag_dataframes['ds1_cons_ag'],
                'datapoints':
                pd.DataFrame([
                    [2018] + ad_2018,
                    [2030] + ds1_2030,
                    [2050] + ds1_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'High, Linear Trend',
                'include':
                False,
                'description':
                ('This scenario projected the future growth of regenerative agriculture based '
                 'on the high historical growth rate of the organic agriculture in different '
                 'regions (Willer et al 2018, after calculation for arable land). In '
                 'addition, it was assumed that the adoption of RA will be higher (20%) than '
                 'that of the organic agriculture and 60% of the estimated adoption by 2050 '
                 'will be achieved by 2030. Along with this, this scenario also includes the '
                 'leftover area from conservation agriculture, as discussed above. Current '
                 'adoption values for the year 2012-2017 are taken from the sheet "org '
                 'adoption by country". This change was made in response to the new year set '
                 'for the currrent adoption, i.e., 2018. '),
                'dataframe':
                cons_ag_dataframes['ds2_cons_ag'],
                'datapoints':
                pd.DataFrame([
                    [2018] + ad_2018,
                    [2030] + ds2_2030,
                    [2050] + ds2_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Max, Linear Trend',
                'include':
                False,
                'description':
                ('This scenario projected a 60% adoption of the solution by 2050 and assumed '
                 '80% of the that will be achieved by 2030. Along with this, this scenario '
                 'also includes the leftover area from conservation agriculture, as discussed '
                 'above. Current adoption values for the year 2012-2017 are taken from the '
                 'sheet "org adoption by country". This change was made in response to the '
                 'new year set for the currrent adoption, i.e., 2018. '),
                'dataframe':
                cons_ag_dataframes['ds3_cons_ag'],
                'datapoints':
                pd.DataFrame([
                    [2018] + ad_2018,
                    [2030] + ds3_2030,
                    [2050] + ds3_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Aggressive-high, early growth, linear trend',
                'include':
                False,
                'description':
                ('This scenario projected the future growth of regenerative agriculture based '
                 'on the high historical growth rate of the organic agriculture in different '
                 'regions (Willer et al 2018, after calculaion for arable land). In addition, '
                 'it was assumed that the adoption of RA will be higher (30%) than that of '
                 'the organic agriculture and 80% of the estimated adoption by 2050 will be '
                 'achieved by 2030. Along with this, this scenario also includes the leftover '
                 'area from conservation agriculture, as discussed above. Current adoption '
                 'values for the year 2012-2017 are taken from the sheet "org adoption by '
                 'country". This change was made in response to the new year set for the '
                 'currrent adoption, i.e., 2018. '),
                'dataframe':
                cons_ag_dataframes['ds4_cons_ag'],
                'datapoints':
                pd.DataFrame([
                    [2018] + ad_2018,
                    [2030] + ds4_2030,
                    [2050] + ds4_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Aggressive-low, early growth, linear trend',
                'include':
                False,
                'description':
                ('This scenario projected the future growth of regenerative agriculture based '
                 'on the low historical growth rate of the organic agriculture in different '
                 'regions (Willer et al 2016). In addition, it was assumed that the adoption '
                 'of RA will be higher (30%) than that of the organic agriculture and 80% of '
                 'the estimated adoption by 2050 will be achieved by 2030. Along with this, '
                 'this scenario also includes the leftover area from conservation '
                 'agriculture, as discussed above. Current adoption values for the year '
                 '2012-2017 are taken from the sheet "org adoption by country". This change '
                 'was made in response to the new year set for the currrent adoption, i.e., '
                 '2018. '),
                'dataframe':
                cons_ag_dataframes['ds5_cons_ag'],
                'datapoints':
                pd.DataFrame([
                    [2018] + ad_2018,
                    [2030] + ds5_2030,
                    [2050] + ds5_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Conservative, low growth 1, only RA',
                'include':
                False,
                'description':
                ('Assuming a lower current adoption of the solution, this scenario has taken '
                 'a conservative approach and projected a 60% adoption of the solution by '
                 '2050 and assumed 75% of the that will be achieved by 2040. This scenario is '
                 'built independent of conservation agriculture, so no leftover area of '
                 'conservation agriculture was added to this solution. Current adoption '
                 'values for the year 2012-2017 are taken from the sheet "org adoption by '
                 'country". This change was made in response to the new year set for the '
                 'currrent adoption, i.e., 2018. '),
                'dataframe':
                cons_ag_dataframes['ds6_cons_ag'],
                'datapoints':
                pd.DataFrame([
                    [2018] + ad_2018,
                    [2040] + ds6_2040,
                    [2050] + ds6_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Conservative, low growth 2, only RA',
                'include':
                False,
                'description':
                ('Assuming a lower current adoption of the solution, this scenario has taken '
                 'a conservative approach and projected a 60% adoption of the solution by '
                 '2050 and assumed 80% of the that will be achieved by 2040. This scenario is '
                 'built independent of conservation agriculture, so no leftover area of '
                 'conservation agriculture was added to this solution. Current adoption '
                 'values for the year 2012-2017 are taken from the sheet "org adoption by '
                 'country". This change was made in response to the new year set for the '
                 'currrent adoption, i.e., 2018. '),
                'dataframe':
                cons_ag_dataframes['ds7_cons_ag'],
                'datapoints':
                pd.DataFrame([
                    [2018] + ad_2018,
                    [2040] + ds7_2040,
                    [2050] + ds7_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Baseline scenario',
                'include':
                True,
                'description': ('Baseline adoption '),
                'dataframe':
                cons_ag_dataframes['ds8_cons_ag'],
                'datapoints':
                pd.DataFrame([
                    [2018] + ad_2018,
                    [2050] + ds8_2050,
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        # Current adoption values for the year 2012-2017 are taken from the sheet
        # "org adoption by country" in the Excel file for this solution.
        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2014] = [
                10.0425, 6.230983199564, 1.024820758485, 1.495740017536,
                0.280348210165, 0.342272547086, 0.0, 0.0, 0.0, 0.0
            ]
            df.loc[2015] = [
                10.4821, 6.392187207238, 1.186149025025, 1.609802907785,
                0.313522708425, 0.349200927281, 0.0, 0.0, 0.0, 0.0
            ]
            df.loc[2016] = [
                10.9217, 6.560831715351, 1.372873741988, 1.732564062959,
                0.350622850918, 0.356484379405, 0.0, 0.0, 0.0, 0.0
            ]
            df.loc[2017] = [
                11.3613, 6.743428946088, 1.588992842952, 1.864686799696,
                0.392113171655, 0.364411206077, 0.0, 0.0, 0.0, 0.0
            ]
            df.loc[2018] = [
                11.8009, 6.946491121632, 1.839133620034, 2.006885018162,
                0.438513174434, 0.373269709916, 0.0, 0.0, 0.0, 0.0
            ]

        # Custom REF Data
        ca_ref_data_sources = [
            {
                'name':
                '[Type Scenario 1 Name Here (REF CASE)...]',
                'include':
                True,
                'description':
                ('[PLEASE DESCRIBE IN DETAIL  THE METHODOLOGY YOU USED IN THIS ANALYSIS. BE '
                 'SURE TO INCLUDE ANY ADDITIONAL EQUATIONS YOU UTILIZED] '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Type_Scenario_1_Name_Here_REF_CASE_.csv')
            },
        ]
        self.ref_ca = customadoption.CustomAdoption(
            data_sources=ca_ref_data_sources,
            soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        if self.ac.soln_ref_adoption_basis == 'Custom':
            ref_adoption_data_per_region = self.ref_ca.adoption_data_per_region(
            )
        else:
            ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region(
            )
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region(
            )
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(list(
            self.ac.ref_base_adoption.values()),
                                            index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (
            ht_ref_adoption_initial / self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_pds_adoption_final_percentage = pd.Series(
            list(self.ac.pds_adoption_final_percentage.values()),
            index=list(self.ac.pds_adoption_final_percentage.keys()))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2018] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=self.tla_per_region,
            pds_adoption_limits=self.tla_per_region,
            ref_adoption_data_per_region=ref_adoption_data_per_region,
            use_first_pds_datapoint_main=False,
            adoption_base_year=2018,
            copy_pds_to_ref=False,
            copy_ref_datapoint=False,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=self.tla_per_region,
            pds_total_adoption_units=self.tla_per_region,
            electricity_unit_factor=1000000.0,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_first_cost_uses_tot_units=True,
            fc_convert_iunit_factor=land.MHA_TO_HA)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=land.MHA_TO_HA)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
コード例 #29
0
ファイル: __init__.py プロジェクト: benibienz/drawdown
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TAM
        tamconfig_list = [
            [
                'param', 'World', 'PDS World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'source_until_2014', self.ac.source_until_2014,
                self.ac.source_until_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'source_after_2014', self.ac.ref_source_post_2014,
                self.ac.pds_source_post_2014, 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES',
                'ALL SOURCES', 'ALL SOURCES', 'ALL SOURCES'
            ],
            [
                'trend', '2nd Poly', '2nd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly'
            ],
            [
                'growth', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium'
            ],
            [
                'low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ],
            [
                'high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
                1.0, 1.0
            ]
        ]
        tamconfig = pd.DataFrame(tamconfig_list[1:],
                                 columns=tamconfig_list[0],
                                 dtype=np.object).set_index('param')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'Calculations, see sheet "IEA 2006 TAM" for details':
                THISDIR.joinpath(
                    'tam',
                    'tam_Calculations_see_sheet_IEA_2006_TAM_for_details.csv'),
                'Calculations on the basis of floor space (m2, Urge-Vorsats et al. 2013 data), average illuminance (lm/m2) and annual operating time (constant 1000 h/a)':
                THISDIR.joinpath(
                    'tam',
                    'tam_Calculations_on_the_basis_of_floor_space_m2_UrgeVorsats_et_al__2013_data_average_illumin_66d3beb0.csv'
                ),
                'ETP2016 6 DS; average efficacy flat at 2014 level; interpolated, 2nd poly; see ETP2016 TAM sheet':
                THISDIR.joinpath(
                    'tam',
                    'tam_ETP2016_6_DS_average_efficacy_flat_at_2014_level_interpolated_2nd_poly_see_ETP2016_TAM_sheet.csv'
                ),
            },
            'Region: China': {
                'Baseline Cases': {
                    'Calculations, see sheet "IEA 2006 TAM" for details':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculations_see_sheet_IEA_2006_TAM_for_details.csv'
                    ),
                    'Calculations on the basis of floor space (m2, Hong et al. 2014 data), average illuminance (lm/m2) and annual operating time (constant 1000 h/a)':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculations_on_the_basis_of_floor_space_m2_Hong_et_al__2014_data_average_illuminance_lm_d069a17b.csv'
                    ),
                    'ETP2016 6 DS; average efficacy flat at 2014 level; interpolated, 2nd poly; see ETP2016 TAM sheet':
                    THISDIR.joinpath(
                        'tam',
                        'tam_ETP2016_6_DS_average_efficacy_flat_at_2014_level_interpolated_2nd_poly_see_ETP2016_TAM_sheet.csv'
                    ),
                },
            },
            'Region: EU': {
                'Baseline Cases': {
                    'VITO 2015 Task 7, corrected':
                    THISDIR.joinpath('tam',
                                     'tam_VITO_2015_Task_7_corrected.csv'),
                    'Calculations, see sheet "IEA 2006 TAM" for details':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculations_see_sheet_IEA_2006_TAM_for_details.csv'
                    ),
                    'ETP2016 6 DS; average efficacy flat at 2014 level; interpolated, 2nd poly; see ETP2016 TAM sheet':
                    THISDIR.joinpath(
                        'tam',
                        'tam_ETP2016_6_DS_average_efficacy_flat_at_2014_level_interpolated_2nd_poly_see_ETP2016_TAM_sheet.csv'
                    ),
                },
            },
            'Region: USA': {
                'Baseline Cases': {
                    'Navigant Consulting 2010 http://apps1.eere.energy.gov/buildings/publications/pdfs/ssl/ssl_energy-savings-report_10-30.pdf, growth rate 1.31% in http://apps1.eere.energy.gov/buildings/publications/pdfs/ssl/energysavingsforecast14.pdf':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Navigant_Consulting_2010_httpapps1_eere_energy_govbuildingspublicationspdfssslssl_energy_95d1ca30.csv'
                    ),
                    'US DOE 2014 Energy saving forecast (total Tlmh lighting in Figure 3.2) & US DOE 2012 (2010 US Lighting Market) for 8% residential lighting, assumed to be constant':
                    THISDIR.joinpath(
                        'tam',
                        'tam_US_DOE_2014_Energy_saving_forecast_total_Tlmh_lighting_in_Figure_3_2_US_DOE_2012_2010_US_0abbe87d.csv'
                    ),
                    'ETP2016 6 DS; average efficacy flat at 2014 level; interpolated, 2nd poly; see ETP2016 TAM sheet':
                    THISDIR.joinpath(
                        'tam',
                        'tam_ETP2016_6_DS_average_efficacy_flat_at_2014_level_interpolated_2nd_poly_see_ETP2016_TAM_sheet.csv'
                    ),
                },
                'Conservative Cases': {
                    'Calculations, see sheet "IEA 2006 TAM" for details':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Calculations_see_sheet_IEA_2006_TAM_for_details.csv'
                    ),
                },
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=tam_ref_data_sources)
        ref_tam_per_region = self.tm.ref_tam_per_region()
        pds_tam_per_region = self.tm.pds_tam_per_region()

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly',
                '3rd Poly', '3rd Poly', '3rd Poly', '3rd Poly'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()
        elif self.ac.soln_pds_adoption_basis == 'Linear':
            pds_adoption_data_per_region = None
            pds_adoption_trend_per_region = None
            pds_adoption_is_single_source = None

        ht_ref_adoption_initial = pd.Series([
            0.6794492428871898, 0.3191954710617667, 0.10696600912194591,
            0.14940816617982913, 0.05052731382746539, 0.028682249324419262,
            0.27338382605688477, 0.06226876414656746, 0.08601359398921465,
            0.12076301805261236
        ],
                                            index=dd.REGIONS)
        ht_ref_adoption_final = ref_tam_per_region.loc[2050] * (
            ht_ref_adoption_initial / ref_tam_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * pds_tam_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=ref_tam_per_region,
            pds_adoption_limits=pds_tam_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(
            ac=self.ac,
            ref_total_adoption_units=ref_tam_per_region,
            pds_total_adoption_units=pds_tam_per_region,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

        self.fc = firstcost.FirstCost(
            ac=self.ac,
            pds_learning_increase_mult=2,
            ref_learning_increase_mult=2,
            conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            fc_convert_iunit_factor=1000000000000.0)

        self.oc = operatingcost.OperatingCost(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.
            soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.
            soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.
            conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.
            soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.
            conv_ref_install_cost_per_iunit(),
            conversion_factor=1000000000000.0)

        self.c4 = ch4calcs.CH4Calcs(
            ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            soln_pds_direct_co2_emissions_saved(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            soln_pds_direct_ch4_co2_emissions_saved(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            soln_pds_direct_n2o_co2_emissions_saved(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            fuel_in_liters=False)

        self.r2s = rrs.RRS(total_energy_demand=ref_tam_per_region.loc[2014,
                                                                      'World'],
                           soln_avg_annual_use=self.ac.soln_avg_annual_use,
                           conv_avg_annual_use=self.ac.conv_avg_annual_use)
コード例 #30
0
ファイル: __init__.py プロジェクト: gitter-badger/solutions-1
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TLA
        self.ae = aez.AEZ(solution_name=self.name, cohort=2020,
                regimes=dd.THERMAL_MOISTURE_REGIMES8)
        if self.ac.use_custom_tla and self.ac.custom_tla_fixed_value is not None:
            self.c_tla = tla.CustomTLA(fixed_value=self.ac.custom_tla_fixed_value)
            custom_world_vals = self.c_tla.get_world_values()
        elif self.ac.use_custom_tla:
            self.c_tla = tla.CustomTLA(filename=THISDIR.joinpath('custom_tla_data.csv'))
            custom_world_vals = self.c_tla.get_world_values()
        else:
            custom_world_vals = None
        self.tla_per_region = tla.tla_per_region(self.ae.get_land_distribution(),
            custom_world_values=custom_world_vals)

        adconfig_list = [
            ['param', 'World', 'OECD90', 'Eastern Europe', 'Asia (Sans Japan)',
             'Middle East and Africa', 'Latin America', 'China', 'India', 'EU', 'USA'],
            ['trend', self.ac.soln_pds_adoption_prognostication_trend, 'Medium',
             'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
             'Medium', 'Medium', 'Medium'],
            ['growth', self.ac.soln_pds_adoption_prognostication_growth, 'NOTE',
             'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE',
             'NOTE', 'NOTE', 'NOTE'],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
        adconfig = pd.DataFrame(adconfig_list[1:], columns=adconfig_list[0],
            dtype=np.object).set_index('param')
        ad_data_sources = {
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
            main_includes_regional=True,
            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_columns = ['Year'] + dd.REGIONS
        tla_world_2050 = self.tla_per_region.loc[2050, 'World']
        ad_2018 = self.ac.ref_base_adoption['World']
        growth_initial = pd.DataFrame([[2018] + list(self.ac.ref_base_adoption.values())],
                columns=ca_pds_columns).set_index('Year')

        degrade_rate_high = pd.Series(0.00506640879193976, index=range(2014, 2061))

        degrade_rate_low = pd.Series(0, index=range(2014, 2061))
        degrade_rate_low.loc[2014:2019] = 0.00506640879193976
        degrade_rate_low.loc[2020:2029] = 0.00253320439596988
        degrade_rate_low.loc[2030:] = 0.0

        degrade_rate_alt = pd.Series(0, index=range(2014, 2061))
        degrade_rate_alt.loc[2014] = 0.00506640879193976
        degrade_rate_alt.loc[2015] = 0.00464420805927811
        degrade_rate_alt.loc[2016] = 0.00422200732661647
        degrade_rate_alt.loc[2017] = 0.00379980659395482
        degrade_rate_alt.loc[2018] = 0.00337760586129317
        degrade_rate_alt.loc[2019] = 0.00295540512863153
        degrade_rate_alt.loc[2020] = 0.00253320439596988
        degrade_rate_alt.loc[2021] = 0.00227988395637289
        degrade_rate_alt.loc[2022] = 0.00202656351677590
        degrade_rate_alt.loc[2023] = 0.00177324307717892
        degrade_rate_alt.loc[2024] = 0.00151992263758193
        degrade_rate_alt.loc[2025] = 0.00126660219798494
        degrade_rate_alt.loc[2026] = 0.00101328175838795
        degrade_rate_alt.loc[2027] = 0.00075996131879096
        degrade_rate_alt.loc[2028] = 0.00050664087919398
        degrade_rate_alt.loc[2029] = 0.00025332043959699
        degrade_rate_alt.loc[2030:] = 0.0

        # In Excel, the Custom PDS Scenarios tab columns AC:AF compute a limit on adoption
        # based on the amount of degraded land remaining. We compute the same limit here.
        # This version takes the adoption into account.
        def constrained_tla_adoption(rate, datapoints):
            degrade_df = pd.DataFrame(0, index=range(2014, 2061), columns=[
                'Total undegraded land at the start of the year',
                'Degraded land at the end of the year',
                'Total undegraded land at the end of the year', 'Constrained TLA'])
            for year in range(2014, 2061):
                if year == 2014:
                    # Not a typo, Excel uses the 2018 base adoption number starting in 2014.
                    # We are bug-for-bug compatible here.
                    undeg_start = tla_world_2050 - ad_2018
                else:
                    last = degrade_df.loc[year-1, 'Total undegraded land at the end of the year']
                    new = datapoints.loc[year, 'World'] - datapoints.loc[year-1, 'World']
                    undeg_start = last - new
                degrade_df.loc[year, 'Total undegraded land at the start of the year'] = undeg_start
                degraded_end = max(0, undeg_start * rate[year])
                degrade_df.loc[year, 'Degraded land at the end of the year'] = degraded_end
                degrade_df.loc[year, 'Total undegraded land at the end of the year'] = (
                        undeg_start - degraded_end)
                degrade_df.loc[year, 'Constrained TLA'] = (tla_world_2050 -
                        degrade_df['Degraded land at the end of the year'].sum())
            return degrade_df

        def constrained_tla(rate):
            degrade_df = pd.DataFrame(0, index=range(2014, 2061), columns=[
                'Total undegraded land at the start of the year',
                'Degraded land at the end of the year',
                'Total undegraded land at the end of the year', 'Constrained TLA'])
            for year in range(2014, 2061):
                if year == 2014:
                    # Not a typo, Excel uses the 2018 base adoption number starting in 2014.
                    # We are bug-for-bug compatible here.
                    undeg_start = tla_world_2050 - ad_2018
                else:
                    last = degrade_df.loc[year-1, 'Constrained TLA']
                    undeg_start = last - ad_2018
                degrade_df.loc[year, 'Total undegraded land at the start of the year'] = undeg_start
                degraded_end = max(0, undeg_start * rate[year])
                degrade_df.loc[year, 'Degraded land at the end of the year'] = degraded_end
                degrade_df.loc[year, 'Total undegraded land at the end of the year'] = (
                        undeg_start - degraded_end)
                degrade_df.loc[year, 'Constrained TLA'] = (tla_world_2050 -
                        degrade_df['Degraded land at the end of the year'].sum())
            return degrade_df


        # DATA SOURCE 1
        # https://rsis.ramsar.org/ris-search/peatland?pagetab=2&f%5B0%5D=wetlandTypes_en_ss%3AInland%20wetlands&f%5B1%5D=wetlandTypes_en_ss%3AU%3A%20Permanent%20Non-forested%20peatlands&f%5B2%5D=wetlandTypes_en_ss%3AXp%3A%20Permanent%20Forested%20peatlands&f%5B3%5D=managementPlanAvailable_i%3A-1
        ds1_growth_rate = 0.0622897686767343
        # silvopasture and farmlandrestoration use a growth_rate feature of customadoption
        # to do something like this. However those two solutions calculate a linear growth
        # and then use it to call TREND() to fit a line through it. peatlands uses the raw
        # linear growth data as its Custom Adoption. not quite compatible with what
        # silvopasture and farmlandrestoration do, so we calculate it here.
        ds1_datapoints = pd.DataFrame(0.0, index=range(2012, 2061), columns=dd.REGIONS)
        ds1_datapoints.loc[2012:2018, 'World'] = ad_2018
        for year in range(2019, 2061):
            rate = 1 + ds1_growth_rate
            ds1_datapoints.loc[year, 'World'] = ds1_datapoints.loc[year-1, 'World'] * rate

        # DATA SOURCE 2
        df = constrained_tla_adoption(rate=degrade_rate_high, datapoints=ds1_datapoints)
        ds2_adoption_2050 = df.loc[2050, 'Constrained TLA']
        ds2_adoption_2030 = 0.7 * ds2_adoption_2050

        # DATA SOURCE 4
        df = constrained_tla_adoption(rate=degrade_rate_alt, datapoints=ds1_datapoints)
        ds4_adoption_2050 = df.loc[2050, 'Constrained TLA']
        ds4_adoption_2030 = 0.7 * ds4_adoption_2050

        # DATA SOURCE 5
        df = constrained_tla(rate=degrade_rate_high)
        ds5_constrained_tla = df.loc[2050, 'Constrained TLA']

        # DATA SOURCE 7
        ds7_constrained_tla = constrained_tla(degrade_rate_low).loc[2050, 'Constrained TLA']

        # DATA SOURCE 9
        ds9_growth_rate = 0.0394112383173051
        # silvopasture and farmlandrestoration use a growth_rate feature of customadoption
        # to do something like this. However those two solutions calculate a linear growth
        # and then use it to call TREND() to fit a line through it. peatlands uses the raw
        # linear growth data as its Custom Adoption. So calculate it here.
        ds9_datapoints = pd.DataFrame(0.0, index=range(2012, 2061), columns=dd.REGIONS)
        ds9_datapoints.loc[2012:2018, 'World'] = ad_2018
        for year in range(2019, 2061):
            rate = 1 + ds9_growth_rate
            ds9_datapoints.loc[year, 'World'] = ds9_datapoints.loc[year-1, 'World'] * rate
        df = constrained_tla_adoption(degrade_rate_high, ds9_datapoints)
        ds9_constrained_tla = df.loc[:, 'Constrained TLA'].min()

        # DATA SOURCE 10
        df = constrained_tla_adoption(degrade_rate_low, ds9_datapoints)
        ds10_constrained_tla = df.loc[:, 'Constrained TLA'].min()

        ca_pds_data_sources = [
            {'name': 'High adoption and conservative degradation rate', 'include': True,
                'description': (
                    'The Peatlands Ramsar sites with management plans evolution (1985-2015) was '
                    'used to estimate the yearly increase rate of 6,23% corresponding to 1985- '
                    "2015 coupled with the TLA's current degradation rate of 0.51%. "
                    ),
                'datapoints': ds1_datapoints, 'maximum': 331},
            {'name': 'Scenario 1 + 70% conservative degradation TLA in 2030', 'include': True,
                'description': (
                    'Scenario 1 with linear increase up to 70% of TLA 2050 value in 2030 and '
                    'then linear increase to 100% TLA value in 2050 from then onwards '
                    ),
                'maximum': ds2_adoption_2050,
                'datapoints': pd.DataFrame([
                    [2014, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2030, ds2_adoption_2030, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds2_adoption_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    ], columns=ca_pds_columns).set_index('Year')},
            {'name': 'High adoption and low degradation rate', 'include': True,
                'description': (
                    'The Peatlands Ramsar sites with management plans  evolution (1985-2015) was '
                    'used to estimate the yearly increase rate of 6,23% corresponding to 1985- '
                    '2015 coupled with the he New York declaration on Forests is used  to '
                    'estimate an alternative degradation rate which starts from 0.51% and '
                    'linearly decreases to half its value in 2020 and then to zero in 2030. '
                    ),
                'datapoints': ds1_datapoints, 'maximum': 396},
            {'name': 'Scenario 3 + 70% low degradation TLA in 2030', 'include': True,
                'description': (
                    'Scenario 3 with linear increase up to 70% of TLA 2050 value in 2030 and '
                    'then linear increase to 100% TLA value in 2050 from then onwards '
                    ),
                'maximum': ds4_adoption_2050,
                'datapoints': pd.DataFrame([
                    [2014, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2030, ds4_adoption_2030, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds4_adoption_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    ], columns=ca_pds_columns).set_index('Year')},
            {'name': '100% conservative degradation TLA in 2050', 'include': True,
                'description': (
                    '100% adoption ofconservative degradation rate TLA  by 2050 '
                    ),
                'maximum': ds5_constrained_tla,
                'datapoints': pd.DataFrame([
                    [2014, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds5_constrained_tla, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    ], columns=ca_pds_columns).set_index('Year')},
            {'name': '80% conservative degradation TLA in 2030', 'include': True,
                'description': (
                    'Linear increase up to 80% of TLA 2050 value in 2030 (calculated with the '
                    'conservative degradation rate) and then linear increase to 100% TLA value '
                    'in 2050 from then onwards '
                    ),
                'maximum': ds5_constrained_tla,
                'datapoints': pd.DataFrame([
                    [2014, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2030, 0.8 * ds5_constrained_tla, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds5_constrained_tla, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    ], columns=ca_pds_columns).set_index('Year')},
            {'name': '100% low degradation TLA in 2050', 'include': True,
                'description': (
                    '100% adoption of low degradation rate TLA  by 2050 '
                    ),
                'maximum': ds7_constrained_tla,
                'datapoints': pd.DataFrame([
                    [2014, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds7_constrained_tla, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    ], columns=ca_pds_columns).set_index('Year')},
            {'name': '80% low degradation TLA in 2030', 'include': True,
                'description': (
                    '80% low degradation TLA in 2030 '
                    ),
                'maximum': ds7_constrained_tla,
                'datapoints': pd.DataFrame([
                    [2014, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2030, 0.8 * ds7_constrained_tla, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds7_constrained_tla, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    ], columns=ca_pds_columns).set_index('Year')},
            {'name': 'Medium adoption and conservative degradation rate', 'include': True,
                'description': (
                    'The Peatlands Ramsar sites with management plans evolution (1985-2015) was '
                    'used to estimate the yearly increase rate of 3,94% corresponding to 1990- '
                    "2015 coupled with the TLA's current degradation rate of 0.51%. "
                    ),
                'datapoints': ds9_datapoints, 'maximum': ds9_constrained_tla},
            {'name': 'Medium adoption and low degradation rate', 'include': True,
                'description': (
                    'The Peatlands Ramsar sites with management plans evolution (1985-2015) was '
                    'used to estimate the yearly increase rate of 3,94% corresponding to 1990- '
                    "2015 coupled with the TLA's low degradation rate of 0.51%. "
                    ),
                'datapoints': ds9_datapoints, 'maximum': ds10_constrained_tla},
        ]
        self.pds_ca = customadoption.CustomAdoption(data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0, low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2014:2018, 'World'] = ad_2018

        ref_adoption_data_per_region = None

        if False:
            # One may wonder why this is here. This file was code generated.
            # This 'if False' allows subsequent conditions to all be elif.
            pass
        elif self.ac.soln_pds_adoption_basis == 'Fully Customized PDS':
            pds_adoption_data_per_region = self.pds_ca.adoption_data_per_region()
            pds_adoption_trend_per_region = self.pds_ca.adoption_trend_per_region()
            pds_adoption_is_single_source = None
        elif self.ac.soln_pds_adoption_basis == 'Existing Adoption Prognostications':
            pds_adoption_data_per_region = self.ad.adoption_data_per_region()
            pds_adoption_trend_per_region = self.ad.adoption_trend_per_region()
            pds_adoption_is_single_source = self.ad.adoption_is_single_source()

        ht_ref_adoption_initial = pd.Series(
            list(self.ac.ref_base_adoption.values()), index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (ht_ref_adoption_initial /
            self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_pds_adoption_final_percentage = pd.Series(
            list(self.ac.pds_adoption_final_percentage.values()),
            index=list(self.ac.pds_adoption_final_percentage.keys()))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2018] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(ac=self.ac,
            ref_datapoints=ht_ref_datapoints, pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=self.tla_per_region, pds_adoption_limits=self.tla_per_region,
            use_first_pds_datapoint_main=True,
            adoption_base_year=2018,
            copy_pds_to_ref=True,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

        self.ef = emissionsfactors.ElectricityGenOnGrid(ac=self.ac)

        self.ua = unitadoption.UnitAdoption(ac=self.ac,
            ref_total_adoption_units=self.tla_per_region,
            pds_total_adoption_units=self.tla_per_region,
            electricity_unit_factor=1000000.0,
            soln_ref_funits_adopted=self.ht.soln_ref_funits_adopted(),
            soln_pds_funits_adopted=self.ht.soln_pds_funits_adopted(),
            bug_cfunits_double_count=True)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted=self.ua.soln_net_annual_funits_adopted()

        self.fc = firstcost.FirstCost(ac=self.ac, pds_learning_increase_mult=2,
            ref_learning_increase_mult=2, conv_learning_increase_mult=2,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_tot_iunits=conv_ref_tot_iunits,
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_first_cost_uses_tot_units=True,
            fc_convert_iunit_factor=land.MHA_TO_HA)

        self.oc = operatingcost.OperatingCost(ac=self.ac,
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            soln_pds_tot_iunits_reqd=soln_pds_tot_iunits_reqd,
            soln_ref_tot_iunits_reqd=soln_ref_tot_iunits_reqd,
            conv_ref_annual_tot_iunits=self.ua.conv_ref_annual_tot_iunits(),
            soln_pds_annual_world_first_cost=self.fc.soln_pds_annual_world_first_cost(),
            soln_ref_annual_world_first_cost=self.fc.soln_ref_annual_world_first_cost(),
            conv_ref_annual_world_first_cost=self.fc.conv_ref_annual_world_first_cost(),
            single_iunit_purchase_year=2017,
            soln_pds_install_cost_per_iunit=self.fc.soln_pds_install_cost_per_iunit(),
            conv_ref_install_cost_per_iunit=self.fc.conv_ref_install_cost_per_iunit(),
            conversion_factor=land.MHA_TO_HA)

        self.c4 = ch4calcs.CH4Calcs(ac=self.ac,
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.direct_ch4_co2_emissions_saved_land(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted)

        self.c2 = co2calcs.CO2Calcs(ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            tot_red_in_deg_land=self.ua.cumulative_reduction_in_total_degraded_land(),
            pds_protected_deg_land=self.ua.pds_cumulative_degraded_land_protected(),
            ref_protected_deg_land=self.ua.ref_cumulative_degraded_land_protected(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)