Пример #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')
        tam_ref_data_sources = {
            'Baseline Cases': {
                'Based on IEA (2016), "Energy Technology Perspectives - 6DS", IEA/OECD':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_IEA_2016_Energy_Technology_Perspectives_6DS_IEAOECD.csv'
                ),
                'Based on ICCT (2012) "Global Transport Roadmap Model", http://www.theicct.org/global-transportation-roadmap-model':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_ICCT_2012_Global_Transport_Roadmap_Model_httpwww_theicct_orgglobaltransportatio_8916596a.csv'
                ),
            },
            'Conservative Cases': {
                'Based on IEA (2016), "Energy Technology Perspectives - 4DS", IEA/OECD':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_IEA_2016_Energy_Technology_Perspectives_4DS_IEAOECD.csv'
                ),
            },
            'Ambitious Cases': {
                'Based on IEA (2016), "Energy Technology Perspectives - 2DS", IEA/OECD':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_IEA_2016_Energy_Technology_Perspectives_2DS_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 = {
            'Baseline Cases': {
                'Based on IEA Reference Tech Scenario- 2017':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_IEA_Reference_Tech_Scenario_2017.csv'),
            },
            'Conservative Cases': {
                'Based on OPEC World Energy Outlook 2016':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_OPEC_World_Energy_Outlook_2016.csv'),
                'Based on The Paris Declaration as Cited in (IEA, 2017- EV Outlook)':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_The_Paris_Declaration_as_Cited_in_IEA_2017_EV_Outlook.csv'
                ),
            },
            'Ambitious Cases': {
                'Based on: IEA ETP 2016 2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
                'Based on Bloomberg New Energy Finance - EV Outlook 2017':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Bloomberg_New_Energy_Finance_EV_Outlook_2017.csv'
                ),
                'Based on IEA Beyond 2DS/B2DS Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_IEA_Beyond_2DSB2DS_Scenario.csv'),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data

        # Data about EV Sales comes from sheets from the original Excel implementation
        wb = xlrd.open_workbook(
            filename=THISDIR.joinpath('electricvehicledata.xlsx'))
        raw_sales = pd.read_excel(io=wb,
                                  sheet_name='EV Sales',
                                  header=0,
                                  index_col=0,
                                  usecols='A:K',
                                  dtype='float',
                                  engine='xlrd',
                                  skiprows=7,
                                  nrows=43)
        ev_sales = raw_sales.rename(
            axis='columns',
            mapper={
                'World ': 'World',
                'OECD90 (US, EU Japan, Canada)': 'OECD90',
                'Asia sans Japan (China, India & Other.)': 'Asia (Sans Japan)',
                'Middle East & Africa': 'Middle East and Africa'
            }).fillna(0.0)
        lifetime = int(np.ceil(self.ac.soln_lifetime_replacement))
        sales_extended = ev_sales.copy()
        for year in range(2051, 2061):
            sales_extended.loc[year, :] = 0.0
        vehicle_retirements = sales_extended.shift(periods=lifetime,
                                                   fill_value=0.0)
        ev_stock = (ev_sales - vehicle_retirements).cumsum()
        pass_km_adoption = ev_stock * self.ac.soln_avg_annual_use

        # Data Source 1
        # EVs.xlsm 'Data Interpolation'!H1181, Adoption Data
        # Based on IEA EV Outlook, 2017 - B2DS Scenario
        predict = pd.Series([
            16.7014449161593, 35.1749574468086, 49.2449404255312,
            635.494231205675, 2239.47229078014, 5072.22886382977
        ],
                            index=[2014, 2015, 2016, 2020, 2025, 2030])
        pass_km_predicted = interpolation.poly_degree3_trend(
            predict)['adoption']
        pass_km_predicted.update(predict)
        integration_pds2 = pd.read_csv(THISDIR.joinpath(
            'tam', 'integration_PDS2.csv'),
                                       skipinitialspace=True,
                                       comment='#',
                                       index_col=0)
        tam_limit_pds2 = integration_pds2['URBAN'] + (
            0.3 * integration_pds2['NONURBAN'])
        world = pd.concat([
            pass_km_adoption.loc[2012:2019, 'World'],
            pass_km_predicted.loc[2020:]
        ])
        ds1_df = pd.DataFrame(0, columns=dd.REGIONS, index=range(2012, 2061))
        ds1_df['World'] = world.clip(upper=tam_limit_pds2, axis=0)

        # Data Source 2
        raw = pd.read_excel(io=wb,
                            sheet_name='Vehicle Survival',
                            header=0,
                            index_col=None,
                            usecols='D:AR',
                            dtype='float',
                            engine='xlrd',
                            skiprows=8,
                            nrows=5).T
        survival_ds2 = pd.concat([ev_stock.loc[:2019, 'World'], raw[3]])
        capture_pct_ds2 = raw[4]
        car_usage = 15765.0  # https://theicct.org/global-transportation-roadmap-model (now 404s)
        car_occupancy = self.ac.lookup_vma(
            vma_title='Current Average Car Occupancy')
        survival_ad_ds2 = survival_ds2 * car_usage * car_occupancy / 1e9
        replace_ds2 = (survival_ds2 * capture_pct_ds2).cumsum().subtract(
            vehicle_retirements['World'], fill_value=0.0)
        pass_km_potential_ds2 = replace_ds2 * self.ac.conv_avg_annual_use
        adoption_ds2 = pd.concat(
            [survival_ad_ds2.loc[:2019], pass_km_potential_ds2.loc[2020:]])
        integration_pds3 = pd.read_csv(THISDIR.joinpath(
            'tam', 'integration_PDS3.csv'),
                                       skipinitialspace=True,
                                       comment='#',
                                       index_col=0)
        tam_limit_pds3 = integration_pds3['URBAN'] + (
            0.3 * integration_pds3['NONURBAN'])
        ds2_df = pd.DataFrame(0, columns=dd.REGIONS, index=range(2012, 2061))
        ds2_df['World'] = adoption_ds2.clip(upper=tam_limit_pds3, axis=0)

        ca_pds_data_sources = [
            {
                'name':
                'PDS2-Based on IEA (2017) B2DS',
                'include':
                True,
                'description':
                ('In this Scenario, we incorporate the highest published stock scenario of '
                 "EV's currently in the literature: the IEA B2DS scenario of 2017. We take the "
                 "Beyond 2 Degree Scenario projections from the IEA of number of EV's in the "
                 'global fleet, convert to estimated passenger-km with a fixed factor and we '
                 'interpolate and extrapolate to estimate missing years with a 3rd degree '
                 'polynomial curve fit. We then limit this to the total projected TAM each '
                 'year after higher priority solutions have supplied their full projection in '
                 'PDS2 (Higher priority solutions are: Walkable Cities, Bike Infrastructure, '
                 'E-Bikes, Mass Transit and Carsharing/Ridesharing) '),
                'dataframe':
                ds1_df
            },
            {
                'name':
                'PDS3-Based on Replacing All Retired Cars from Survival Analysis',
                'include':
                True,
                'description':
                ('In this Optimum Scenario, to estimate the Fastest that a New Car Technology '
                 'can Diffuse into the Global Fleet - assuming that from time of car '
                 'replacement, new technology is used. Weibull distributions are assumed '
                 'using the Weibull Survival data from ICCT Global Roadmap model v1.0 for 6 '
                 'countries (China, USA, Canada, Brazil, Mexico and India). Using these, we '
                 'estimate the proportion of cars in each country that are scrapped or '
                 'retired X years after purchase date (0 <= X <= 40). Combining this with '
                 'vehicle sales data for each of the selected countries (mainly from OICA '
                 'database), we estimate how many cars should be retiring each year. Assuming '
                 'the average retiring rate of these selected countries applies to entire '
                 'world, we scale up the retired cars to global fleet and then convert from '
                 'cars to pass-km. We then limit this to the total projected TAM each year '
                 'after higher priority solutions have supplied their full projection in PDS3 '
                 '(Higher priority solutions are: Walkable Cities, Bike Infrastructure, '
                 'E-Bikes, Mass Transit and Carsharing/Ridesharing) '),
                'dataframe':
                ds2_df
            },
            {
                'name':
                'Book Ed.1 Scenario 1',
                'include':
                False,
                'description':
                ('Starting with the IEA 2DS Projection of EV in the Global stock, we '
                 'interpolate and apply a fixed car occupancy to 2050. Minor adjustments are '
                 'made to early years to ensure smoothness of the adoption curve. '
                 ),
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Book_Ed_1_Scenario_1.csv')
            },
            {
                'name':
                'Book Ed.1 Scenario 2',
                'include':
                False,
                'description':
                ("Using the IEA's Energy Technology Perspectives 2012 projections of EV "
                 "sales' growth, we project the sales and then global EV stock. Assuming the "
                 "ICCT's global car occupancy average and a 50% growth in this occupancy by "
                 '2050, we estimate the total passenger-km of EV during the period of '
                 'analysis. '),
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Book_Ed_1_Scenario_2.csv')
            },
            {
                'name':
                'Book Ed.1 Scenario 3',
                'include':
                False,
                'description':
                ("Using the IEA's Energy Technology Perspectives 2012 projections of EV "
                 "sales' growth, we project the sales and then global EV stock. Assuming "
                 "twice the ICCT's global car occupancy average, we estimate the total "
                 "passenger-km of EV during the period of analysis. "),
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Book_Ed_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=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)

        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[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,
            use_first_pds_datapoint_main=False,
            copy_pds_to_ref=True,
            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=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)
Пример #2
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': {
          'Custom calculated from (GBPN, Urge-Vorsatz Factored by IEA Building  Data)': THISDIR.joinpath('tam', 'tam_Custom_calculated_from_GBPN_UrgeVorsatz_Factored_by_IEA_Building_Data.csv'),
          'IEA 6DS (2016), Residential & Commercial Water Heating': THISDIR.joinpath('tam', 'tam_IEA_6DS_2016_Residential_Commercial_Water_Heating.csv'),
          'GBPN Energy for water heating, Urban & Rural / All buildings, All Vintages, Frozen efficiency (Water Heating Thermal energy use in TWHth)': THISDIR.joinpath('tam', 'tam_GBPN_Energy_for_water_heating_Urban_Rural_All_buildings_All_Vintages_Frozen_efficiency_W_e86b69eb.csv'),
      },
      'Conservative Cases': {
          'Custom calculated from (GBPN and Urge-Vorsatz)': THISDIR.joinpath('tam', 'tam_Custom_calculated_from_GBPN_and_UrgeVorsatz.csv'),
          'IEA 4DS (2016), Residential & Commercial Water Heating': THISDIR.joinpath('tam', 'tam_IEA_4DS_2016_Residential_Commercial_Water_Heating.csv'),
      },
      'Region: OECD90': {
        'Baseline Cases': {
          'Custom calculated from (GBPN, Urge-Vorsatz Factored by IEA Building  Data)': THISDIR.joinpath('tam', 'tam_Custom_calculated_from_GBPN_UrgeVorsatz_Factored_by_IEA_Building_Data.csv'),
          'Custom calculated from (GBPN and Urge-Vorsatz)': THISDIR.joinpath('tam', 'tam_Custom_calculated_from_GBPN_and_UrgeVorsatz.csv'),
          'GBPN Energy for water heating, Urban & Rural / All buildings, All Vintages, Frozen efficiency (Water Heating Thermal energy use in TWHth)': THISDIR.joinpath('tam', 'tam_GBPN_Energy_for_water_heating_Urban_Rural_All_buildings_All_Vintages_Frozen_efficiency_W_e86b69eb.csv'),
        },
      },
      'Region: Eastern Europe': {
        'Baseline Cases': {
          'Custom calculated from (GBPN, Urge-Vorsatz Factored by IEA Building  Data)': THISDIR.joinpath('tam', 'tam_Custom_calculated_from_GBPN_UrgeVorsatz_Factored_by_IEA_Building_Data.csv'),
          'Custom calculated from (GBPN and Urge-Vorsatz)': THISDIR.joinpath('tam', 'tam_Custom_calculated_from_GBPN_and_UrgeVorsatz.csv'),
          'GBPN Energy for water heating, Urban & Rural / All buildings, All Vintages, Frozen efficiency (Water Heating Thermal energy use in TWHth)': THISDIR.joinpath('tam', 'tam_GBPN_Energy_for_water_heating_Urban_Rural_All_buildings_All_Vintages_Frozen_efficiency_W_e86b69eb.csv'),
        },
      },
      'Region: Asia (Sans Japan)': {
        'Baseline Cases': {
          'Custom calculated from (GBPN, Urge-Vorsatz Factored by IEA Building  Data)': THISDIR.joinpath('tam', 'tam_Custom_calculated_from_GBPN_UrgeVorsatz_Factored_by_IEA_Building_Data.csv'),
          'Custom calculated from (GBPN and Urge-Vorsatz)': THISDIR.joinpath('tam', 'tam_Custom_calculated_from_GBPN_and_UrgeVorsatz.csv'),
          'GBPN Energy for water heating, Urban & Rural / All buildings, All Vintages, Frozen efficiency (Water Heating Thermal energy use in TWHth)': THISDIR.joinpath('tam', 'tam_GBPN_Energy_for_water_heating_Urban_Rural_All_buildings_All_Vintages_Frozen_efficiency_W_e86b69eb.csv'),
        },
      },
    }
    tam_pds_data_sources = {
      'Baseline Cases': {
          'Drawdown TAM: PDS1 - post-Low-Flow': THISDIR.joinpath('tam', 'tam_pds_Drawdown_TAM_PDS1_postLowFlow.csv'),
      },
      'Conservative Cases': {
          'Drawdown TAM: PDS2 - post-Low-Flow': THISDIR.joinpath('tam', 'tam_pds_Drawdown_TAM_PDS2_postLowFlow.csv'),
      },
      'Ambitious Cases': {
          'Drawdown TAM: PDS3 - post-Low-Flow': THISDIR.joinpath('tam', 'tam_pds_Drawdown_TAM_PDS3_postLowFlow.csv'),
      },
    }
    self.tm = tam.TAM(tamconfig=tamconfig, tam_ref_data_sources=tam_ref_data_sources,
      tam_pds_data_sources=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 = {
      'Conservative Cases': {
          'IEA (2012) Technology Roadmap Solar Heating and Cooling - Cons': THISDIR.joinpath('ad', 'ad_IEA_2012_Technology_Roadmap_Solar_Heating_and_Cooling_Cons.csv'),
      },
      'Ambitious Cases': {
          'Solar Heat Worldwide http://www.iea-shc.org/solar-heat-worldwide': THISDIR.joinpath('ad', 'ad_Solar_Heat_Worldwide_httpwww_ieashc_orgsolarheatworldwide.csv'),
      },
    }
    self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
        adconfig=adconfig)

    # Custom PDS Data
    ca_pds_data_sources = [
      {'name': 'Conservative, based on IEA 2012', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Conservative_based_on_IEA_2012.csv')},
      {'name': 'Aggressive, High Growth, early', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Aggressive_High_Growth_early.csv')},
      {'name': 'Aggressive, High Growth, based on IEA', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Aggressive_High_Growth_based_on_IEA.csv')},
      {'name': 'Aggressive, High Growth, late', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Aggressive_High_Growth_late.csv')},
      {'name': 'Aggressive, V. High Growth, late', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Aggressive_V__High_Growth_late.csv')},
      {'name': 'Aggressive, V. High Growth', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Aggressive_V__High_Growth.csv')},
      {'name': 'Conservative Growth, late', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Conservative_Growth_late.csv')},
      {'name': 'Conservative Growth, early', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Conservative_Growth_early.csv')},
      {'name': 'Low Growth', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Low_Growth.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(
      [335.463, 56.493, 2.374, 240.305, 9.948,
       9.113, 231.838, 6.4350000000000005, 23.777, 17.233],
       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=1000000000.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=1000000000.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)
Пример #3
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 = {
            'Baseline Cases': {
                'Based on: AMPERE 2014 IMAGE TIMER Reference':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.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: IEA ETP 2016 6DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
            },
            'Conservative Cases': {
                'Based on: AMPERE 2014 IMAGE TIMER 550':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_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 GEM E3 550':
                THISDIR.joinpath('ad',
                                 'ad_based_on_AMPERE_2014_GEM_E3_550.csv'),
                'Based on: IEA ETP 2016 4DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
                'Based on: Greenpeace Reference (2015)':
                THISDIR.joinpath('ad',
                                 'ad_based_on_Greenpeace_Reference_2015.csv'),
            },
            'Ambitious Cases': {
                'Based on: AMPERE 2014 IMAGE TIMER 450':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_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 GEM E3 450':
                THISDIR.joinpath('ad',
                                 'ad_based_on_AMPERE_2014_GEM_E3_450.csv'),
                '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'),
            },
            '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([
            75.43696666666665, 50.234754444444434, 0.22261666666666663,
            14.113495555555552, 1.0549222222222219, 9.81238111111111,
            10.027777777777775, 1.8406988888888887, 37.01894555555555,
            8.790349999999998
        ],
                                            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)
Пример #4
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:
            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': {
                'FAO 2010': THISDIR.joinpath('ad', 'ad_FAO_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
        adoption_2014 = self.ac.ref_base_adoption['World']
        tla_2050 = self.tla_per_region.loc[2050, 'World']
        ds4_percent_adoption_2050 = 0.85
        ds4_adoption_2050 = ds4_percent_adoption_2050 * tla_2050
        ca_pds_data_sources = [
            {
                'name':
                'Low growth, linear trend',
                'include':
                True,
                'datapoints_degree':
                1,
                # This scenario projects the future adoption of bamboo based on historical regional
                # growth reported for the 1990-2010 period in the Global Forest Resource Assessment
                # 2010 report, published by the FAO.
                'datapoints':
                pd.DataFrame([
                    [
                        1990, np.nan, 0.0, 0.0, 15.412, 3.688, 10.399, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2000, np.nan, 0.0, 0.0, 16.311, 3.656, 10.399, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2005, np.nan, 0.0, 0.0, 16.943, 3.640, 10.399, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2010, np.nan, 0.0, 0.0, 17.360, 3.627, 10.399, 0.0,
                        0.0, 0.0, 0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Medium growth, linear trend',
                'include':
                True,
                # This scenario projects the future adoption of bamboo based on the highest
                # historical regional annual growth rate, based on 1990-2010 FAO data. The highest
                # annual growth rate was reported in the Asia region (0.0974 Mha/year). Thus, it
                # was assumed that bamboo plantation in other regions will grow by half of the
                # growth rate calculated in Asia (0.05 Mha/year), while bamboo plantation in Asia
                # continues to grow with the same rate.
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Medium_growth_linear_trend.csv')
            },
            {
                'name':
                'High growth, linear trend',
                'include':
                True,
                # This scenario projects the future adoption of bamboo based on the highest
                # historical regional annual growth rate, based on 1990-2010 FAO data. The highest
                # annual growth rate was reported in the Asia region. Thus, it was assumed that
                # bamboo plantation in other regions will grow at the same growth rate calculated
                # in Asia (0.0974 Mha/year), while bamboo plantation in Asia continues to grow at
                # double this rate (0.19 Mha/year).
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_High_growth_linear_trend.csv')
            },
            {
                'name':
                'Max growth, linear trend',
                'include':
                True,
                # Considering the limited total land available for bamboo, this scenario
                # projects an aggressive adoption of bamboo plantation and projects a worldwide
                # 85% adoption of bamboo plantation by 2050.
                'datapoints':
                pd.DataFrame([
                    [
                        2014, adoption_2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0
                    ],
                    [
                        2050, ds4_adoption_2050, 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')
            },
            {
                'name':
                'Song et al. 2013',
                'include':
                True,
                # "Annual increase in global bamboo forests based on a global historical annual
                # expansion of bamboo forests of 3%, as reported in Song et al. 2013 (see p.7
                # of publication).
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Song_et_al__2013.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)

        # Manual adjustment made in spreadsheet for Drawdown 2020.
        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2014] = [
                32.8913636108367000, 0.0, 0.0, 18.0440250214314000,
                3.9611495064729000, 10.8861890829324000, 0.0, 0.0, 0.0, 0.0
            ]
            df.loc[2015] = [
                33.0453659423780000, 0.0, 0.0, 18.1703910504150000,
                3.9772571687142000, 10.8977177232488000, 0.0, 0.0, 0.0, 0.0
            ]
            df.loc[2016] = [
                33.2014226143695000, 0.0, 0.0, 18.2979284861039000,
                3.9938159101118100, 10.9096782181539000, 0.0, 0.0, 0.0, 0.0
            ]
            df.loc[2017] = [
                33.3595689913150000, 0.0, 0.0, 18.4266654288099000,
                4.0108468526825300, 10.9220567098226000, 0.0, 0.0, 0.0, 0.0
            ]
            df.loc[2018] = [
                33.5198404377181000, 0.0, 0.0, 18.5566299788448000,
                4.0283711184431500, 10.9348393404302000, 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,
                '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)
Пример #5
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())
Пример #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', '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'),
      },
      'Ambitious Cases': {
          'IEA (2016), "Energy Technology Perspectives - 2DS", IEA/OECD': THISDIR.joinpath('tam', 'tam_IEA_2016_Energy_Technology_Perspectives_2DS_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 = {
      'Baseline Cases': {
          'Based on IEA Reference Tech Scenario- 2017': THISDIR.joinpath('ad', 'ad_based_on_IEA_Reference_Tech_Scenario_2017.csv'),
      },
      'Conservative Cases': {
          'Based on OPEC World Energy Outlook 2016': THISDIR.joinpath('ad', 'ad_based_on_OPEC_World_Energy_Outlook_2016.csv'),
          'Based on The Paris Declaration as Cited in (IEA, 2017- EV Outlook)': THISDIR.joinpath('ad', 'ad_based_on_The_Paris_Declaration_as_Cited_in_IEA_2017_EV_Outlook.csv'),
      },
      'Ambitious Cases': {
          'Based on: IEA ETP 2016 2DS': THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
          'Based on Bloomberg New Energy Finance - EV Outlook 2017': THISDIR.joinpath('ad', 'ad_based_on_Bloomberg_New_Energy_Finance_EV_Outlook_2017.csv'),
          'Based on IEA Beyond 2DS/B2DS Scenario': THISDIR.joinpath('ad', 'ad_based_on_IEA_Beyond_2DSB2DS_Scenario.csv'),
      },
      'Maximum Cases': {
          'Double EV occupancy on PDS2 = double pass-km': THISDIR.joinpath('ad', 'ad_Double_EV_occupancy_on_PDS2_double_passkm.csv'),
          'Drawdown Projections based on adjusted IEA data (ETP 2012) on projected growth in each year, and recent sales Data (IEA - ETP 2016)': THISDIR.joinpath('ad', 'ad_Drawdown_Projections_based_on_adjusted_IEA_data_ETP_2012_on_projected_growth_in_each_yea_72fb5617.csv'),
      },
    }
    self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
        adconfig=adconfig)

    # Custom PDS Data
    ca_pds_data_sources = [
      {'name': 'PDS2-Based on IEA (2017) B2DS+50% Occupancy Increase', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_PDS2based_on_IEA_2017_B2DS50_Occupancy_Increase.csv')},
      {'name': 'PDS3-Based on IEA B2DS with 100% Increase in Car Occupancy', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_PDS3based_on_IEA_B2DS_with_100_Increase_in_Car_Occupancy.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')},
      {'name': 'Book Ed.1 Scenario 3', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Book_Ed_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(
      [16.701444916159307, 14.405959906291683, 8.68248837596512e-05, 2.7858260096477, 8.68248837596512e-05,
       8.68248837596512e-05, 2.6861138324271523, 0.09962535233678836, 4.508096807458965, 6.7600117997589235],
       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)
Пример #7
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 (2016), "Energy Technology Perspectives - 6DS", IEA/OECD':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_IEA_2016_Energy_Technology_Perspectives_6DS_IEAOECD.csv'
                ),
                'Based on ICCT (2012) "Global Transport Roadmap Model", http://www.theicct.org/global-transportation-roadmap-model':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_ICCT_2012_Global_Transport_Roadmap_Model_httpwww_theicct_orgglobaltransportatio_8916596a.csv'
                ),
            },
            'Conservative Cases': {
                'Based on IEA (2016), "Energy Technology Perspectives - 4DS", IEA/OECD':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_IEA_2016_Energy_Technology_Perspectives_4DS_IEAOECD.csv'
                ),
            },
            'Ambitious Cases': {
                'Based on IEA (2016), "Energy Technology Perspectives - 2DS", IEA/OECD':
                THISDIR.joinpath(
                    'tam',
                    'tam_based_on_IEA_2016_Energy_Technology_Perspectives_2DS_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 = {
            'Conservative Cases': {
                'Navigant Research':
                THISDIR.joinpath('ad', 'ad_Navigant_Research.csv'),
                'Based on: IEA ETP 2016 4DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
                'Based on Clean Energy Manufacturing Analysis Center':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Clean_Energy_Manufacturing_Analysis_Center.csv'
                ),
            },
            'Ambitious Cases': {
                'Based on: IEA ETP 2016 2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
                'Interpolation Based on World Energy Council 2011 - Global Transport Scenarios 2050':
                THISDIR.joinpath(
                    'ad',
                    'ad_Interpolation_based_on_World_Energy_Council_2011_Global_Transport_Scenarios_2050.csv'
                ),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        wb = xlrd.open_workbook(
            filename=THISDIR.joinpath('hybridcarsdata.xlsx'))
        raw_sales = pd.read_excel(io=wb,
                                  sheet_name='HEV Sales',
                                  header=0,
                                  index_col=0,
                                  usecols='A:K',
                                  dtype='float',
                                  engine='xlrd',
                                  skiprows=7,
                                  nrows=43)
        hev_sales = raw_sales.rename(
            axis='columns',
            mapper={
                'World ': 'World',
                'OECD90 (US, EU Japan, Canada)': 'OECD90',
                'Asia sans Japan (China, India & Other.)': 'Asia (Sans Japan)',
                'Middle East & Africa': 'Middle East and Africa'
            }).fillna(0.0)
        lifetime = int(np.ceil(self.ac.soln_lifetime_replacement))
        sales_extended = hev_sales.copy()
        for year in range(2019, 2061):
            sales_extended.loc[year, :] = 0.0
        vehicle_retirements = sales_extended.shift(periods=lifetime,
                                                   fill_value=0.0)
        hev_stock = (hev_sales - vehicle_retirements).cumsum()
        pass_km_adoption = hev_stock * self.ac.soln_avg_annual_use

        # HybridCars.xlsm 'Data Interpolator'!H1582, Adoption Data
        # Project Drawdown Analysis based on Market Reports and a Drop in HEV
        # in later years (replaced by EVs) - PDS2
        predict = pd.read_csv(THISDIR.joinpath('ca_pds_data',
                                               'pass_km_datapoints_PDS2.csv'),
                              skipinitialspace=True,
                              comment='#',
                              index_col=0,
                              squeeze=True)
        pass_km_predicted = interpolation.poly_degree3_trend(
            predict)['adoption']
        pass_km_predicted.update(
            predict.loc[:2018])  # Early years adjusted to be actual values
        integration_pds2 = pd.read_csv(THISDIR.joinpath(
            'tam', 'integration_PDS2.csv'),
                                       skipinitialspace=True,
                                       comment='#',
                                       index_col=0)
        tam_limit_pds2 = 0.95 * (integration_pds2['URBAN'] +
                                 integration_pds2['NONURBAN']) * 1e9
        world = pd.concat([
            pass_km_adoption.loc[2012:2016, 'World'],
            pass_km_predicted.loc[2017:]
        ])
        ds1_df = pd.DataFrame(0, columns=dd.REGIONS, index=range(2012, 2061))
        ds1_df['World'] = world.clip(upper=tam_limit_pds2, lower=0.0, axis=0)

        # Data Source 2
        predict = pd.read_csv(THISDIR.joinpath('ca_pds_data',
                                               'pass_km_datapoints_PDS3.csv'),
                              skipinitialspace=True,
                              comment='#',
                              index_col=0,
                              squeeze=True)
        pass_km_predicted = interpolation.poly_degree3_trend(
            predict)['adoption']
        pass_km_predicted.update(
            predict.loc[:2018])  # Early years adjusted to be actual values
        integration_pds3 = pd.read_csv(THISDIR.joinpath(
            'tam', 'integration_PDS3.csv'),
                                       skipinitialspace=True,
                                       comment='#',
                                       index_col=0)
        intg_limit = (integration_pds3['URBAN'] +
                      integration_pds3['NONURBAN']) * 1e9
        tam_limit_pds3 = pd.concat([(intg_limit.loc[:2035] * 0.95),
                                    (intg_limit.loc[2036:] * 0.9)])
        world = pd.concat([
            pass_km_adoption.loc[2012:2016, 'World'],
            pass_km_predicted.loc[2017:]
        ])
        ds2_df = pd.DataFrame(0, columns=dd.REGIONS, index=range(2012, 2061))
        ds2_df['World'] = world.clip(upper=tam_limit_pds3, lower=0.0, axis=0)

        ca_pds_data_sources = [
            {
                'name':
                'PDS2-Transition to EVs in Cities',
                'include':
                True,
                'description':
                ('Considering that Electric Vehicles (BEV or PHEV)  are a better technology '
                 'from a lifetime emissions perspective, HEV are considered as a transition '
                 'technology in the PDS2  where the target is drawdown by 2050 particularly '
                 'within cities where there is minimal range anxiety. In this Drawdown '
                 'scenario, then, the focus is on growing EV after all higher priority '
                 'solutions (like non-motorized transportation) in cities are grown to their '
                 "maximum potential. For HEV's then, the adoption is projected to only occur "
                 'where BEV or PHEV cars cannot easily be used, such as for long distance '
                 'intercity trips until perhaps around 2025 when EV battery technology can be '
                 'assumed to be adequate enough to eliminate all range anxiety. The HEV '
                 'adoption is projected to continue its growth until around 2025 when it '
                 'starts to decline and trend to zero by or before 2050. Sales data for '
                 'multiple key countries and regions were used to estimate the actual global '
                 "sales. Using the model's lifetime data, the older HEVs are removed from the "
                 'fleet while aggregating the total sales to get the total stock per year. '
                 'With these, the projected sales from IEA are used to project increments to '
                 'the existing stock to 2050 (latest data vailable). Stock data are converted '
                 "to usage with model's Advanced Controls input.  All scenarios are limited "
                 'by integrated TAM after removing adoptions of higher priority solutions. '
                 ),
                'dataframe':
                ds1_df
            },
            {
                'name':
                'PDS3-Transition to EVs',
                'include':
                True,
                'description':
                ('Considering that Electric Vehicles (BEV or PHEV)  are a better technology '
                 'from a lifetime emissions perspective, HEV are considered as a transition '
                 'technology in the PDS3  where the target is maximizing emissions reduction. '
                 'In this scenario, then, the focus is on growing EV after all higher '
                 'priority solutions (like non-motorized transportation)  are grown to their '
                 'maximum potential. As soon as possible, HEV sales will rapidly decline. '
                 'Sales data for multiple key countries and regions were used to estimate the '
                 "actual global sales. Using the model's lifetime data, the older HEVs are "
                 'removed from the fleet while aggregating the total sales to get the total '
                 "stock per year.  Stock data are converted to usage with model's Advanced "
                 'Controls input.  All scenarios are limited by integrated TAM after removing '
                 'adoptions of higher priority solutions. '),
                'dataframe':
                ds2_df
            },
            {
                'name':
                'Drawdown Book - Edition 1- Quick Doubling of Hybrid Car Occupancy',
                'include':
                True,
                'description':
                ('We take the Average of two Ambitious adoption scenarios (on Adoption Data '
                 'tab): Interpolation of IEA 2016 ETP 2DS(2016), and World Energy Council '
                 '(2011) (both with annual use of ICCT Roadmap Model). We then double the HEV '
                 'car occupancy from 2017 and interpolate back to current adoption for 2014. '
                 ),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Book_Edition_1_Quick_Doubling_of_Hybrid_Car_Occupancy.csv'
                )
            },
            {
                'name':
                'PDS1 - Aggressive Growth from Existing Stock  based on  IEA 2DS',
                'include':
                True,
                'description':
                ('Sales data for multiple key countries and regions were used to estimate the '
                 "global sales. Using the model's lifetime data, the older HEVs are removed "
                 'from the fleet while aggregating the total sales to get the total stock per '
                 'year. With these, the projected sales from IEA are used to project '
                 'increments to the existing stock to 2050 (latest data vailable). Stock data '
                 "are converted to usage with model's Advanced Controls input. All scenarios "
                 'are limited by integrated TAM after removing adoptions of higher priority '
                 'solutions. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS1_Aggressive_Growth_from_Existing_Stock_based_on_IEA_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=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':
                'Default REF Projection with Adjustment for Recent Historical Adoptions',
                '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 HEV Pass-Km tab. '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Default_REF_Projection_with_Adjustment_for_Recent_Historical_Adoptions.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[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=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(),
            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)
Пример #8
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_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: Greenpeace 2015 Energy Revolution':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
                'Based on: AMPERE 2014 MESSAGE MACRO 450':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_450.csv'),
                'Based on: AMPERE 2014 MESSAGE MACRO 550':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_550.csv'),
                'Based on: AMPERE 2014 MESSAGE MACRO Reference':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_AMPERE_2014_MESSAGE_MACRO_Reference.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':
                THISDIR.joinpath('ad',
                                 'ad_based_on_Greenpeace_2015_Reference.csv'),
                'Based on: AMPERE 2014 GEM E3 Reference':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_GEM_E3_Reference.csv'),
                'Based on: IEA ETP 2016 6DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
            },
            'Ambitious Cases': {
                'Based on: IEA ETP 2016 2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
                'Based on: AMPERE 2014 IMAGE TIMER 550':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_550.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: AMPERE 2014 GEM E3 550':
                THISDIR.joinpath('ad',
                                 'ad_based_on_AMPERE_2014_GEM_E3_550.csv'),
                'Based on: AMPERE 2014 IMAGE TIMER Reference':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.csv'),
            },
            '100% RES2050 Case': {
                'Based on: Greenpeace 2015 Advanced Revolution':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
            },
            'Region: Middle East and Africa': {
                'Conservative Cases': {
                    'Based on: Greenpeace 2015 Reference':
                    THISDIR.joinpath(
                        'ad', 'ad_based_on_Greenpeace_2015_Reference.csv'),
                },
                'Ambitious Cases': {
                    '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: India': {
                'Baseline Cases': {
                    'Based on: IEA ETP 2016 6DS':
                    THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
                },
                'Conservative Cases': {
                    'Based on: Greenpeace 2015 Reference':
                    THISDIR.joinpath(
                        'ad', 'ad_based_on_Greenpeace_2015_Reference.csv'),
                    'Based on: IEA ETP 2016 4DS':
                    THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
                },
                'Ambitious Cases': {
                    'Based on: Greenpeace 2015 Energy Revolution':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_Greenpeace_2015_Energy_Revolution.csv'),
                    'Based on: IEA ETP 2016 2DS':
                    THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
                },
                '100% RES2050 Case': {
                    'Based on: Greenpeace 2015 Advanced Revolution':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_Greenpeace_2015_Advanced_Revolution.csv'),
                },
            },
            'Region: EU': {
                'Baseline Cases': {
                    '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'),
                },
                'Ambitious Cases': {
                    'Based on: IEA ETP 2016 2DS':
                    THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_2DS.csv'),
                },
            },
            'Region: USA': {
                'Baseline Cases': {
                    'Based on: IEA ETP 2016 4DS':
                    THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
                },
                'Conservative Cases': {
                    'Based on: IEA ETP 2016 6DS':
                    THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_6DS.csv'),
                    'Baeed on: Greenpeace Reference Scenario':
                    THISDIR.joinpath(
                        'ad', 'ad_Baeed_on_Greenpeace_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'),
                },
                '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)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'PDS 1 Baseline _Integrated with Waste Model on feedstock availability',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_1_Baseline__Integrated_with_Waste_Model_on_feedstock_availability.csv'
                )
            },
            {
                'name':
                'PDS 2 Baseline _Integrated with Waste Model on feedstock availability',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_2_Baseline__Integrated_with_Waste_Model_on_feedstock_availability.csv'
                )
            },
            {
                'name':
                'PDS 3 Baseline _Integrated with Waste Model on feedstock availability',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_3_Baseline__Integrated_with_Waste_Model_on_feedstock_availability.csv'
                )
            },
            {
                'name':
                'PDS 1 - CONSERVATIVE LANDFILL METHANE IF. CONSERVATIVE W2E (Integrated in Waste Model)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_1_CONSERVATIVE_LANDFILL_METHANE_IF__CONSERVATIVE_W2E_Integrated_in_Waste_Model.csv'
                )
            },
            {
                'name':
                'PDS 2 - CONSERVATIVE LANDFILL METHANE IF. CONSERVATIVE W2E (Integrated in Waste Model)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_2_CONSERVATIVE_LANDFILL_METHANE_IF__CONSERVATIVE_W2E_Integrated_in_Waste_Model.csv'
                )
            },
            {
                'name':
                'PDS 3 - CONSERVATIVE LANDFILL METHANE IF. CONSERVATIVE W2E (Integrated in Waste Model)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_3_CONSERVATIVE_LANDFILL_METHANE_IF__CONSERVATIVE_W2E_Integrated_in_Waste_Model.csv'
                )
            },
            {
                'name':
                'PDS 1 - AMBITIOUS LANDFILL METHANE IF AMBITIOUS W2E (Integrated in Waste Model)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_1_AMBITIOUS_LANDFILL_METHANE_IF_AMBITIOUS_W2E_Integrated_in_Waste_Model.csv'
                )
            },
            {
                'name':
                'PDS 2 - AMBITIOUS LANDFILL METHANE IF AMBITIOUS W2E (Integrated in Waste Model)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_2_AMBITIOUS_LANDFILL_METHANE_IF_AMBITIOUS_W2E_Integrated_in_Waste_Model.csv'
                )
            },
            {
                'name':
                'PDS 3 - AMBITIOUS LANDFILL METHANE IF AMBITIOUS W2E (Integrated in Waste Model)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS_3_AMBITIOUS_LANDFILL_METHANE_IF_AMBITIOUS_W2E_Integrated_in_Waste_Model.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(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)
Пример #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', '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'),
            },
            'Conservative Cases': {
                'Based on: IEA ETP 2016 4DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2016_4DS.csv'),
                'Based on: Greenpeace 2015 Reference':
                THISDIR.joinpath('ad',
                                 'ad_based_on_Greenpeace_2015_Reference.csv'),
                'Based on: AMPERE 2014 MESSAGE MACRO 550':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_550.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: AMPERE 2014 MESSAGE MACRO 450':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_AMPERE_2014_MESSAGE_MACRO_450.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)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'High Ambitious, double growth by 2030 & 2050',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_High_Ambitious_double_growth_by_2030_2050.csv'
                )
            },
            {
                'name':
                'Conservative Growth of 2.5% annum',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Conservative_Growth_of_2_5_annum.csv')
            },
            {
                'name':
                'Low Ambitious Growth, 10% higher compared to REF case',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Low_Ambitious_Growth_10_higher_compared_to_REF_case.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([
            547.672, 69.035, 38.758, 403.057, 17.967, 18.856, 383.689, 4.014,
            23.027, 3.148
        ],
                                            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)
Пример #10
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', '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)
Пример #11
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:
            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': {
                'Sum of regional prognostications below':
                THISDIR.joinpath(
                    'ad', 'ad_Sum_of_regional_prognostications_below.csv'),
            },
            'Region: Asia (Sans Japan)': {
                'Raw Data for ALL LAND TYPES': {
                    'Dara et al. 2018; Kazakshstan recultivation':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Dara_et_al__2018_Kazakshstan_recultivation.csv'),
                },
            },
            'Region: China': {
                'Tropical-Humid Land': {
                    'Lin, L, et al 2018, Wenzhou province only':
                    THISDIR.joinpath(
                        'ad', 'ad_Lin_L_et_al_2018_Wenzhou_province_only.csv'),
                },
            },
            'Region: EU': {
                'Tropical-Humid Land': {
                    'Estel et al. 2015, 2nd Poly, capped at 94.7mha':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Estel_et_al__2015_2nd_Poly_capped_at_94_7mha.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
        growth_initial = pd.DataFrame(
            [[2018] + list(self.ac.ref_base_adoption.values())],
            columns=ca_pds_columns).set_index('Year')
        tla_init = self.ac.ref_base_adoption['World']
        tla_grow = self.tla_per_region.loc[2050, 'World'] - tla_init

        ca_pds_data_sources = [
            {
                'name': '1.32% ann, Linear Trend',
                'include': True,
                'growth_rate': 0.013219212962963,
                # Limited information on restoration of abandoned farmland is available (see
                # data interpolation sheet). As abandoned farmlands area a subset of degraded
                # land, it is asumed that the restoration of abandoned farmland will also follow
                # similar trends. Refer sheet, "Adoption rates-Deg Area".
                'growth_initial': growth_initial
            },
            {
                'name': '2.64% annual rate, Linear Trend',
                'include': False,
                # This scenario projects future growth by doubling of historical annual
                # rate in India
                'growth_rate': (2 * 0.013219212962963),
                'growth_initial': growth_initial
            },
            {
                'name':
                '63% of TLA, Linear Trend',
                'include':
                True,
                #  It is assumed that by 2050, 63% of the total degraded farmlands will be restored
                # for cropping. This is the highest reported adoption - from rainfed cultivated
                # areas in India over several decades: see Adoption trends-Deg Area worksheet.
                'datapoints':
                pd.DataFrame([
                    [2012] + list(self.ac.ref_base_adoption.values()),
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [
                        2050, tla_init + (tla_grow * 0.63), 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')
            },
            {
                'name':
                'Very high: 85%  of TLA, Linear Trend',
                'include':
                False,
                # It is assumed that by 2050, 85% of the total abandoned farmlands will be
                # restored for cropping.
                'datapoints':
                pd.DataFrame([
                    [2012] + list(self.ac.ref_base_adoption.values()),
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [
                        2050, tla_init + (tla_grow * 0.85), 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')
            },
            {
                'name':
                'Maximum, Linear Trend',
                'include':
                True,
                # It is assumed that by 2050, 100% of the total abandoned farmlands will be
                # restored for cropping.
                'datapoints':
                pd.DataFrame([
                    [2012] + list(self.ac.ref_base_adoption.values()),
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [
                        2050, tla_init + (tla_grow * 1.00), 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')
            },
            {
                'name':
                'Historical linear based on Whenzhou province China reclaimed lands',
                'include': True,
                # Based on low interpolated linear trend from historical data on annual adoption
                # rate for Whenzhoue province China; Lin, Jia et al 2017
                'include': True,
                'growth_rate': 0.0696,
                'growth_initial': growth_initial
            },
            {
                'name': 'Historical linear based on EU -Estel et al 2015',
                'include': True,
                # Based on low interpolated linear trend from historical data on annual adoption
                # rate for EU, based on Estel et al 2015
                'growth_rate': 0.0568,
                'growth_initial': growth_initial
            },
            {
                'name':
                'Historical linear trend based on Kazakstan, Dara et al 2017',
                'include': True,
                # Based on low interpolated linear trend from historical data on annual adoption
                # rate for Kazahkstan, based on Dara et al 2017
                'growth_rate': 0.0512,
                'growth_initial': growth_initial
            },
        ]
        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 year in range(2012, 2019):
                df.loc[year] = [
                    20.029602999999, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0
                ]
            df.sort_index(inplace=True)

        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)
Пример #12
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':
                'Regional linear trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Regional_linear_trend.csv')
            },
            {
                'name':
                'Regional max linear trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Regional_max_linear_trend.csv')
            },
            {
                'name':
                '50% of the max annual afforestation rate across the regions',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_50_of_the_max_annual_afforestation_rate_across_the_regions.csv'
                )
            },
            {
                'name':
                '100% of the max annual afforestation rate across the regions',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_100_of_the_max_annual_afforestation_rate_across_the_regions.csv'
                )
            },
            {
                'name':
                '200% increase for Asia and 100% for the other regions',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_200_increase_for_Asia_and_100_for_the_other_regions.csv'
                )
            },
            {
                'name':
                'Global high - medium early adoption',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Global_high_medium_early_adoption.csv')
            },
            {
                'name':
                'Global high - high early adoption',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Global_high_high_early_adoption.csv')
            },
            {
                'name':
                'Global max - max early adoption',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Global_max_max_early_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([
            297.78662238675923, 98.41788764519316, 44.68660278943361,
            119.60170249905194, 17.61544828747855, 17.464981165602055, 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())
Пример #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': {
                'Based on: IEA ETP 2016 6DS':
                THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2016_6DS.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'),
            },
        }
        tam_pds_data_sources = {
            'Ambitious Cases': {
                'Drawdown TAM: Drawdown Integrated TAM - PDS1':
                THISDIR.joinpath(
                    'tam',
                    'tam_pds_Drawdown_TAM_Drawdown_Integrated_TAM_PDS1.csv'),
                'Drawdown TAM: Drawdown Integrated TAM - PDS2':
                THISDIR.joinpath(
                    'tam',
                    'tam_pds_Drawdown_TAM_Drawdown_Integrated_TAM_PDS2.csv'),
            },
            'Maximum Cases': {
                'Drawdown TAM: Drawdown Integrated TAM - PDS3':
                THISDIR.joinpath(
                    'tam',
                    'tam_pds_Drawdown_TAM_Drawdown_Integrated_TAM_PDS3.csv'),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=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 = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Trajectory Adapted from REF Scenario Greenpeace (2015)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Trajectory_Adapted_from_REF_Scenario_Greenpeace_2015.csv'
                )
            },
            {
                'name':
                'Based on: Greenpeace 2015 Energy Revolution',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_based_on_Greenpeace_2015_Energy_Revolution.csv'
                )
            },
            {
                'name':
                'Based on: Greenpeace 2015 Advanced Revolution',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_based_on_Greenpeace_2015_Advanced_Revolution.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(
            [1.99921610218339, 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=1000000000.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=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)
Пример #14
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'),
      },
      '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
    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_2050 = self.tla_per_region.loc[2050, 'World']

        # Page 9, Green India Mission- Mission document
        # http://moef.gov.in/wp-content/uploads/2017/08/GIM_Mission-Document-1.pdf
        i_percent = 300000 / 346713

        # Guatemala
        # Table on page 35 of "Mesa de Restauración del Paisaje Forestal de Guatemala 2015.
        # Estrategia de Restauración del Paisaje Forestal: Mecanismo para el Desarrollo Rural
        # Sostenible de Guatemala, 58 pp."
        g_percent = 10132 / 26464

        avg_percent = (i_percent + g_percent) / 2.0

        ca_pds_data_sources = [
            {
                'name':
                'India restoration commitment applied to TLA',
                'include':
                True,
                'description':
                ('The National Mission for a Green India included a commitment to restore 0.1 '
                 'Mha of mangroves in 10 years (up to 2020). We assume that this commitment '
                 'will be replicated in the next three decades resulting in 300,000 hectares '
                 'to be restored by 2050. This would represent a restoration of 89% of '
                 'mangrove restorable area in India. We apply this % to the global mangrove '
                 'area. '),
                'datapoints':
                pd.DataFrame([
                    [2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [
                        2050, i_percent * tla_2050, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2051, i_percent * tla_2050, 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')
            },
            {
                'name':
                'India + Guatemala restoration commitment applied to TLA',
                'include':
                True,
                'description':
                ("Guatemala's NDC includes the restoration of 10,000 ha of mangroves by 2045. "
                 'This would represent 38% of total mangrove restorable area in the country. '
                 'We use the average of both India  (87%) and Guatemala % and apply them to '
                 'the TLA '),
                'datapoints':
                pd.DataFrame([
                    [2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [
                        2050, avg_percent * tla_2050, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2051, avg_percent * tla_2050, 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')
            },
            {
                'name':
                'India restoration commitment applied to TLA with 100% adoption by 2030',
                'include':
                True,
                'description': ('Scenario 1 + 100% of adoption by 2030 '),
                'datapoints':
                pd.DataFrame([
                    [2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [
                        2030, i_percent * tla_2050, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2031, i_percent * tla_2050, 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')
            },
            {
                'name':
                'India + Guatemala restoration commitment applied to TLA with 100% adoption in 2030',
                'include':
                True,
                'description': ('Scenario 2 + 100% adoption by 2030 '),
                'datapoints':
                pd.DataFrame([
                    [2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [
                        2030, avg_percent * tla_2050, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2031, avg_percent * tla_2050, 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')
            },
            {
                'name':
                '100% TLA by 2050',
                'include':
                True,
                'description': ('Linear increase to 100% TLA by 2050 '),
                'datapoints':
                pd.DataFrame([
                    [2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [
                        2050, 1.0 * tla_2050, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2051, 1.0 * tla_2050, 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')
            },
            {
                'name':
                '100% TLA by 2030',
                'include':
                True,
                'description': ('Linear increase to 100% TLA by 2030 '),
                'datapoints':
                pd.DataFrame([
                    [2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [
                        2030, 1.0 * tla_2050, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2031, 1.0 * tla_2050, 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(2014, 2019):
                df.loc[y, 'World'] = 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[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,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
Пример #16
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 2014 6DS': THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2014_6DS.csv'),
      },
      'Conservative Cases': {
          'Based on: IEA ETP 2014 4DS': THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2014_4DS.csv'),
      },
      'Ambitious Cases': {
          'Based on: IEA ETP 2014 2DS': THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2014_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()

    # Custom PDS Data
    ca_pds_data_sources = [
      {'name': 'PDS1 - Based on ICCT+RMI Freight Work Adoption estimates', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_PDS1_based_on_ICCTRMI_Freight_Work_Adoption_estimates.csv')},
      {'name': 'PDS2 - Based on an ICCT Truck Sales extrapolation', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_PDS2_based_on_an_ICCT_Truck_Sales_extrapolation.csv')},
      {'name': 'PDS3 - Based on IEA Freight Work - 100% Adoption of Trucks by 2035', 'include': True,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_PDS3_based_on_IEA_Freight_Work_100_Adoption_of_Trucks_by_2035.csv')},
      {'name': 'Book Ed.1 Scenario 1', 'include': False,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Book_Ed_1_Scenario_1.csv')},
      {'name': 'Book Ed.1 Scenario 3', 'include': False,
          'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Book_Ed_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)

    # Custom REF Data
    ca_ref_data_sources = [
      {'name': 'Drawdown Book Reference Scenario', 'include': False,
          'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Drawdown_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

    ht_ref_adoption_initial = pd.Series(
      [600621.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,
        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)
Пример #17
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()

        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': {
                'ITDP/UCD (2015) A Global High Shift Cycling Scenario - High Shift Scenario  - Early Years replaced with Recent Historical Data': THISDIR.joinpath('ad', 'ad_ITDPUCD_2015_A_Global_High_Shift_Cycling_Scenario_High_Shift_Scenario_Early_Years_replac_b131f9f6.csv'),
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac, data_sources=ad_data_sources,
            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {'name': 'PDS2 - Density remains Constant and is the key driver of walking in cities.', 'include': True,
                'description': (
                    'We project the amount of walking that would happen in 1,737 cities '
                    'worldwide representing 57% of the global urban population then we scale the '
                    'total amount of walking to 100% of the world’s urban population. The '
                    'background calculations of this scenario use the population and density of '
                    'each of the 1737 cities from Demographia’s report and projects the fraction '
                    'of each country’s urban population in that city. We assume that that '
                    'fraction is constant and then project the city’s population each year to '
                    '2050 using UN projections of each country’s urban population to 2050. With '
                    'the TAM and total urban population projections, we estimate the mobility '
                    'per urban resident each year and then apply 6.5% to walking in each city in '
                    'each year when the density is over the "dense city threshold" (~3,000 '
                    'p/sqkm) and 2% otherwise. Each year is scaled to the global urban '
                    'population. '
                    ),
                'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_PDS2_Density_remains_Constant_and_is_the_key_driver_of_walking_in_cities_.csv')},
            {'name': 'PDS2 - Increasing Urban Density with Density Driving Urban Walking (Book Ed.1)', 'include': True,
                'description': (
                    'We project the amount of walking that would happen in 1,737 cities '
                    'worldwide representing 57% of the global urban population then we scale the '
                    'total amount of walking to 100% of the world’s urban population. The '
                    'background calculations of this scenario use the population and density of '
                    'each of the 1737 cities from Demographia’s report and projects the fraction '
                    'of each country’s urban population in that city. We assume that that '
                    'fraction is constant and then project the city’s population each year to '
                    '2050 using UN projections of each country’s urban population to 2050. With '
                    'the TAM and total urban population projections, we estimate the mobility '
                    'per urban resident each year and then apply 7% to walking in each city in '
                    'each year when the density is over the "dense city threshold" (~3,000 '
                    'p/sqkm) and 2% otherwise. Each year is scaled to the global urban '
                    'population. City densities are assumed to increased by around 2.4% annually '
                    'which reverses historical declines of around 2%. This scenario was '
                    'calculated for the Drawdown book Edition 1. Some variables may have been '
                    'updated. '
                    ),
                'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_PDS2_Increasing_Urban_Density_with_Density_Driving_Urban_Walking_Book_Ed_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': 'Custom REF Scenario 1: Fixed Passenger-km Annual after 2014', 'include': True,
                'description': (
                    'Taking the estimated passenger-km adoption value from 2014, we hold that '
                    'constant out to 2050 which assumes that the total amount of walking remains '
                    'constant despite increasing populations. The rapid rise in populations '
                    'generally happens in developing countries, and as these countries urbanise '
                    'and get wealthier, there is a large trend towards increased motorization '
                    'following the historical patterns of Western Nations. This then, although a '
                    'pessimistic case, is not unrealistic. '
                    ),
                'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Custom_REF_Scenario_1_Fixed_Passengerkm_Annual_after_2018.csv')},
            {'name': 'Reference Growth in Walking', 'include': True,
                'description': (
                    'Here the Drawdown Model of Urban density for 1,737 cities across the world '
                    'in the Demographia Dataset was used to develop a reasonable Reference '
                    'Scenario for Walking out to the end of the analysis period. While full '
                    'details are described in the [Mobility Output] sheet, here is the summary: '
                    'The urban density of these cities (representing 57% of the world urban '
                    'population), was obtained from the data source and projected out to 2050 '
                    'using an assumed global urban density change as listed below. Research on '
                    'walking in cities indicates that higher density is correlated with more '
                    'walking, so an assumed walking mode share in cities with at least the '
                    'minimum threshold urban density, and another assumed walking mode share for '
                    'cities below this threshold were together used to estimate the average '
                    'walking for each city in each year (considering that density change is '
                    'assumed). The total walking mobility in these cities was summed and then '
                    'scaled linearly to 100% of the global urban population. This projection to '
                    '2050 was then interpolated and extrapolated to develop a smooth curve for '
                    'the entire analysis period. Also taken into account: increasing urban '
                    'population, assumed fixed total mobility per capita, recent historical '
                    'walking estimates have been used (2012-2018) instead of curve fit. '
                    ),
                'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Reference_Growth_in_Walking.csv')},
            {'name': 'ITDP/ UCDavis (2015) Global Highshift Cycling Scenario - Baseline Case for Walking', 'include': True,
                'description': (
                    'The Source listed below estimated a Baseline Walking Case which generally '
                    'shows an increae in walking, but not in line with total mobility increase, '
                    'so the walking mode share declines over time. The source published data in '
                    '5-year increments, these have been interpolated for missing years (on Data- '
                    'Interpolator) and pasted here. '
                    ),
                'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_ITDP_UCDavis_2015_Global_Highshift_Cycling_Scenario_Baseline_Case_for_Walking.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(),
            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)
Пример #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': {
                'Combined from IEA ETP 2016, ICAO 2014, Boeing 2013, Airbus 2014, Highest Ranges':
                THISDIR.joinpath(
                    'tam',
                    'tam_Combined_from_IEA_ETP_2016_ICAO_2014_Boeing_2013_Airbus_2014_Highest_Ranges.csv'
                ),
            },
            'Conservative Cases': {
                'Combined from IEA ETP 2016, ICAO 2014, Boeing 2013, Airbus 2014, Middle Ranges':
                THISDIR.joinpath(
                    'tam',
                    'tam_Combined_from_IEA_ETP_2016_ICAO_2014_Boeing_2013_Airbus_2014_Middle_Ranges.csv'
                ),
            },
            'Ambitious Cases': {
                'Combined from IEA ETP 2016, ICAO 2014, Boeing 2013, Airbus 2014, Lowest Ranges':
                THISDIR.joinpath(
                    'tam',
                    'tam_Combined_from_IEA_ETP_2016_ICAO_2014_Boeing_2013_Airbus_2014_Lowest_Ranges.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
        wb = xlrd.open_workbook(filename=THISDIR.joinpath('trainsdata.xlsx'))
        adoption1 = pd.read_excel(io=wb,
                                  sheet_name='Adoption1',
                                  header=0,
                                  index_col=0,
                                  usecols='A:C',
                                  dtype='float',
                                  engine='xlrd',
                                  skiprows=12,
                                  nrows=47)
        adoption2 = pd.read_excel(io=wb,
                                  sheet_name='Adoption2',
                                  header=0,
                                  index_col=0,
                                  usecols='A:B',
                                  dtype='float',
                                  engine='xlrd',
                                  skiprows=12,
                                  nrows=47)
        adoption3 = pd.read_excel(io=wb,
                                  sheet_name='Adoption3',
                                  header=0,
                                  index_col=0,
                                  usecols='A:C',
                                  dtype='float',
                                  engine='xlrd',
                                  skiprows=12,
                                  nrows=47)

        ds1_df = pd.DataFrame(index=range(2012, 2061), columns=dd.REGIONS)
        ds1_df['World'] = adoption2['Electrified Freight million tonne-km']

        ds2_df = pd.DataFrame(index=range(2012, 2061), columns=dd.REGIONS)
        ds2_df['World'] = adoption1['Electrified']

        ds3_df = pd.DataFrame(index=range(2012, 2061), columns=dd.REGIONS)
        ds3_df['World'] = adoption3['Electrified']

        ca_pds_data_sources = [
            {
                'name':
                'PDS2 - Doubling of Historical Electrification Rate (UIC data)',
                'include':
                True,
                'description':
                ('Electrified railway tkms increase at TWICE the historical average annual '
                 'rate of track electrification. Using UIC data, we estimate the average '
                 'electrification rate at 1.4% annually. We double this and use this rate as '
                 'the optimistically plausible electrification rate. This is reasonable since '
                 "it still remains below the annual rate of many year's growth according to "
                 'UIC data below. This may come from increased track length and uniform '
                 'usage, or higher usage of electrified tracks versus other tracks. '
                 ),
                'dataframe':
                ds1_df
            },
            {
                'name':
                'PDS1 - Linear projection of Electricity-powered rail freight from 27% of rail freight in 2014 to 40% in 2050 (IEA 2DS projection)',
                'include':
                True,
                'description':
                ('UIC data for 2014 indicates 27% electrification of rails. The IEA 2DS '
                 'scenario projects that 40% of rail freight can be powered by electricity by '
                 '2050. We linearly interpolate between these two percentages. We also use an '
                 'annual average use rate that is 25% higher for the electrified tracks than '
                 'the conventional. '),
                'dataframe':
                ds2_df
            },
            {
                'name':
                'PDS3 - Linear projection of Electricity-powered rail freight from 27% of rail freight in 2014 to 100% in 2050',
                'include':
                True,
                'description':
                ('UIC data for 2014 indicates 27% electrification of rails. The IEA 2DS '
                 'scenario projects that 40% of rail freight can be powered by electricity by '
                 '2050. We examine the impact of making this target 100% in 2050 by linearly '
                 'interpolating between these two percentages. We also assume a doubling of '
                 'the electrified track usage versus the conventional. '),
                'dataframe':
                ds3_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
        ca_ref_data_sources = [
            {
                'name':
                'Drawdown Book Reference Scenario',
                'include':
                True,
                'description':
                ('This scenario uses the inputs that were used for the Scenario developed for '
                 'the Drawdown Book Edition 1. The scenario assumes a fixed percent of the '
                 'TAM is adopted for Efficient trucks as the TAM grows. '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Drawdown_Book_Reference_Scenario.csv')
            },
            {
                'name':
                'Default REF Projection with Adjustment for Recent Historical Adoptions',
                '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 Adoption1. '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Default_REF_Projection_with_Adjustment_for_Recent_Historical_Adoptions.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(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,
            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(),
            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
    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': {
                'Nair 2012 & Lal et al. 2018':
                THISDIR.joinpath('ad', 'ad_Nair_2012_Lal_et_al__2018.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']
        adoption_vma = VMAs['Current Adoption']
        adoption_2018 = adoption_vma.avg_high_low(key='mean')

        # SOURCE: den Herder, M., Moreno, G., Mosquera-Losada, R. M., Palma, J. H., Sidiropoulou,
        # A., Freijanes, J. J. S., ... & Papanastasis, V. P. (2017). Current extent and
        # stratification of agroforestry in the European Union. Agriculture, Ecosystems &
        # Environment, 241, 121-132.
        ds4_silvo_of_grassland = 0.35
        ds4_total_grassland = 3621.237045
        ds4_potential_adoption = ds4_silvo_of_grassland * ds4_total_grassland
        ds4_adopt_2050 = 0.6 * ds4_potential_adoption

        # SOURCE: Somarriba, E., Beer, J., Alegre-Orihuela, J., Andrade, H. J., Cerda, R., DeClerck,
        # F., ... & Krishnamurthy, L. (2012). Mainstreaming agroforestry in Latin America. In
        # Agroforestry-The Future of Global Land Use (pp. 429-453). Springer, Dordrecht.
        ds5_adoption_rate = 0.45
        pg_vma = VMAs['Total Pasture/Grazing Area']
        pasture_grassland_area = pg_vma.avg_high_low(key='mean')
        ds5_potential_adoption = ds5_adoption_rate * pasture_grassland_area
        ds5_adopt_2050 = 0.6 * ds5_potential_adoption

        # SOURCE: Holman et al., 2004, http://www.lrrd.org/lrrd16/12/holm16098.htm
        growth_initial = pd.DataFrame(
            [[2018] + list(self.ac.ref_base_adoption.values())],
            columns=ca_pds_columns).set_index('Year')
        ds6_rate = 0.006

        # SOURCE: Holman et al., 2004, http://www.lrrd.org/lrrd16/12/holm16098.htm
        ds7_rate = 0.013

        ca_pds_data_sources = [
            {
                'name':
                'Linear trend based on Zomers  >30% tree cover percent area applied in grassland area',
                'include':
                False,
                # This is a proxy adoption scenario which is created in the absence of any data
                # available either on historical growth rate of silvopasture or any future
                # projections. Thus, the present scenario builds the future adoption using the
                # Zoomer 2014 information available on tree coverage in the agricultural area.
                # Country level data on agricultural area with > 30 percent tree cover was available
                # at Zomer 2014. This data was compiled at the Project Drawdown regions, which is
                # then used to get their percent with respect  to the total agricultural area.
                # Those percentages were then applied on the grassland area to get the regional
                # grassland area under >30 percent tree cover. The future adoption of the silvopasture
                # area under was thus projected based on the regional linear trend applied to the
                # grassland area with >30 percent tree coverage. The projections were based on the
                # regional linear trend. (Refer PD region wise - silvopasture sheet)
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Linear_trend_based_on_Zomers_30_tree_cover_percent_area_applied_in_grassland_area.csv'
                )
            },
            {
                'name':
                'Linear trend based on Zomers >30% tree cover percent area and conversion of >10% are to 30% tree cover area applied in grassland area',
                'include':
                False,
                #  In this scenario, the future area in silvopasture is projected based on scenario
                # one, in addition it was assumed that there will be some extra area available for
                # silvopasture by the conversion of 0-10 percent/11-20 percent tree coverage
                # grassland area to >30 percent tree coverage areas as required for a silvopasture
                # system.  The projections are based on regional linear trends.
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Linear_trend_based_on_Zomers_30_tree_cover_percent_area_and_conversion_of_10_are_to_30_t_d419700f.csv'
                )
            },
            {
                'name':
                'Linear Interpolation for Adoption Data based on Nair 2012 & Lal et al. 2018',
                'include':
                True,
                # In the absence of comprehensive historical data for silvopasture adoption, this
                # scenario uses available global adoption estimates reported in peer-reviewed
                # publications. Data points ffrom 2012 (Nair 2012) and 2018 (Lal et al. 2018) were
                # used for a linear interpolation of future adoption based on historic expansion of
                # silvopasture adoption.
                'datapoints':
                pd.DataFrame([
                    [
                        2018, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2050, 1083.33333333333, 0., 0., 0., 0., 0., 0., 0., 0.,
                        0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Medium interpolation based on current adoption, linear trend (high regional proportion of grazing land under silvopasture)',
                'include':
                True,
                # Future area in silvopasture is projected based on the proportion of current area
                # of grazing or pasture land under silvopasture practice in the EU, which currently
                # has the highest regional proportion of grazing land under silvopasture worldwide
                # (35%), as reported by den Herder et al 2017 (see VMA, Variable 31). This percentage
                # was applied to the total global grazing area to obtain a medium estimate of
                # potential projected area for future silvopasture adoption. This scenario assumes
                # 60 percent of future silvopasture adoption by 2050.
                'datapoints':
                pd.DataFrame([
                    [
                        2018, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [2050, ds4_adopt_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'High interpolation based on current adoption, linear trend (high national proportion of grazing land under silvopasture)',
                'include':
                True,
                # Future area in silvopasture is projected based on the proportion of current area
                # of grazing or pasture land under silvopasture practice in Nicaragua, which currently
                # has the highest national proportion of grazing land under silvopasture worldwide
                # (45%), as reported by Somarriba et al 2012 (see VMA, Variable 31). This percentage
                # was applied to the total global grazing area to obtain a high estimate of potential
                # projected area for future silvopasture adoption. This scenario assumes 60 percent
                # of future silvopasture adoption by 2050.
                'datapoints':
                pd.DataFrame([
                    [
                        2018, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [2050, ds5_adopt_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Low growth, linear trend (based on improved pasture area)',
                'include': True,
                # This is a proxy adoption scenario which is created in the absence of any data
                # available either on historical growth rate of silvopasture or any future projections
                # on silvopasture. In this scenario future adoption of silvopasture area was projected
                # using the Thorton 2010 future adoption rates given for improved pasture. The
                # silvopasture adoption is  projected based on the average annual adoption percent
                # (0.60%) increase in the improved pasture area given for the five countries (Mexico,
                # Honduras, Nicaragua, Costa Rica, and Panama) by Holman et al 2004 and reported by
                # Thorton et al 2010. With the limitation of data at the regional level, the
                # projections are made only at the global scale.
                'growth_rate': ds6_rate,
                'growth_initial': growth_initial
            },
            {
                'name':
                'High growth, linear trend (based on improved pasture area)',
                'include': True,
                # This is a proxy adoption scenario which is created in the absence of any data
                # available either on historical growth rate of silvopasture or any future projections
                # on silvopasture. In this scenario future adoption of silvopasture area was projected
                # using the Thorton 2010 future adoption rates given for improved pasture. The
                # silvopasture adoption is  projected based on the maximum annual adoption percent
                # (1.30%) increase in the improved pasture area given for the five countries (Mexico,
                # Honduras, Nicaragua, Costa Rica, and Panama) by Holman et al 2004 and reported by
                # Thorton et al 2010. With the limitation of data at the regional level, the
                # projections are made only at the global scale.
                'growth_rate': ds7_rate,
                'growth_initial': growth_initial
            },
        ]
        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)
        # Manual adjustment made in spreadsheet for Drawdown 2020.
        for source in ca_pds_data_sources:
            if 'filename' in source:
                # only the interpolated sources are adjusted
                continue
            name = source['name']
            s = self.pds_ca.scenarios[name]
            df = s['df']
            df.loc[2012, 'World'] = 450.0
            df.loc[2013, 'World'] = 466.666666666667
            df.loc[2014, 'World'] = 483.333333333333
            df.loc[2015, 'World'] = 500.0
            df.loc[2016, 'World'] = 516.666666666667
            df.loc[2017, 'World'] = 533.333333333333
            df.loc[2018, 'World'] = 550.0

        # 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')
            },
        ]
        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=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)
Пример #20
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_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 BP Energy Outlook 2019 (Evolving transition Scenario)':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_BP_Energy_Outlook_2019_Evolving_transition_Scenario.csv'
                ),
                'Based on IEEJ Outlook - 2019, Ref Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_IEEJ_Outlook_2019_Ref_Scenario.csv'),
                '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'),
            },
            'Conservative Cases': {
                'Based on Equinor (2018), Reform Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Equinor_2018_Reform_Scenario.csv'),
                'Based on IEA, WEO-2018, New Policies Scenario (NPS)':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEA_WEO2018_New_Policies_Scenario_NPS.csv'),
            },
            'Ambitious Cases': {
                'Based on Equinor (2018), Renewal Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_Equinor_2018_Renewal_Scenario.csv'),
                'Based on IEEJ Outlook - 2019, Advanced Tech Scenario':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IEEJ_Outlook_2019_Advanced_Tech_Scenario.csv'
                ),
                'Based on: Grantham Institute and Carbon Tracker (2017), Strong Scenario, Original, Medium':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Grantham_Institute_and_Carbon_Tracker_2017_Strong_Scenario_Original_Medium.csv'
                ),
                '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: IEA ETP 2017 2DS':
                THISDIR.joinpath('ad', 'ad_based_on_IEA_ETP_2017_2DS.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'
                ),
            },
            'Region: OECD90': {
                'Baseline Cases': {
                    'Based on: AMPERE 2014 MESSAGE MACRO Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_MESSAGE_MACRO_Reference.csv'),
                    'Based on: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.csv'),
                },
                'Conservative Cases': {
                    '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: 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'),
                },
            },
            'Region: Eastern Europe': {
                'Baseline Cases': {
                    '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: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.csv'),
                },
                'Conservative Cases': {
                    '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: 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'),
                },
            },
            'Region: Asia (Sans Japan)': {
                'Baseline Cases': {
                    'Based on: AMPERE 2014 MESSAGE MACRO Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_MESSAGE_MACRO_Reference.csv'),
                    'Based on: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.csv'),
                },
                'Conservative Cases': {
                    '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 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'),
                },
            },
            'Region: Middle East and Africa': {
                'Baseline Cases': {
                    'Based on: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.csv'),
                },
                'Conservative Cases': {
                    '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 IMAGE TIMER 450':
                    THISDIR.joinpath(
                        'ad', 'ad_based_on_AMPERE_2014_IMAGE_TIMER_450.csv'),
                },
            },
            'Region: Latin America': {
                'Baseline Cases': {
                    'Based on: AMPERE 2014 MESSAGE MACRO Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_MESSAGE_MACRO_Reference.csv'),
                    'Based on: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.csv'),
                },
                'Conservative Cases': {
                    '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 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'),
                },
            },
            'Region: China': {
                'Baseline Cases': {
                    '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: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.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'),
                },
                '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'),
                },
            },
            'Region: India': {
                'Baseline Cases': {
                    '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: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.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'),
                },
                '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'),
                },
            },
            'Region: EU': {
                'Baseline Cases': {
                    '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: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.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'),
                },
                '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'),
                },
            },
            'Region: USA': {
                'Baseline Cases': {
                    '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: AMPERE 2014 IMAGE TIMER Reference':
                    THISDIR.joinpath(
                        'ad',
                        'ad_based_on_AMPERE_2014_IMAGE_TIMER_Reference.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'),
                },
                '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'),
                },
            },
        }
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Project Drawdown High Growth, Ambitious Cases, adjusted',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Project_Drawdown_High_Growth_Ambitious_Cases_adjusted.csv'
                )
            },
            {
                'name':
                'Project Drawdown High Growth, Conservative Cases, adjusted, smoothed curve',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Project_Drawdown_High_Growth_Conservative_Cases_adjusted_smoothed_curve.csv'
                )
            },
            {
                'name':
                'Optimum Nuclear reduces to 0% of TAM by 2050, based on AMPERE RefPol Scenario (2014) till peaking',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Optimum_Nuclear_reduces_to_0_of_TAM_by_2050_based_on_AMPERE_RefPol_Scenario_2014_till_peaking.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 mirroring decline in nuclear in Plausible SCenario',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Custom_REF_Adoption_mirroring_decline_in_nuclear_in_Plausible_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)

        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,
            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)
Пример #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': {
                '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: USA': {
                'Baseline Cases': {
                    'Annual Energy Outlook 2016, U.S. Energy Information Administration, 2016.':
                    THISDIR.joinpath(
                        'tam',
                        'tam_Annual_Energy_Outlook_2016_U_S__Energy_Information_Administration_2016_.csv'
                    ),
                },
            },
        }
        tam_pds_data_sources = {
            'Baseline Cases': {
                'Drawdown TAM: Adjusted GBPN Data - Commercial Floor Area':
                THISDIR.joinpath(
                    'tam',
                    'tam_pds_Drawdown_TAM_Adjusted_GBPN_Data_Commercial_Floor_Area.csv'
                ),
            },
        }
        self.tm = tam.TAM(tamconfig=tamconfig,
                          tam_ref_data_sources=tam_ref_data_sources,
                          tam_pds_data_sources=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 = {}
        self.ad = adoptiondata.AdoptionData(ac=self.ac,
                                            data_sources=ad_data_sources,
                                            adconfig=adconfig)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'PDS1 - Adoption based on Navigant Sales and World Green Buildings Council Targets',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS1_Adoption_based_on_Navigant_Sales_and_World_Green_Buildings_Council_Targets.csv'
                )
            },
            {
                'name':
                'PDS2 - Adoption based on Navigant Sales and World Green Buildings Council Targets',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS2_Adoption_based_on_Navigant_Sales_and_World_Green_Buildings_Council_Targets.csv'
                )
            },
            {
                'name':
                'PDS3 - Adoption based on Navigant Sales and World Green Buildings Council Targets',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_PDS3_Adoption_based_on_Navigant_Sales_and_World_Green_Buildings_Council_Targets.csv'
                )
            },
            {
                'name':
                'Drawdown Book (Edition 1) Scenario 3',
                'include':
                True,
                '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(
            [1.9734999131249993, 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)
Пример #22
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': True,
                'description': (
                    'Taking the production rate of aircraft  by the two major suppliers - Airbus '
                    'and Boeing, we project the production of "efficient model" aircraft over '
                    'the future. We also assume that a third manufacturer enters the market '
                    '(possibly COMAC or UAC) in 2025 and produces first single aisle then twin '
                    'aisle aircraft of competitive quality. 100 aircraft per year are '
                    'retrofitted to equivalent new-aircraft efficiency. Each aircraft in the '
                    'fleet is assumed to work around  an average number of passenger-km per year '
                    'according to an estimate for each of single aisle and twin aisle from our '
                    'brief schedule calculations including downtime for maintenance checks, and '
                    'new models are 1SD below the average estimated efficiency improvement '
                    '(~13%). We assume that the production rate of the big players remains '
                    'constant, but that the newcomer increases production annually. '
                    ),
                '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': True,
                'description': (
                    'Taking the production rate of aircraft  by the two major suppliers - Airbus '
                    'and Boeing, we project the production of "efficient model" aircraft over '
                    'the future. We also assume that a third manufacturer enters the market '
                    '(possibly COMAC or UAC) in 2025 and produces first single aisle then twin '
                    'aisle aircraft of competitive quality.  100 aircraft per year are '
                    'retrofitted to equivalent new-aircraft efficiency. Each aircraft in the '
                    'fleet is assumed to work around  an average number of passenger-km per year '
                    'according to an estimate for each of single aisle and twin aisle from our '
                    'brief schedule calculations including downtime for maintenance checks, and '
                    'new models are 18% more efficient). We assume that the production rate of '
                    'the big players remains constant, but that the newcomer increases '
                    'production annually. Global Load factor of solution aircraft increases to '
                    '83% (current US average). '
                    ),
                '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': True,
                'description': (
                    'Taking the production rate of aircraft  by the two major suppliers - Airbus '
                    'and Boeing, we project the production of "efficient model" aircraft over '
                    'the future. We also assume that a third manufacturer enters the market '
                    '(possibly COMAC or UAC) in 2025 and produces first single aisle then twin '
                    'aisle aircraft of competitive quality.  1000 aircraft per year are '
                    'retrofitted to equivalent new-aircraft efficiency. Each aircraft in the '
                    'fleet is assumed to work around  an average number of passenger-km per year '
                    'according to an estimate for each of single aisle and twin aisle from our '
                    'brief schedule calculations including downtime for maintenance checks, and '
                    'new models are 20% more efficient). We assume that the production rate of '
                    'the big players remains constant, but that the newcomer increases '
                    'production annually. Global Load factor of solution aircraft increases to '
                    '83%. '
                    ),
                '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': False,
                'description': (
                    'Taking the production rate of aircraft  by the two major suppliers - Airbus '
                    'and Boeing, we project the production of aircraft switching to 100% '
                    '"efficient models" over the short future. Aircraft older than a certain '
                    'number of years (around 25) are retired. Each aircraft in the fleet is '
                    'assumed to work around  an average number of passenger-km per year '
                    'according to an estimate for each of single aisle and twin aisle from our '
                    'brief schedule calculations including downtime for maintenance checks. We '
                    'assume that the production rate of these players remains constant. '
                    ),
                'filename': THISDIR.joinpath('ca_pds_data', 'custom_pds_ad_Book_Ed_1_Scenario_1.csv')},
            {'name': 'Book Ed.1 Scenario 2', 'include': False,
                'description': (
                    'Taking the production rate of aircraft, and the estimated number of orders '
                    'for aircraft by the two major suppliers - Airbus and Boeing, we project the '
                    'production of aircraft switching to 100% "efficient models" over the short '
                    'future. We include a small number of retrofits which would be for engines, '
                    'lightweighting and other adjustments to make up the 15% efficiency '
                    'improvement expected from a whole new aircraft. Aircraft older than a '
                    'certain number of years (around 25) are retired. Each aircraft in the fleet '
                    'is assumed to work around  an average number of passenger-km per year '
                    'according to an estimate for each of single aisle and twin aisle from our '
                    'brief schedule calculations including downtime for maintenance checks. We '
                    'assume that the production rate of these players remains constant, but that '
                    'an additional competitive manufacturer is able to add to production later '
                    'in 2025(for single aisle)/2035(for twin aisle) and produce comparable '
                    'aircraft. '
                    ),
                '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=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': 'Reference Based on Historical Aircraft Deliveries of Airbus, Boeing', 'include': True,
                'description': (
                    'Historical deliveries of efficient aircraft have been collected from the '
                    'aircraft manufacturers themselves and the delivery data each year are used '
                    'to estimate adoption assuming certain work done by each aircraft (single '
                    'aisle and twin aisle estimated separately). The historical data from 2014 '
                    'and mid-2019 (assumed to apply to 2018) are used and the adoption of the '
                    'TAM in 2018 (in percentage terms) is assumed to continue fixed for the '
                    'future. '
                    ),
                'filename': THISDIR.joinpath('ca_ref_data', 'custom_ref_ad_Reference_based_on_Historical_Aircraft_Deliveries_of_Airbus_Boeing.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[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,
            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)
Пример #23
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 2014 6DS':
                THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2014_6DS.csv'),
            },
            'Conservative Cases': {
                'Based on: IEA ETP 2014 4DS':
                THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2014_4DS.csv'),
            },
            'Ambitious Cases': {
                'Based on: IEA ETP 2014 2DS':
                THISDIR.joinpath('tam', 'tam_based_on_IEA_ETP_2014_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()

        # Custom PDS Data
        wb = xlrd.open_workbook(filename=THISDIR.joinpath('trucksdata.xlsx'))
        adoption1 = pd.read_excel(io=wb,
                                  sheet_name='AdoptionFactoring1',
                                  header=0,
                                  index_col=0,
                                  usecols='B:C',
                                  dtype='float',
                                  engine='xlrd',
                                  skiprows=11,
                                  nrows=51)
        adoption2 = pd.read_excel(io=wb,
                                  sheet_name='AdoptionFactoring2',
                                  header=0,
                                  index_col=0,
                                  usecols='B:H,J:M',
                                  dtype='float',
                                  engine='xlrd',
                                  skiprows=10,
                                  nrows=50)
        adoption3 = pd.read_excel(io=wb,
                                  sheet_name='AdoptionFactoring3',
                                  header=0,
                                  index_col=0,
                                  usecols='B:D',
                                  dtype='float',
                                  engine='xlrd',
                                  skiprows=9,
                                  nrows=51)

        ds1_df = pd.DataFrame(index=range(2012, 2061), columns=dd.REGIONS)
        ds1_df['World'] = adoption1.loc[2014:, 'Global']

        ds2_df = adoption2.loc[2012:2060].dropna(axis=0).rename(
            axis='columns',
            mapper={
                'Asia (sans Japan)': 'Asia (Sans Japan)',
                'Middle East & Africa': 'Middle East and Africa',
                'OECD': 'OECD90',
                'EU27': 'EU'
            }).fillna(0.0)
        ds2_df.index = ds2_df.index.astype(int)

        ds3_df = pd.DataFrame(index=range(2012, 2061), columns=dd.REGIONS)
        ds3_df['World'] = adoption3['Adoption tonne-km']

        # Excel Custom PDS Adoption overrides these with real data
        for df in [ds1_df, ds2_df, ds3_df]:
            df.loc[2014, 'World'] = 304732.461811978
            df.loc[2015, 'World'] = 475099.277763475
            df.loc[2016, 'World'] = 660286.809851347
            df.loc[2017, 'World'] = 853343.225192547
            df.loc[2018, 'World'] = 1055789.45303526

        ca_pds_data_sources = [
            {
                'name':
                'PDS1 - Based on ICCT+RMI Freight Work Adoption estimates',
                'include':
                True,
                'description':
                ('ICCT estimates the total freight work each five years, and RMI estimates '
                 'that by 2050 50% of trucks globally may have efficient technologies. We '
                 "therefore interpolate and extrapolate ICCT's freight work data and project "
                 'linear adoption globally from current adoption of truck freight work '
                 "(approximately 5%) to RMI's projection in 2050. "),
                'dataframe':
                ds1_df
            },
            {
                'name':
                'PDS2 - Based on an ICCT Truck Sales extrapolation',
                'include':
                True,
                'description':
                ("We use the number of truck sales estimated for each of ICCT's 16 regions "
                 '(interpolated and extrapolated for each) to estimate the number of truck '
                 'with efficiency packages installed. ICCT has an estimate of the year when '
                 'truck fuel efficiency legislation becomes mandatory for each region. '
                 ),
                'dataframe':
                ds2_df
            },
            {
                'name':
                'PDS3 - Based on IEA Freight Work - 100% Adoption of Trucks by 2035',
                'include':
                True,
                'description':
                ("IEA's estimated Truck freight work data are interpolated and extrapolated "
                 'and we apply an increasing fraction of adoption rising to 100% in 2050. '
                 ),
                'dataframe':
                ds3_df
            },
            {
                'name':
                'Book Ed.1 Scenario 1',
                'include':
                False,
                'description':
                ('ICCT estimates the total freight work each five years, and RMI estimates '
                 'that by 2050 50% of trucks globally may have efficient technologies. We '
                 "therefore interpolate and extrapolate ICCT's freight work data and project "
                 'linear adoption globally from current adoption of truck freight work '
                 "(approximately 5%) to RMI's projection in 2050. "),
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Book_Ed_1_Scenario_1.csv')
            },
            {
                'name':
                'Book Ed.1 Scenario 3',
                'include':
                False,
                'description':
                ('IEA"s estimated Truck freight work data are interpolated and extrapolated '
                 'and we apply an increasing fraction of adoption rising to 100% (of global '
                 'truck freight market only) in 2050. '),
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Book_Ed_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=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 Reference Scenario',
                'include':
                True,
                'description':
                ('This scenario uses the inputs that were used for the Scenario developed for '
                 'the Drawdown Book Edition 1. The scenario assumes a fixed percent of the '
                 'TAM is adopted for Efficient trucks as the TAM grows. '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Drawdown_Book_Reference_Scenario.csv')
            },
            {
                'name':
                'Efficient Truck Share of Market is Fixed',
                'include':
                True,
                'description':
                ('Drawdown calculations for REF adoption of Efficient Trucks based on fixed '
                 'percent of growth of trucking. The 2014 - 2018 values are taken from '
                 'estimates of historical data '),
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Efficient_Truck_Share_of_Market_is_Fixed.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(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=True,
            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)
Пример #24
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 = {}
        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':
                'Constant degradation rate, 100% adoption by 2050, linear',
                'include':
                True,
                'description':
                ('The TLA_Envelope sheet was used to compute the annual degradation of the '
                 'wetland.  The annual protection rate was adjusted so that 100% of the '
                 'remaining wetlands in 2050 were protected.  This adoption is less than 100% '
                 'of the wetlands in 2014. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Constant_degradation_rate_100_adoption_by_2050_linear.csv'
                )
            },
            {
                'name':
                'Constant degradation rate, 80% adoption by 2050, linear',
                'include':
                True,
                'description':
                ('The TLA_Envelope sheet was used to compute the annual degradation of the '
                 'wetland.  The annual protection rate was adjusted so that 80% of the '
                 'remaining wetlands in 2050 were protected.  This is the same as Scenario 1 '
                 'except for a smaller percentage protected by 2050. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Constant_degradation_rate_80_adoption_by_2050_linear.csv'
                )
            },
            {
                'name':
                'Constant degradation rate, 100% adoption by 2030, linear',
                'include':
                True,
                'description':
                ('The TLA_Envelope sheet was used to compute the annual degradation of the '
                 'wetland.  The annual protection rate was adjusted so that 100% of the '
                 'remaining wetlands in 2030 were protected.  Because there is 100% '
                 'protection in 2030, all values after that are constant. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Constant_degradation_rate_100_adoption_by_2030_linear.csv'
                )
            },
            {
                'name':
                'Constant degradation rate, 80% adoption by 2030, linear',
                'include':
                True,
                'description':
                ('The TLA_Envelope sheet was used to compute the annual degradation of the '
                 'wetland.  The annual protection rate was adjusted so that 80% of the '
                 'remaining wetlands in 2030 were protected.  Because there is only 80% '
                 'protection in 2030 linear interpolation was used to bridge the 2014, 2030, '
                 'and 2050 values. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Constant_degradation_rate_80_adoption_by_2030_linear.csv'
                )
            },
            {
                'name':
                'Variable degradation rate, 100% adoption by 2050, linear',
                'include':
                True,
                'description':
                ('The TLA_Envelope sheet was used to compute the annual degradation of the '
                 'wetland.  The annual protection rate was adjusted so that 100% of the '
                 'remaining wetlands in 2050 were protected.  This adoption is less than 100% '
                 'of the wetlands in 2014.  This is the same as Scenario 1 except an annual '
                 'reduction in degradation rate is applied. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Variable_degradation_rate_100_adoption_by_2050_linear.csv'
                )
            },
            {
                'name':
                'Variable degradation rate, 80% adoption by 2050, linear',
                'include':
                True,
                'description':
                ('The TLA_Envelope sheet was used to compute the annual degradation of the '
                 'wetland.  The annual protection rate was adjusted so that 80% of the '
                 'remaining wetlands in 2050 were protected.  This is the same as Scenario 5 '
                 'except for a smaller percentage protected by 2050. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Variable_degradation_rate_80_adoption_by_2050_linear.csv'
                )
            },
            {
                'name':
                'Variable degradation rate, 100% adoption by 2030, linear',
                'include':
                True,
                'description':
                ('The TLA_Envelope sheet was used to compute the annual degradation of the '
                 'wetland.  The annual protection rate was adjusted so that 100% of the '
                 'remaining wetlands in 2030 were protected.  Because there is 100% '
                 'protection in 2030, all values after that are constant. This is the same as '
                 'Scenario 3 except a variable degradation rate is used. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Variable_degradation_rate_100_adoption_by_2030_linear.csv'
                )
            },
            {
                'name':
                'Variable degradation rate, 80% adoption by 2030, linear',
                'include':
                True,
                'description':
                ('The TLA_Envelope sheet was used to compute the annual degradation of the '
                 'wetland.  The annual protection rate was adjusted so that 80% of the '
                 'remaining wetlands in 2030 were protected.  Because there is only 80% '
                 'protection in 2030 linear interpolation was used to bridge the 2014, 2030, '
                 'and 2050 values.  This scenario is the same as Scenario 4 except a variable '
                 'degradation rate is used. '),
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Variable_degradation_rate_80_adoption_by_2030_linear.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)

        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=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=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)
Пример #25
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_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 IEEJ Outlook - 2019, Ref Scenario':
                THISDIR.joinpath(
                    'ad', 'ad_based_on_IEEJ_Outlook_2019_Ref_Scenario.csv'),
                'Based on IRENA (2018), Roadmap-2050, Reference Case':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_IRENA_2018_Roadmap2050_Reference_Case.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 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 Grantham Institute and Carbon Tracker (2017) Strong PV Scenario':
                THISDIR.joinpath(
                    'ad',
                    'ad_based_on_Grantham_Institute_and_Carbon_Tracker_2017_Strong_PV_Scenario.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'),
            },
            '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)

        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=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)
Пример #26
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 = {}
        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
        w_2018 = self.ac.ref_base_adoption['World']
        w_2050 = self.tla_per_region.loc[2050, 'World']

        ca_pds_data_sources = [
            {
                'name':
                'International Pledges, Low Growth (Linear trend)',
                'include':
                True,
                'description':
                ('In the absence of accurate studies predicting future adoption of '
                 'multistrata agroforests, Drawdown evaluated current pledges for the '
                 'conversion of degraded land to protect land or buffer as part of the Bonn '
                 'Challenge and NY deceleration. (See hidden "Adoption - Multistrata" data- '
                 'sheet for a breakdown of calculation). Based on these pledges, projected '
                 'low-growth adoption was set at 10%. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, w_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2050, w_2018 + (0.1 * w_2050), 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')
            },
            {
                'name':
                'Medium, linear trend',
                'include':
                True,
                'description':
                ('In the absence of accurate studies predicting future adoption of '
                 'multistrata agroforests, Drawdown evaluated current pledges for the '
                 'conversion of degraded land to protect land or buffer as part of the Bonn '
                 'Challenge and NY deceleration. (See hidden "Adoption - Multistrata" data- '
                 'sheet for a breakdown of calculation). Based on these pledges, projected '
                 'low-growth adoption was set at 20%. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, w_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2050, w_2018 + (0.2 * w_2050), 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')
            },
            {
                'name':
                'High, linear trend',
                'include':
                True,
                'description':
                ('In the absence of accurate studies predicting future adoption of '
                 'multistrata agroforests, Drawdown evaluated current pledges for the '
                 'conversion of degraded land to protect land or buffer as part of the Bonn '
                 'Challenge and NY deceleration. (See hidden "Adoption - Multistrata" data- '
                 'sheet for a breakdown of calculation). Based on these pledges, projected '
                 'low-growth adoption was set at 30%. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, w_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2050, w_2018 + (0.3 * w_2050), 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')
            },
            {
                'name':
                'Low, early adoption, linear trend',
                'include':
                True,
                'description':
                ('This is Scenario 1 with 70% adoption by 2030 '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, w_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2030, w_2018 + (0.07 * w_2050), 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2050, w_2018 + (0.1 * w_2050), 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')
            },
            {
                'name':
                'Medium, early adoption, linear trend',
                'include':
                True,
                'description':
                ('This is Scenario 2 with 70% adoption by 2030 '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, w_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2030, w_2018 + (0.14 * w_2050), 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2050, w_2018 + (0.2 * w_2050), 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')
            },
            {
                'name':
                'High, early adoption, linear trend',
                'include':
                True,
                'description':
                ('This is Scenario 3 with 70% adoption by 2030 '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, w_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2030, w_2018 + (0.21 * w_2050), 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2050, w_2018 + (0.3 * w_2050), 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')
            },
            {
                'name':
                'Max growth, linear trend',
                'include':
                False,
                'description':
                ('This is the Drawdown Optimum scenario, assuming 100% adoption of '
                 'Multistrata Agroforestry in the allocated TLA. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, w_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2050, w_2018 + (1.0 * w_2050), 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, 'World'] = 0.0001

        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=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=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)
Пример #27
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': {
          '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)
Пример #28
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:
            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
        ad_vma = VMAs['Future adoption (million hectares)']
        ad_cached = self.ac.lookup_vma(
            vma_title='Future adoption (million hectares)')
        adoption_2050_mean = ad_cached if ad_cached else ad_vma.avg_high_low(
            key='mean')
        adoption_2050_high = ad_vma.avg_high_low(key='high')

        ca_pds_data_sources = [
            {
                'name':
                'Average growth, linear trend',
                'include':
                True,
                # In this scenario, the future adoption of the solution was based on the average
                # percent future adoption of perennial bioenergy crops as derived from the VMA sheet.
                'datapoints':
                pd.DataFrame([
                    [
                        2014, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2018, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2050, adoption_2050_mean, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Medium growth, linear trend',
                'include':
                True,
                # In this scenario, the future adoption of the solution was based on the high
                # percent future adoption of perennial bioenergy crops as derived from the VMA sheet.
                'datapoints':
                pd.DataFrame([
                    [
                        2014, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2018, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2050, adoption_2050_high, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Max growth, linear trend',
                'include':
                True,
                # This scenario assumes that perennial bioenergy crops will be cultivated on
                # 100% of the total land allocated to this solution by 2050.
                'datapoints':
                pd.DataFrame([
                    [
                        2014, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2018, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2050, self.tla_per_region.loc[2050, 'World'], 0., 0.,
                        0., 0., 0., 0., 0., 0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Average early growth, linear trend',
                'include':
                True,
                # This is scenario 1, with the assumption that 70% of the total adoption will
                # be achieved by 2030.
                'datapoints':
                pd.DataFrame([
                    [
                        2014, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2018, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2030, 0.7 * adoption_2050_mean, 0., 0., 0., 0., 0., 0.,
                        0., 0., 0.
                    ],
                    [
                        2050, adoption_2050_mean, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Medium early growth, linear trend',
                'include':
                True,
                # This is scenario 2, with the assumption that 70% of the total adoption will
                # be achieved by 2030.
                'datapoints':
                pd.DataFrame([
                    [
                        2014, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2018, self.ac.ref_base_adoption['World'], 0., 0., 0.,
                        0., 0., 0., 0., 0., 0.
                    ],
                    [
                        2030, 0.7 * adoption_2050_high, 0., 0., 0., 0., 0., 0.,
                        0., 0., 0.
                    ],
                    [
                        2050, adoption_2050_high, 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=None)

        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=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,
            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
    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: CES ITU AMPERE Baseline':
                THISDIR.joinpath('tam',
                                 'tam_based_on_CES_ITU_AMPERE_Baseline.csv'),
                'Based on: CES ITU AMPERE 550':
                THISDIR.joinpath('tam', 'tam_based_on_CES_ITU_AMPERE_550.csv'),
                'Based on: CES ITU AMPERE 450':
                THISDIR.joinpath('tam', 'tam_based_on_CES_ITU_AMPERE_450.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':
                'Aggressive, Low',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Aggressive_Low.csv')
            },
            {
                'name':
                'Conservative, Low',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Conservative_Low.csv')
            },
            {
                'name':
                'Aggressive, high',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Aggressive_high.csv')
            },
            {
                'name':
                'Aggressive, high, early',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Aggressive_high_early.csv')
            },
            {
                'name':
                'Drawdown Book Ed.1 Scenario 1',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Book_Ed_1_Scenario_1.csv')
            },
            {
                'name':
                'Drawdown Book Ed.1 Scenario 2',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Book_Ed_1_Scenario_2.csv')
            },
            {
                'name':
                'Drawdown Book Ed.1 Scenario 3',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Drawdown_Book_Ed_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(
            [3.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.7, 2.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=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)
Пример #30
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',
                '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)