Esempio n. 1
0
def test_populate_solution_land_allocation():
    trr_aez = aez.AEZ('Tropical Forest Restoration')
    assert trr_aez.soln_land_alloc_df.loc['Tropical-Humid',
            'AEZ3: Forest, good, moderate'] == pytest.approx(0.245464949942429)
    zero_rows = trr_aez.soln_land_alloc_df.iloc[[1, 3, 4, 5]].sum().sum()  # these should be all 0
    assert zero_rows == 0
    trr_aez = aez.AEZ('Peatland Protection', cohort=2019)
    assert trr_aez.soln_land_alloc_df.loc['Tropical-Humid',
            'AEZ3: Forest, good, moderate'] == pytest.approx(0.10591729011599778)
Esempio n. 2
0
def test_populate_world_land_allocation():
    trr_aez = aez.AEZ('Tropical Forest Restoration')
    tsa_df = trr_aez.world_land_alloc_dict['Tropical-Semi-Arid']
    assert tsa_df.loc['China',
            'AEZ5: Forest, marginal, minimal'] == pytest.approx(0.6833171383331640)
    trr_aez = aez.AEZ('Tropical Forest Restoration', cohort=2019)
    tsa_df = trr_aez.world_land_alloc_dict['Tropical-Semi-Arid']
    assert tsa_df.loc['China',
            'AEZ5: Forest, marginal, minimal'] == pytest.approx(0.7322819187332402)
Esempio n. 3
0
def test_populate_solution_land_distribution():
    trr_aez = aez.AEZ('Tropical Forest Restoration')
    assert trr_aez.soln_land_dist_df.loc['Global', 'All'] == pytest.approx(303.9980581327790)
    result = trr_aez.soln_land_dist_df.loc['Latin America', 'Tropical-Humid']
    assert result == pytest.approx(129.598434)
    result = trr_aez.soln_land_dist_df.loc['Eastern Europe', 'Tropical-Semi-Arid']
    assert result == pytest.approx(21.689457)
Esempio n. 4
0
def test_tropical_tree_staples():
    ae = aez.AEZ('Tropical Tree Staples')
    expected = pd.DataFrame(
        tropical_tree_staples_land_distribution_list[1:],
        columns=tropical_tree_staples_land_distribution_list[0]).set_index(
            'Region')
    result = ae.soln_land_dist_df
    pd.testing.assert_frame_equal(result, expected, check_exact=False)
Esempio n. 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':
                'Linear trend based on Zomers  >30% tree cover percent area applied in grassland area',
                'include':
                True,
                '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':
                True,
                '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':
                'Medium growth, linear trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Medium_growth_linear_trend.csv')
            },
            {
                'name':
                'High growth, linear trend',
                'include':
                False,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_High_growth_linear_trend.csv')
            },
            {
                'name':
                'Low growth, linear trend (based on improved pasture area)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Low_growth_linear_trend_based_on_improved_pasture_area.csv'
                )
            },
            {
                'name':
                'High growth, linear trend (based on improved pasture area)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_High_growth_linear_trend_based_on_improved_pasture_area.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=0.5,
            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(
            [314.15, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (
            ht_ref_adoption_initial / self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2014] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_regions, ht_percentages = zip(
            *self.ac.pds_adoption_final_percentage)
        ht_pds_adoption_final_percentage = pd.Series(list(ht_percentages),
                                                     index=list(ht_regions))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        self.ht = helpertables.HelperTables(
            ac=self.ac,
            ref_datapoints=ht_ref_datapoints,
            pds_datapoints=ht_pds_datapoints,
            pds_adoption_data_per_region=pds_adoption_data_per_region,
            ref_adoption_limits=self.tla_per_region,
            pds_adoption_limits=self.tla_per_region,
            pds_adoption_trend_per_region=pds_adoption_trend_per_region,
            pds_adoption_is_single_source=pds_adoption_is_single_source)

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

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

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

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

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

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution())
Esempio n. 6
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)
Esempio n. 7
0
def test_tropical_tree_staples():
    ae = aez.AEZ('Tropical Tree Staples')
    result = ae.soln_land_dist_df
    assert result is not None
Esempio n. 8
0
def test_applicable_zones():
    trr_aez = aez.AEZ('Tropical Forest Restoration')
    assert len(trr_aez.applicable_zones) == 18
    assert 'AEZ27: Rainfed Cropland, marginal, moderate' in trr_aez.applicable_zones
Esempio n. 9
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)
Esempio n. 10
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)
Esempio n. 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)
        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())
Esempio n. 12
0
def test_populate_solution_land_distribution():
    trr_aez = aez.AEZ('Tropical Forest Restoration')
    assert trr_aez.soln_land_dist_df.loc['Global', 'All'] == pytest.approx(303.9980581327790)
Esempio n. 13
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
        tla_2050 = self.tla_per_region.loc[2050]
        total_grazing_area = 2700.0

        ds1_percentages = pd.Series([
            0.0, 0.413624302911244, 0.0, 0.070550343761321, 0.138183856774756,
            0.845901090636972, 0.0, 0.0, 0.0, 0.0
        ],
                                    index=dd.REGIONS)
        ds1_2050 = tla_2050 * ds1_percentages
        ds1_2050['World'] = ds1_2050.sum()

        ds2_percentages = pd.Series([
            0.0, 0.596920577658838, 0.0, 0.0836983623713848, 0.178254518319696,
            0.933216308519849, 0.0, 0.0, 0.0, 0.0
        ],
                                    index=dd.REGIONS)
        ds2_2050 = tla_2050 * ds2_percentages
        ds2_2050['World'] = ds2_2050.sum()

        ds3_percentages = pd.Series([
            0.494785212286615, 0.494785212286615, 0.0, 0.0743985443301198,
            0.153620863162148, 0.853238399576085, 0.0, 0.0, 0.0, 0.0
        ],
                                    index=dd.REGIONS)
        ds3_2050 = tla_2050 * ds3_percentages

        # Data source 4 is described as scenario 1 with 70% adoption by 2030, but in actual
        # implementation it does not make the World be a sum of the regions. Instead, it
        # makes the World use the percentage of the OECD90 region.
        ds4_percentages = pd.Series([
            0.413624302911244, 0.413624302911244, 0.0, 0.070550343761321,
            0.138183856774756, 0.845901090636972, 0.0, 0.0, 0.0, 0.0
        ],
                                    index=dd.REGIONS)
        ds4_2050 = tla_2050 * ds4_percentages

        # Data source 5 is described as scenario 2 with 70% adoption by 2030, but in actual
        # implementation it does not make the World be a sum of the regions. Instead, it
        # makes the World use the percentage of the OECD90 region.
        ds5_percentages = pd.Series([
            0.596920577658838, 0.596920577658838, 0.0, 0.0836983623713848,
            0.178254518319696, 0.933216308519849, 0.0, 0.0, 0.0, 0.0
        ],
                                    index=dd.REGIONS)
        ds5_2050 = tla_2050 * ds5_percentages

        # SOURCE: Organic World 2009 Table 47, Organic World 2019 and FAOStat.
        # Region, Organic grazing area 2009 Mha, Organic grazing area 2009 %,
        #     Organic grazing area 2019 Mha, Organic grazing area 2019 %
        # Africa,        0.03,  0%,    0.08, 0%
        # Asia,          0.6,   0%,    1,    0%
        # EU,            2.1,   3%,    5.7,  8%
        # Latin America, 0.006, 0%,    4.9,  3%
        # N. America,    1.1,   0%,    1.4,  0%
        # Oceania,       11.7,  8%,    34.9, 24%
        # Global Total,  15.5,  0.50%, 48,   2%
        ds7_mha_2009 = 15.5
        ds7_mha_2019 = 48
        ds7_growth_rate = (ds7_mha_2019 - ds7_mha_2009) / (2019 - 2009)
        # Note that Excel says the ref_base_adoption is for 2018, when computing a growth
        # projection it uses it as 2014. We do the same here, bug-for-bug compatibility.
        ds7_2050 = self.ac.ref_base_adoption['World'] + (ds7_growth_rate *
                                                         (2050 - 2014))

        # Costa Rica proposes a 20-40% increase in 20 years; increase managed grazing
        # area by 1-2% per year (Navarro 2015).
        ds8_2050 = 0.4 * total_grazing_area

        # Brazil INDC proposes to restore 15 Mha of degraded grassland, (20% of national
        # grazing area), (Federative Republic of Brazil 2015)
        ds9_2050 = 0.2 * total_grazing_area

        # Sá (2016) projects an increase in restoration of degraded pasture in Latin America
        # from 10Mha in 2015 to 20Mha in 2020. That’s 11% of 177.4 Mha grazing land for
        # South America (FAOstat 2019)
        ds10_2050 = 0.11 * total_grazing_area

        ca_pds_data_sources = [
            {
                'name':
                'Low Growth, Linear Trend',
                'include':
                True,
                # The adoption of managed grazing is projected based on weighted "average, medium,
                # and high" growth rates, calculated based on the available country specifc area
                # under managed grazing and the region specific total grazing area (Using Henderson
                # et al 2015 estimates). This scenario builds the future projection based on the
                # low growth rate.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2050] + ds1_2050.tolist(),
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'High Growth, Linear Trend',
                'include':
                True,
                # The adoption of managed grazing is projected based on weighted "average, medium,
                # and high" growth rates, calculated based on the available country specifc area
                # under managed grazing and the region specific total grazing area (Using Henderson
                # et al 2015 estimates). This scenario builds the future projection based on the
                # high growth rate.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2050] + ds2_2050.tolist(),
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Medium Growth, Linear Trend',
                'include':
                True,
                # The adoption of managed grazing is projected based on weighted "average, medium,
                # and high" growth rates, calculated based on the available country specifc area
                # under managed grazing and the region specific total grazing area (Using Henderson
                # et al 2015 estimates). This scenario builds the future projection based on the
                # medium growth rate.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2050] + ds3_2050.tolist(),
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Low High Early Growth, Linear Trend',
                'include':
                True,
                # This is scenario 1 with 70% adoption by 2030.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2030] + (0.7 * ds4_2050).tolist(),
                    [2050] + ds4_2050.tolist(),
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'High High Early Growth, Linear Trend',
                'include':
                True,
                # This is scenario 2 with 70% adoption by 2030.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2030] + (0.7 * ds5_2050).tolist(),
                    [2050] + ds5_2050.tolist(),
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Medium High Early Growth, Linear Trend',
                'include':
                True,
                # This is scenario 3 with 70% adoption by 2030.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2030] + (0.7 * ds3_2050).tolist(),
                    [2050] + ds3_2050.tolist(),
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Linear growth, based on Organic Grazing Historic Growth',
                'include':
                True,
                # The future adoption of managed grazing is projected based on the organic
                # grazing historic growth rate using the linear trend.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [2050] +
                    [ds7_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':
                'Future commitments, max growth',
                'include':
                True,
                # Future adoption of managed grazing is projected based on the country/regional
                # commitments as given in the table below. It is assumed that the country/regional
                # level trends will be adopted at the global level. This scenario is based on the
                # high end commitments given for the Costa Rica.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [
                        2050, ds8_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':
                'Future Commitments, moderate growth',
                'include':
                True,
                # Future adoption of managed grazing is projected based on the country/regional
                # commitments as given in the table below. It is assumed that the country/regional
                # level trends will be adopted at the global level. This scenario is based on the
                # high end commitments given for the Brazil.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [
                        2050, ds9_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':
                'Future Commitments, low growth',
                'include':
                True,
                # Future adoption of managed grazing is projected based on the country/regional
                # commitments as given in the table below. It is assumed that the country/regional
                # level trends will be adopted at the global level. This scenario is based on the
                # high end commitments given for the Latin America.
                'datapoints':
                pd.DataFrame([
                    [2018] + list(self.ac.ref_base_adoption.values()),
                    [
                        2050, ds10_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] = [
                    71.6320447618946, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                    0.0
                ]

        ref_adoption_data_per_region = None

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

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

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

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

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

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

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

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
Esempio n. 14
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_world_2050 = self.tla_per_region.loc[2050, 'World']
        ad_2018 = self.ac.ref_base_adoption['World']

        # Data Source 4-5
        # Zomer et al. 2014; Zomer, R. J., Trabucco, A., Coe, R., Place, F.,
        # Van Noordwijk, M., & Xu, J. C. (2014). Trees on farms: an update and
        # reanalysis of agroforestry’s global extent and socio-ecological characteristics.
        # World Agroforestry Center Working Paper, 179.
        ds5_adoption = ad_2018
        for y in range(2015, 2049):
            ds5_adoption = ds5_adoption * (1 + 0.0128)
        # In Excel, the 2018 adoption is used as 2014 and the 2048 adoption is used as 2050.
        ds5_ad_2050 = ds5_adoption

        # Data Source 6-9
        # Thomson et al. 2018; Thomson, A., Misselbrook, T., Moxley, J., Buys, G.,
        # Evans, C., Malcolm, H., ... & Reinsch, S. (2018). Quantifying the impact
        # of future land use scenarios to 2050 and beyond. Final report.
        ds6_cropland_percent = 0.05
        global_cropland = 1411.0
        remaining_cropland = global_cropland - ad_2018
        ds6_ad_2018 = 248.0  # No idea why ds6 uses a different adoption in 2018
        ds6_ad_2050 = (remaining_cropland * ds6_cropland_percent) + ds6_ad_2018
        ds7_cropland_percent = 0.1
        ds7_ad_2050 = (remaining_cropland * ds7_cropland_percent) + ad_2018
        ds8_cropland_percent = 0.2
        ds8_ad_2050 = (remaining_cropland * ds8_cropland_percent) + ad_2018
        ds9_cropland_percent = 0.39
        ds9_ad_2050 = (remaining_cropland * ds9_cropland_percent) + ad_2018

        ca_pds_data_sources = [
            {
                'name':
                'Medium, linear growth',
                'include':
                False,
                'description':
                ('Due to the unavailability of any historical data or future prognostication, '
                 'we have assumed a 75% adoption of the solution under this scenario. '
                 ),
                'maximum':
                tla_world_2050,
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [
                        2050, 0.75 * tla_world_2050, 0., 0., 0., 0., 0., 0.,
                        0., 0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'High, linear growth',
                'include':
                False,
                'description':
                ('Due to the unavailability of any historical data or future prognostication, '
                 'we have assumed a 90% adoption of the solution under this scenario. '
                 ),
                'maximum':
                tla_world_2050,
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [
                        2050, 0.9 * tla_world_2050, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Max, linear growth',
                'include':
                True,
                'description':
                ('Due to the unavailability of any historical data or future prognostication, '
                 'we have assumed a 100% adoption of the solution under this scenario. '
                 ),
                'maximum':
                tla_world_2050,
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [
                        2050, 1.0 * tla_world_2050, 0., 0., 0., 0., 0., 0., 0.,
                        0., 0.
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                '0.64% annual adoption increase based on Zomer 2014 global increase rates of <20% tree cover on cropland',
                'include':
                True,
                'description':
                ('Linear projection based on current global increase rates of tree cover '
                 'greater than 10% on cropland, as calculated based on Zomer et al. (2014) '
                 'data. Percent of agricultural land under >10% and >20% tree cover in 2000 '
                 "and 2010 was calculated (see 'Zomer2014-CurrentAdoption' sheet). We "
                 'compared this to total global cropland (1473 Mha according to GAEZ zones) '
                 'and calculated a global increase in 10-20% tree cover on cropland of 6.4% '
                 'from 2000 - 2010, which was converted to an annual increase rate of 0.64 % '
                 'for this scenario. '),
                'maximum':
                tla_world_2050,
                'growth_initial':
                pd.DataFrame(
                    [[2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.]],
                    columns=ca_pds_columns).set_index('Year'),
                'growth_rate':
                0.0064
            },
            {
                'name':
                '1.28% annual adoption increase based on Zomer 2014 global increase rates of <10% tree cover on cropland',
                'include':
                True,
                'description':
                ('Linear projection based on current global increase rates of tree cover '
                 'greater than 10% on cropland, as calculated based on Zomer et al. (2014) '
                 'data. Percent of agricultural land under >10% and >20% tree cover in 2000 '
                 "and 2010 was calculated (see 'Zomer2014-CurrentAdoption' sheet). We "
                 'compared this to total global cropland (1473 Mha according to GAEZ zones) '
                 'and calculated a global increase in 10-20% tree cover on cropland of 6.4% '
                 'from 2000 - 2010, which was doubled and converted to an annual increase '
                 'rate of 1.28 % for this scenario. '),
                'maximum':
                tla_world_2050,
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds5_ad_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Low conversion of remaining cropland by 2050 (5% - UK medium ambition scenario)',
                'include':
                True,
                'description':
                ('Linear projection based on the projected rate of 5% conversion of remaining '
                 'cropland by 2050 as reported by Thomson et al. (2018) for UK projections of '
                 'future land-use change. Total remaining global cropland in 2014 is '
                 'estimated at 1225 Mha, which was calculated based on the difference between '
                 'total current cropland of 1473 Mha and the total global area already under '
                 'tree intercropping. '),
                'maximum':
                tla_world_2050,
                'datapoints':
                pd.DataFrame([
                    [2018, ds6_ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds6_ad_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Medium conversion of remaining cropland by 2050 (10% - UK medium ambition scenario)',
                'include':
                True,
                'description':
                ('Linear projection based on the projected rate of 10% conversion of '
                 'remaining cropland by 2050 as reported by Thomson et al. (2018) for UK '
                 'projections of future land-use change. Total remaining global cropland in '
                 '2014 is estimated at 1225 Mha, which was calculated based on the difference '
                 'between total current cropland of 1473 Mha and the total global area '
                 'already under tree intercropping. '),
                'maximum':
                tla_world_2050,
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds7_ad_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'High conversion of remaining cropland by 2050 (20%)',
                'include':
                True,
                'description':
                ('Linear projection estimating a medium current adoption rate of 20% of tree '
                 'intercropping on remaining global cropland. Total remaining global cropland '
                 'in 2014 is estimated at 1225 Mha, which was calculated based on the '
                 'difference between total current cropland of 1473 Mha and the total global '
                 'area already under tree intercropping. '),
                'maximum':
                tla_world_2050,
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds8_ad_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Very high conversion of remaining cropland by 2050 (39% - current adoption in EU)',
                'include':
                True,
                'description':
                ('Linear projection based on current adoption rate of tree intercropping on '
                 'cropland in the EU, which is 39% as reported in den Herder et al. (2017). '
                 'This rate was applied to all current remaining global cropland by 2050. '
                 'Total remaining global cropland in 2014 is estimated at 1225 Mha, which was '
                 'calculated based on the difference between total current cropland of 1473 '
                 'Mha and the total global area already under tree intercropping. '
                 ),
                'maximum':
                tla_world_2050,
                'datapoints':
                pd.DataFrame([
                    [2018, ad_2018, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                    [2050, ds9_ad_2050, 0., 0., 0., 0., 0., 0., 0., 0., 0.],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2012, 'World'] = 254.91717271225
            df.loc[2013, 'World'] = 256.900453733641
            df.loc[2014, 'World'] = 259.672330723017
            df.loc[2015, 'World'] = 261.743911973822
            df.loc[2016, 'World'] = 263.820565911005
            df.loc[2017, 'World'] = 265.901052727049
            df.loc[2018, 'World'] = 267.984718062521

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

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

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

        ht_ref_adoption_initial = pd.Series(list(
            self.ac.ref_base_adoption.values()),
                                            index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (
            ht_ref_adoption_initial / self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[2018] = ht_ref_adoption_initial
        ht_ref_datapoints.loc[2050] = ht_ref_adoption_final.fillna(0.0)
        ht_pds_adoption_initial = ht_ref_adoption_initial
        ht_pds_adoption_final_percentage = pd.Series(
            list(self.ac.pds_adoption_final_percentage.values()),
            index=list(self.ac.pds_adoption_final_percentage.keys()))
        ht_pds_adoption_final = ht_pds_adoption_final_percentage * self.tla_per_region.loc[
            2050]
        ht_pds_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_pds_datapoints.loc[2014] = ht_pds_adoption_initial
        ht_pds_datapoints.loc[2050] = ht_pds_adoption_final.fillna(0.0)
        use_first_pds_datapoint_main = False
        if (self.ac.name == 'PDS-100p2050-Optimum'
                or self.ac.name == 'PDS-100p2050-Optimum-Jan2019'
                or self.ac.name == 'PDS-97p2050-Drawdown-Jan2019'):
            use_first_pds_datapoint_main = True
        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=use_first_pds_datapoint_main,
            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)
Esempio n. 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)
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution())

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE',
                'NOTE'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Raw Data for ALL LAND TYPES': {
                'FAOSTAT (Sum of all Regions)':
                THISDIR.joinpath('ad', 'ad_FAOSTAT_Sum_of_all_Regions.csv'),
                'Prestele baseline and Topdown (moderate growth) projection':
                THISDIR.joinpath(
                    'ad',
                    'ad_Prestele_baseline_and_Topdown_moderate_growth_projection.csv'
                ),
                'Prestele baseline and BottoUp: (maximum)':
                THISDIR.joinpath(
                    'ad', 'ad_Prestele_baseline_and_BottoUp_maximum.csv'),
            },
            'Region: OECD90': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT':
                    THISDIR.joinpath('ad', 'ad_FAOSTAT.csv'),
                    'Prestele baseline and Topdown (moderate growth) projection':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Prestele_baseline_and_Topdown_moderate_growth_projection.csv'
                    ),
                    'Prestele baseline and BottoUp: (maximum)':
                    THISDIR.joinpath(
                        'ad', 'ad_Prestele_baseline_and_BottoUp_maximum.csv'),
                },
            },
            'Region: Eastern Europe': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT':
                    THISDIR.joinpath('ad', 'ad_FAOSTAT.csv'),
                    'Prestele baseline and Topdown (moderate growth) projection':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Prestele_baseline_and_Topdown_moderate_growth_projection.csv'
                    ),
                    'Prestele baseline and BottoUp: (maximum)':
                    THISDIR.joinpath(
                        'ad', 'ad_Prestele_baseline_and_BottoUp_maximum.csv'),
                },
            },
            'Region: Asia (Sans Japan)': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT':
                    THISDIR.joinpath('ad', 'ad_FAOSTAT.csv'),
                    'Prestele baseline and Topdown (moderate growth) projection':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Prestele_baseline_and_Topdown_moderate_growth_projection.csv'
                    ),
                    'Prestele baseline and BottoUp: (maximum)':
                    THISDIR.joinpath(
                        'ad', 'ad_Prestele_baseline_and_BottoUp_maximum.csv'),
                },
            },
            'Region: Middle East and Africa': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT':
                    THISDIR.joinpath('ad', 'ad_FAOSTAT.csv'),
                    'Prestele baseline and Topdown (moderate growth) projection':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Prestele_baseline_and_Topdown_moderate_growth_projection.csv'
                    ),
                    'Prestele baseline and BottoUp: (maximum)':
                    THISDIR.joinpath(
                        'ad', 'ad_Prestele_baseline_and_BottoUp_maximum.csv'),
                },
            },
            'Region: Latin America': {
                'Raw Data for ALL LAND TYPES': {
                    'FAOSTAT':
                    THISDIR.joinpath('ad', 'ad_FAOSTAT.csv'),
                    'Prestele baseline and Topdown (moderate growth) projection':
                    THISDIR.joinpath(
                        'ad',
                        'ad_Prestele_baseline_and_Topdown_moderate_growth_projection.csv'
                    ),
                    'Prestele baseline and BottoUp: (maximum)':
                    THISDIR.joinpath(
                        'ad', 'ad_Prestele_baseline_and_BottoUp_maximum.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]
        ad_2018 = pd.Series(self.ac.ref_base_adoption)

        # % smallholder area, based on updates to smallholder area VMA sheet
        # (34.1% was estimated in Book Ed1)
        smallholder_land = 0.315909724971454
        large_farm_land = 1.0 - smallholder_land
        max_cons_ag_large_farm_tla = self.tla_per_region.loc[
            2050] * large_farm_land
        max_cons_ag_large_farm_tla[dd.SPECIAL_COUNTRIES] = 0.0
        ad_2080 = 1.5 * pd.Series(self.ac.ref_base_adoption)

        # Maximum technical potential adoption area available for CA out of the 685 Mha based
        # on percentage in Prestele et al 2018 (81.4%, bottom up, likely maximum future area)
        # Values used in 2017 Project Drawdown book publication.
        prestele_pct_book = pd.Series(
            [0., 0.3952, 0.1662, 0.1632, 0.1422, 0.7332, 0., 0., 0., 0.],
            index=dd.REGIONS)
        prestele_mult = 0.814
        prestele_ad_book = self.tla_per_region.loc[
            2050] * prestele_mult * prestele_pct_book

        # Data Source 1
        # Source: Refer sheet "PD regional CA annual adoption"
        if 'BookVersion' in self.ac.name:
            pct = pd.Series(
                [0., 0.3952, 0.1662, 0.1632, 0.1422, 0.7332, 0., 0., 0., 0.],
                index=dd.REGIONS)
        else:
            pct = pd.Series([
                0., 0.465683756524670, 0.169344179047277, 0.194261406995049,
                0.141859451675443, 0.712235299292505, 0., 0., 0., 0.
            ],
                            index=dd.REGIONS)
        ds1_poss_adopt_2050 = max_cons_ag_large_farm_tla * pct
        ds1_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds1_datapoints.loc[2018] = ad_2018
        ds1_datapoints.loc[2030] = (1.0 * ds1_poss_adopt_2050)
        ds1_datapoints.loc[2050] = (1.0 * ds1_poss_adopt_2050)
        ds1_datapoints.loc[2080] = ad_2080
        ds1_datapoints['World'] = 0.0
        ds1_datapoints['World'] = ds1_datapoints.sum(axis=1)

        # Data Source 2
        # Source: Refer sheet "PD regional CA annual adoption"
        if 'BookVersion' in self.ac.name:
            pct = pd.Series(
                [0., 0.7208, 0.4918, 0.4888, 0.4678, 1.0, 0., 0., 0., 0.],
                index=dd.REGIONS)
        else:
            pct = pd.Series([
                0., 0.791283756524669, 0.494944179047277, 0.519861406995050,
                0.467459451675442, 1.037835299292510, 0., 0., 0., 0.
            ],
                            index=dd.REGIONS)
        ds2_poss_adopt_2050 = max_cons_ag_large_farm_tla * pct
        ds2_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds2_datapoints.loc[2018] = ad_2018
        ds2_datapoints.loc[2030] = (1.0 * ds2_poss_adopt_2050)
        ds2_datapoints.loc[2050] = (1.0 * ds2_poss_adopt_2050)
        ds2_datapoints.loc[2080] = ad_2080
        ds2_datapoints['World'] = 0.0
        ds2_datapoints['World'] = ds2_datapoints.sum(axis=1)

        # Data Source 3
        # Source: Refer sheet "PD regional CA annual adoption"
        ds3_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds3_datapoints.loc[2018] = ad_2018
        ds3_datapoints.loc[2030] = (0.8 * max_cons_ag_large_farm_tla)
        ds3_datapoints.loc[2050] = (1.0 * max_cons_ag_large_farm_tla)
        ds3_datapoints.loc[2080] = ad_2080
        ds3_datapoints['World'] = 0.0
        ds3_datapoints['World'] = ds3_datapoints.sum(axis=1)

        # Data Source 4
        # Source: Refer sheet "PD regional CA annual adoption"
        ds4_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds4_datapoints.loc[2018] = ad_2018
        ds4_datapoints.loc[2030] = (0.8 * ds2_poss_adopt_2050)
        ds4_datapoints.loc[2050] = (0.6 * ds2_poss_adopt_2050)
        ds4_datapoints.loc[2080] = ad_2080
        ds4_datapoints['World'] = 0.0
        ds4_datapoints['World'] = ds4_datapoints.sum(axis=1)

        # Data Source 5
        # Source: Refer sheet "PD regional CA annual adoption"
        ds5_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds5_datapoints.loc[2018] = ad_2018
        ds5_datapoints.loc[2030] = (0.8 * ds1_poss_adopt_2050)
        ds5_datapoints.loc[2050] = (0.6 * ds1_poss_adopt_2050)
        ds5_datapoints.loc[2080] = ad_2080
        ds5_datapoints['World'] = 0.0
        ds5_datapoints['World'] = ds5_datapoints.sum(axis=1)

        # Data Source 6
        # Source: see PresteleAdoptionCalc sheet
        if 'BookVersion' in self.ac.name:
            ds6_prestele_poss_adopt_2050 = prestele_ad_book
        else:
            pct = pd.Series([
                0., 0.740285597497468, 0.61878404520945, 0.581170964964222,
                0.0900760503108076, 0.803736844958406, 0., 0., 0., 0.
            ],
                            index=dd.REGIONS)
            ds6_prestele_poss_adopt_2050 = self.tla_per_region.loc[
                2050] * prestele_mult * pct
        ds6_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds6_datapoints.loc[2018] = ad_2018
        ds6_datapoints.loc[2030] = (0.8 * ds6_prestele_poss_adopt_2050)
        ds6_datapoints.loc[2050] = (0.6 * ds6_prestele_poss_adopt_2050)
        ds6_datapoints.loc[2080] = ad_2080
        ds6_datapoints['World'] = 0.0
        ds6_datapoints['World'] = ds6_datapoints.sum(axis=1)

        # Data Source 7
        # Source: see PresteleAdoptionCalc sheet
        if 'BookVersion' in self.ac.name:
            ds7_prestele_poss_adopt_2050 = prestele_ad_book
        else:
            pct = pd.Series(
                [0., 1.0, 1.0, 1.0, 0.320741884451365, 1.0, 0., 0., 0., 0.],
                index=dd.REGIONS)
            ds7_prestele_poss_adopt_2050 = self.tla_per_region.loc[
                2050] * prestele_mult * pct
        ds7_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds7_datapoints.loc[2018] = ad_2018
        ds7_datapoints.loc[2030] = (0.8 * ds7_prestele_poss_adopt_2050)
        ds7_datapoints.loc[2050] = (0.6 * ds7_prestele_poss_adopt_2050)
        ds7_datapoints.loc[2080] = ad_2080
        ds7_datapoints['World'] = 0.0
        ds7_datapoints['World'] = ds7_datapoints.sum(axis=1)

        # Data Source 8
        # Source: see PresteleAdoptionCalc sheet
        if 'BookVersion' in self.ac.name:
            ds8_prestele_poss_adopt_2050 = prestele_ad_book
        else:
            pct = pd.Series([
                0., 0.46568375652467, 0.169344179047277, 0.194261406995049,
                0.141859451675443, 0.712235299292505, 0., 0., 0., 0.
            ],
                            index=dd.REGIONS)
            ds8_prestele_poss_adopt_2050 = self.tla_per_region.loc[
                2050] * prestele_mult * pct
        ds8_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds8_datapoints.loc[2018] = ad_2018
        ds8_datapoints.loc[2050] = (1.0 * ds8_prestele_poss_adopt_2050)
        ds8_datapoints['World'] = 0.0
        ds8_datapoints['World'] = ds8_datapoints.sum(axis=1)

        ca_pds_data_sources = [
            {
                'name':
                'Low,High Early Adoption, Polynomial Trend',
                'include':
                False,
                'description':
                ('An annual growth rate of 0.36% was used to forecast regional adoption. '
                 'Regional adoption of CA in the year 2050 was calculated and their '
                 'percentage to the total arable land area was estimated, and are used as '
                 'assumptions 1-5, below. It is also assumed that 100% of the projected '
                 'adoption will be achieved by 2030. As, it is a bridge solution to RA, the '
                 'area under CA will decline post 2030 and will remains to only 80% of the '
                 'estimated adoption by 2050. '),
                'datapoints':
                ds1_datapoints,
                'datapoints_degree':
                3
            },
            {
                'name':
                'High,High Early Adoption, Polynomial Trend',
                'include':
                False,
                'description':
                ('Adoption of CA was reported maximum in Brazil, across the globe. Thus, its '
                 'annual growth rate of 1.24% was used to forecast regional adoption. '
                 'Regional adoption of CA in the year 2050 was calculated and their '
                 'percentage to the total arable land area was estimated, and are used as '
                 'assumptions 1-5, below. It is also assumed that 100% of the projected '
                 'adoption will be achieved by 2030. As, it is a bridge solution to RA, the '
                 'area under CA will decline post 2030 and will remains to only 80% of the '
                 'estimated adoption by 2050. '),
                'datapoints':
                ds2_datapoints,
                'datapoints_degree':
                3
            },
            {
                'name':
                'Max, Polynomial Trend',
                'include':
                False,
                'description':
                ('A 100% regional adoption was assumed in this scenario. '),
                'datapoints':
                ds3_datapoints,
                'datapoints_degree':
                3
            },
            {
                'name':
                'High, Early Adoption, Polynomial Trend',
                'include':
                False,
                'description':
                ('Adoption of CA was reported maximum in Brazil, across the globe. Thus, its '
                 'annual growth rate of 1.24% was used to forecast regional adoption. '
                 'Regional adoption of CA in the year 2050 was calculated and their '
                 'percentage to the total arable land area was estimated, and are used as '
                 'assumptions 1-5, below. It is also assumed that 80% of the projected '
                 'adoption will be achieved by 2030. As, it is a bridge solution to RA, the '
                 'area under CA will decline post 2030 and will remains to only 60% of the '
                 'estimated adoption by 2050. '),
                'datapoints':
                ds4_datapoints,
                'datapoints_degree':
                3
            },
            {
                'name':
                'Low, Early Adoption, Polynomial Trend',
                'include':
                False,
                'description':
                ('An annual growth rate of 0.36% was used to forecast regional adoption. '
                 'Regional adoption of CA in the year 2050 was calculated and their '
                 'percentage to the total arable land area was estimated, and are used as '
                 'assumptions 1-5, below. It is also assumed that 80% of the projected '
                 'adoption will be achieved by 2030. As, it is a bridge solution to RA, the '
                 'area under CA will decline post 2030 and will remains to only 60% of the '
                 'estimated adoption by 2050. '),
                'datapoints':
                ds5_datapoints,
                'datapoints_degree':
                3
            },
            {
                'name':
                'Moderate CA Adoption rates based on Prestele Topdown map, polynomial',
                'include':
                False,
                'description':
                ('Regional adoption of CA in the year 2050 was calculated and their '
                 'percentage to the total arable land area was estimated, and are used as '
                 'assumptions 1-5, below. It is also assumed that 80% of the projected '
                 'adoption will be achieved by 2030. It is a bridge solution to RA so the '
                 'area under CA will decline post 2030 and will remain to only 60% of the '
                 'estimated adoption by 2050. SEI added current and projected adoption and '
                 'max potential adoption (assumption 10)  based on Prestele et al 2018. after '
                 'applying Prestele regional percent adoption by TopDown projection '
                 '(intermediate adoption rate to 2050), to country -level data available in '
                 'their supplementary materials, then summing by PDrawdown regions (which '
                 'differ from Prestele regions). The % of regional Drawdown TLA projected by '
                 '2050 using Prestele projections (not mean of data) was calculated and used '
                 'in Revised growth assumptions 1-5. '),
                'datapoints':
                ds6_datapoints,
                'datapoints_degree':
                3
            },
            {
                'name':
                'Likely max CA based on Prestele BottomUp Map, polynominal',
                'include':
                False,
                'description':
                ('Regional adoption of CA in the year 2050 was calculated and their '
                 'percentage to the total arable land area was estimated, and are used as '
                 'assumptions 1-5, below. It is also assumed that 80% of the projected '
                 'adoption will be achieved by 2030. It is a bridge solution to RA so the '
                 'area under CA will decline post 2030 and will remain to only 60% of the '
                 'estimated adoption by 2050. SEI added current and projected adoption and '
                 'max potential adoption (assumption 10)  based on Prestele et al 2018. after '
                 'applying Prestele regional percent adoption by BOTTOM UP projection (forced '
                 'to 2050), to country -level data available in their supplementary '
                 'materials, then summing by PDrawdown regions (which differ from Prestele '
                 'regions). The % of regional Drawdown TLA projected by 2050 using Prestele '
                 'projections (not mean of data) was calculated OR if the bottom up '
                 'projection result in extent larger than Drawdown regional TLA, then 100% '
                 'was used in Revised growth assumptions 1-5. '),
                'datapoints':
                ds7_datapoints,
                'datapoints_degree':
                3
            },
            {
                'name': 'Baseline scenario',
                'include': True,
                'description': ('tis is the average of scenarios 1-7 '),
                'datapoints': ds8_datapoints,
                'maximum': max_cons_ag_large_farm_tla['World']
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2014] = [
                108.926170040128000, 43.700575542980000, 9.040960261572450,
                8.934730992728910, 1.113417893008100, 46.136485349838400, 0.0,
                0.0, 0.0, 0.0
            ]
            df.loc[2015] = [
                118.522634649202000, 47.190416175021700, 10.277201842542000,
                10.390765035686000, 1.355692262948170, 49.308559333003700, 0.0,
                0.0, 0.0, 0.0
            ]
            df.loc[2016] = [
                128.231557482326000, 50.685767480789800, 11.580017143547000,
                11.936077959964700, 1.613327416836600, 52.416367481188000, 0.0,
                0.0, 0.0, 0.0
            ]
            df.loc[2017] = [
                138.054065103220000, 54.187020002847500, 12.949707603363100,
                13.570892429945200, 1.886419963055470, 55.460025104009000, 0.0,
                0.0, 0.0, 0.0
            ]
            df.loc[2018] = [
                147.991284075603000, 57.694564283758300, 14.386574660765900,
                15.295431110007600, 2.175066509986860, 58.439647511084400, 0.0,
                0.0, 0.0, 0.0
            ]

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

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

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

        ht_ref_adoption_initial = pd.Series(list(
            self.ac.ref_base_adoption.values()),
                                            index=dd.REGIONS)
        ht_ref_adoption_final = self.tla_per_region.loc[2050] * (
            ht_ref_adoption_initial / self.tla_per_region.loc[2014])
        ht_ref_datapoints = pd.DataFrame(columns=dd.REGIONS)
        ht_ref_datapoints.loc[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_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)
Esempio n. 16
0
    def __init__(self, scenario=None):
        if scenario is None:
            scenario = list(scenarios.keys())[0]
        self.scenario = scenario
        self.ac = scenarios[scenario]

        # TLA
        self.ae = aez.AEZ(solution_name=self.name,
                          cohort=2020,
                          regimes=dd.THERMAL_MOISTURE_REGIMES8)
        if self.ac.use_custom_tla:
            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 2015': THISDIR.joinpath('ad', 'ad_FAO_2015.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']
        tla_afforestation = 717.972721643776
        tla_bamboo = 363.757256176669
        tla_perennial_bioenergy = 264.89533875
        tla_all_biomass = tla_afforestation + tla_bamboo + tla_perennial_bioenergy
        ds6_percent_afforestation = tla_afforestation / tla_all_biomass
        ds6_percent_adoption_2050 = (
            1614 * ds6_percent_afforestation) / tla_all_biomass
        ds6_adoption_2050 = ds6_percent_adoption_2050 * tla_2050
        ds7_percent_adoption_2050 = 1614 / tla_all_biomass
        ds7_adoption_2050 = ds7_percent_adoption_2050 * tla_2050

        ca_pds_data_sources = [
            {
                'name':
                'Regional linear trend',
                'include':
                True,
                'datapoints_degree':
                1,
                # Future forest plantation area is projected based on country level data available
                # for the year 1990, 2000, 2005, and 2010 from the FAO's Forest Resource Assessment
                # report from 2015.
                #
                # Country level data about planted forest area from 1990 - 2014 was aggregated at
                # the regional level (for details see hidden ""HistoricAndProjectedData"" sheet).
                # This data was then used to project future adoption using a linear trend.
                'datapoints':
                pd.DataFrame([
                    [
                        1990, np.nan, 96.8914, 44.1631, 106.1562, 16.5338,
                        14.9281, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2000, np.nan, 97.2555, 44.2605, 107.5489, 16.7251,
                        15.2771, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2005, np.nan, 97.6355, 44.3794, 109.8028, 16.9607,
                        15.6649, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2010, np.nan, 97.8700, 44.4540, 111.5210, 17.1760,
                        16.0730, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2014, np.nan, 98.1783330003811, 44.5558196042818,
                        113.7890763825080, 17.4259450169749, 16.5131623025461,
                        0.0, 0.0, 0.0, 0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Regional max linear trend',
                'include':
                True,
                # "Future forest plantation area is projected based on country level data available
                # for the year 1990, 2000, 2005, and 2010 from the FAO's Forest Resource Assessment
                # report from 2015. Country level data about planted forest area from 1990 - 2014
                # was aggregated at the regional level, and used to determine regional annual growth
                # rates. For details about the calculations of regional rates see hidden
                # ""HistoricAndProjectedData"" sheet).
                #
                # In this scenario, regional future adoption of forest plantations is projected
                # based on the maximum historical regional growth rate reported in the respective
                # region (between 1990 - 2014). For each region, future adoption projected based
                # on the maximum linear regional trend between any two given time periods.
                'datapoints':
                pd.DataFrame([
                    [
                        2010, np.nan, 97.8700, 44.4540, 111.5210, 17.1760,
                        16.0730, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2014, np.nan, 98.1783330003811, 44.5558196042818,
                        113.7890763825080, 17.4259450169749, 16.5131623025461,
                        0.0, 0.0, 0.0, 0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                '50% of the max historical annual afforestation rate across the regions',
                'include':
                True,
                # Future forest plantation area is projected based on country level data available
                # for the year 1990, 2000, 2005, and 2010 from the FAO's Forest Resource Assessment
                # report from 2015. Country level data about planted forest area from 1990 - 2014
                # was aggregated at the regional level, and used to determine regional annual growth
                # rates. For details about the calculations of regional rates see hidden
                # "HistoricAndProjectedData" sheet).
                #
                # In this scenario, regional future adoption of forest plantations is projected
                # based on the maximum historical regional growth rate across all regions (between
                # 1990 - 2014), which occurred in Asia (0.57 Mha annual increase between 2010 -2014).
                # For the ASIA region this same rate (0.57 Mha annual increase) is used for
                # projecting the future adoption of forest plantation. For all other regions half
                # of this growth rate is applied (0.29 Mha annual increase).
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_50_of_the_max_historical_annual_afforestation_rate_across_the_regions.csv'
                )
            },
            {
                'name':
                '100% of the max historical annual afforestation rate across the regions',
                'include':
                True,
                # Future forest plantation area is projected based on country level data available
                # for the year 1990, 2000, 2005, and 2010 from the FAO's Forest Resource Assessment
                # report from 2015. Country level data about planted forest area from 1990 - 2014
                # was aggregated at the regional level, and used to determine regional annual growth
                # rates. For details about the calculations of regional rates see hidden
                # "HistoricAndProjectedData" sheet).
                #
                # In this scenario, regional future adoption of forest plantations is projected
                # based on the maximum historical regional growth rate across all regions (between
                # 1990 - 2014), which occurred in Asia (0.57 Mha increase between 2010 -2014).
                # To project future adoption of forest plantations, this rate was applied to all
                # regions, including Asia (0.57 Mha annual increase).
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_100_of_the_max_historical_annual_afforestation_rate_across_the_regions.csv'
                )
            },
            {
                'name':
                '200% increase for Asia and 100% for the other regions',
                'include':
                True,
                # Future forest plantation area is projected based on country level data available
                # for the year 1990, 2000, 2005, and 2010 from the FAO's Forest Resource Assessment
                # report from 2015. Country level data about planted forest area from 1990 - 2014
                # was aggregated at the regional level, and used to determine regional annual growth
                # rates. For details about the calculations of regional rates see hidden
                # "HistoricAndProjectedData" sheet).
                #
                # In this scenario, regional future adoption of forest plantations is projected
                # based on the maximum historical regional growth rate across all regions (between
                # 1990 - 2014), which occurred in Asia (0.57 Mha increase between 2010 -2014).
                # To project future adoption of forest plantations, this rate was applied to all
                # regions (0.57 Mha annual increase) except for Asia region where the rate was
                # doubled (1.14 Mha annual increase).
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_200_increase_for_Asia_and_100_for_the_other_regions.csv'
                )
            },
            {
                'name':
                'Conservative growth projection based on Kreidenweis et al. (2016)',
                'include':
                True,
                # This projection of future adoption of afforestation is based on Kreidenweis
                # et al. (2016)'s ""global afforestation"" scenario, which assumes 1614 Mha total
                # afforested area by 2050.
                # We calculated the proportion of this projection based on the percent of
                # afforestation to the total TLA set for the biomass crops as per 2019 land
                # allocation model. This proportion was applied to TLA set for this solution
                # allocated on forest AEZs.
                '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, ds6_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'),
                'maximum':
                tla_bamboo
            },
            {
                'name':
                'High growth projection based on Kreidenweis et al. (2016)',
                'include':
                True,
                # "This projection of future adoption of afforestation is based on Kreidenweis
                # et al. (2016)'s ""global afforestation"" scenario, which assumes 1614 Mha total
                # afforested area by 2050.
                # We calculated the proportion of this projection based on the percent of
                # afforestation to the total TLA set for the biomass crops as per 2019 land
                # allocation model.  This proportion was applied to TLA set for this solution
                # allocated on forest AEZs.
                '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, ds7_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':
                'Linear projections based on  Evans (2009) publication',
                'include':
                True,
                # Projections of future adoption of forest plantations are based on the total
                # predicted area of planted forest in 2030 (344.5 Mha), as reported by Evans (2009),
                # see Table 5.5. The predictions are made according to two scenarios (Scenario 2:
                # "Business as Usual" and Scenario 3: "Higher Productivity") described in
                # Table 5.2 of the publication.
                'datapoints':
                pd.DataFrame([
                    [
                        2014, 294.140179643776, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2030, 344.500000000000, 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=0.5,
            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] = [
                290.462336306692, 98.1783330003811, 44.5558196042818,
                113.789076382508, 17.4259450169749, 16.5131623025461, 0.0, 0.0,
                0.0, 0.0
            ]
            df.loc[2015] = [
                291.336550416405, 98.2542011640878, 44.5812227272287,
                114.378174359749, 17.4918608321974, 16.6310913331414, 0.0, 0.0,
                0.0, 0.0
            ]
            df.loc[2016] = [
                292.240912741787, 98.3317866108997, 44.6073285492058,
                114.988603296961, 17.5600505509306, 16.7531437337891, 0.0, 0.0,
                0.0, 0.0
            ]
            df.loc[2017] = [
                293.175447683892, 98.4110924492030, 44.6341380907823,
                115.620380827999, 17.6305154458053, 16.8793208701027, 0.0, 0.0,
                0.0, 0.0
            ]
            df.loc[2018] = [
                294.140179643776, 98.4921217873836, 44.6616523725276,
                116.273524586716, 17.7032567894526, 17.0096241076960, 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)
Esempio n. 17
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': {
                'Lassaletta et al 2014':
                THISDIR.joinpath('ad', 'ad_Lassaletta_et_al_2014.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']
        area_N_eff_1990_1995 = 225.049083333333
        area_N_eff_1996_2000 = 89.7290333333333
        area_N_eff_2001_2005 = 42.7382
        area_N_eff_2006_2010 = 98.7301833333333

        ds1_o90_2050 = 0.46568375652467 * self.tla_per_region.loc[2050,
                                                                  'OECD90']
        ds1_ee_2050 = 0.169344179047277 * self.tla_per_region.loc[
            2050, 'Eastern Europe']
        ds1_asj_2050 = 0.194261406995049 * self.tla_per_region.loc[
            2050, 'Asia (Sans Japan)']
        ds1_mea_2050 = 0.141859451675443 * self.tla_per_region.loc[
            2050, 'Middle East and Africa']
        ds1_la_2050 = 0.712235299292505 * self.tla_per_region.loc[
            2050, 'Latin America']
        ds1_world_2050 = ds1_o90_2050 + ds1_ee_2050 + ds1_asj_2050 + ds1_mea_2050 + ds1_la_2050

        ds2_o90_2050 = 0.791283756524669 * self.tla_per_region.loc[2050,
                                                                   'OECD90']
        ds2_ee_2050 = 0.494944179047277 * self.tla_per_region.loc[
            2050, 'Eastern Europe']
        ds2_asj_2050 = 0.51986140699505 * self.tla_per_region.loc[
            2050, 'Asia (Sans Japan)']
        ds2_mea_2050 = 0.467459451675442 * self.tla_per_region.loc[
            2050, 'Middle East and Africa']
        ds2_la_2050 = 1.03783529929251 * self.tla_per_region.loc[
            2050, 'Latin America']
        ds2_world_2050 = ds2_o90_2050 + ds2_ee_2050 + ds2_asj_2050 + ds2_mea_2050 + ds2_la_2050

        ds3_o90_2050 = 1.0 * self.tla_per_region.loc[2050, 'OECD90']
        ds3_ee_2050 = 1.0 * self.tla_per_region.loc[2050, 'Eastern Europe']
        ds3_asj_2050 = 1.0 * self.tla_per_region.loc[2050, 'Asia (Sans Japan)']
        ds3_mea_2050 = 1.0 * self.tla_per_region.loc[2050,
                                                     'Middle East and Africa']
        ds3_la_2050 = 1.0 * self.tla_per_region.loc[2050, 'Latin America']
        ds3_world_2050 = ds3_o90_2050 + ds3_ee_2050 + ds3_asj_2050 + ds3_mea_2050 + ds3_la_2050

        ds_2018 = [
            self.ac.ref_base_adoption['World'],
            self.ac.ref_base_adoption['OECD90'],
            self.ac.ref_base_adoption['Eastern Europe'],
            self.ac.ref_base_adoption['Asia (Sans Japan)'],
            self.ac.ref_base_adoption['Middle East and Africa'],
            self.ac.ref_base_adoption['Latin America']
        ]

        ca_pds_data_sources = [
            {
                'name':
                'Aggressive-Low, Linear Trend',
                'include':
                True,
                # The future adoption of nutrient management is build on the extent of the future
                # adoption of Conservation Agrculture (CA). Nutrient management is one of the
                # integral component of CA, thus, it is assumed that the adoption of nutrient
                # management will follow the similar trend of CA. This scenario projects the
                # future adoption of the solution based on the average annual future growth rate
                # of conservation agriculture.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2050, ds1_world_2050, ds1_o90_2050, ds1_ee_2050,
                        ds1_asj_2050, ds1_mea_2050, ds1_la_2050, 0.0, 0.0, 0.0,
                        0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Aggressive-High, Linear Trend',
                'include':
                True,
                # The future adoption of nutrient management is build on the extent of the future
                # adoption of Conservation Agrculture (CA). Nutrient management is one of the integral
                # component of CA, thus, it is assumed that the adoption of nutrient management will
                # follow the similar trend of CA. This scenario projects the future adoption of the
                # solution based on the high annual future growth rate of conservation agriculture.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2050, ds2_world_2050, ds2_o90_2050, ds2_ee_2050,
                        ds2_asj_2050, ds2_mea_2050, ds2_la_2050, 0.0, 0.0, 0.0,
                        0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Aggressive-Max, Linear Trend',
                'include':
                True,
                # This is an aggressive scenario assumes adoption of the solution in 100% of the TLA
                # by 2050 in all regions.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2050, ds3_world_2050, ds3_o90_2050, ds3_ee_2050,
                        ds3_asj_2050, ds3_mea_2050, ds3_la_2050, 0.0, 0.0, 0.0,
                        0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Aggressive-High, high early growth',
                'include':
                False,
                # This scenario is assuming 60% of the total adoption will be achieved by 2030.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2030, 0.6 * ds2_world_2050, 0.6 * ds2_o90_2050, 0.6 *
                        ds2_ee_2050, 0.6 * ds2_asj_2050, 0.6 * ds2_mea_2050,
                        0.6 * ds2_la_2050, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2050, ds2_world_2050, ds2_o90_2050, ds2_ee_2050,
                        ds2_asj_2050, ds2_mea_2050, ds2_la_2050, 0.0, 0.0, 0.0,
                        0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Aggressive-Low, high early growth',
                'include':
                False,
                # "This is scenario 1, assuming 60% of the total adoption will be achieved by 2030.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2030, 0.6 * ds1_world_2050, 0.6 * ds1_o90_2050, 0.6 *
                        ds1_ee_2050, 0.6 * ds1_asj_2050, 0.6 * ds1_mea_2050,
                        0.6 * ds1_la_2050, 0.0, 0.0, 0.0, 0.0
                    ],
                    [
                        2050, ds1_world_2050, ds1_o90_2050, ds1_ee_2050,
                        ds1_asj_2050, ds1_mea_2050, ds1_la_2050, 0.0, 0.0, 0.0,
                        0.0
                    ],
                ],
                             columns=ca_pds_columns).set_index('Year')
            },
            {
                'name':
                'Lassaletta et al 2014, conservative growth',
                'include':
                True,
                # Future adoption is projected based on the maximum global area reported under
                # Nitrogen Use Efficiency in the past by Lassaletta et al 2014.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2050, area_N_eff_1990_1995, 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':
                'Lassaletta et al 2014, moderate growth',
                'include':
                True,
                # Future adoption is projected based on the maximum global area reported under
                # Nitrogen Use Efficiency in the past by Lassaletta et al 2014.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2050, 2 * area_N_eff_1990_1995, 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':
                'Lassaletta et al 2014, high growth',
                'include':
                True,
                # Future adoption is projected based on the maximum global area reported under
                # Nitrogen Use Efficiency in the past by Lassaletta et al 2014.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2050, 4 * area_N_eff_1990_1995, 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':
                'Sutton et al 2013, linear trend',
                'include':
                True,
                # Future adoption is projected based on the projected global area under
                # Nitrogen Use Efficiency by 2020 by Sutton et al 2013.
                'datapoints':
                pd.DataFrame([
                    [2018] + ds_2018 + [0.0, 0.0, 0.0, 0.0],
                    [
                        2020, 335.92674, 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)

        # Manual adjustment made in spreadsheet for Drawdown 2020.
        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2012:2018, 'World'] = 139.129613374975

        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=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)
Esempio n. 18
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

        # Current commitments made under Bonn Challenge (taken on 16/12/2019)
        bonn_mha = 149.012768

        # % current commitments are projects in temperate thermal moisture regime
        temperate_percent = 0.198187597540394

        # % current commitments in temperate thermal moisture regime available are
        # for intact forest restoration
        intact_percent = 0.4423

        # Calculated by subtracting the total degraded land suitable for tropical
        # forest restoration (304 Mha) and boreal (46 Mha) from the WRI estimates
        # of 500 Mha as the potential global area for forest restoration
        # TODO: the spatial-aez work in late 2019 provided direct data input of temperate
        #       forest area, distinct from boreal and tropical, which could be used here.
        title = 'Percent of Degraded Land Suitable for Intact Temperate Forest Restoration'
        intact_mha = self.ac.lookup_vma(vma_title=title)
        if intact_mha is None:
            intact_mha = VMAs[title].avg_high_low(key='mean')

        # Max land Expected total land commited under Bonn Challenge and NY Declaration 
        max_land = 350.0

        # Mha of current commitments in temperate thermal moisture regime
        committed_mha = bonn_mha * temperate_percent

        # Mha of total degraded land available for new commitments in
        # temperate thermal moisture regime, from New York Declaration
        nydf_new_mha = (max_land - bonn_mha) * temperate_percent

        # WRI prediction for max available land area
        wri_new_mha = intact_mha - committed_mha

        # DATA SOURCE 1, using NYDF land area
        ds1_future_commit = 1.0
        ds1_2030 = (committed_mha * intact_percent) + (nydf_new_mha * ds1_future_commit)

        # future land area with WRI prediction plus 44.23% and 100% commitment
        future_mha_44p = (committed_mha * intact_percent) + (wri_new_mha * 0.4423)
        future_mha_100p = (committed_mha * intact_percent) + (wri_new_mha * 1.0)

        ca_pds_data_sources = [
            {'name': 'Optimistic-Achieve Commitment in 15 years w/ 100% intact, (Charlotte Wheeler, 2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060).  In this '
                    'scenario, NYDF prediction for max area available for temperate forest '
                    'restoration, 100% new commitment for intact forest and year 2030 was '
                    'considered when the commitments will be realized.'),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2030, ds1_2030, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2031, ds1_2030, 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': 'Optimistic-Achieve Commitment in 15 years w/ 100% intact, WRI estimates (Charlotte Wheeler, 2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060). In this '
                    'scenario, WRI prediction for max area available for temperate forest '
                    'restoration, 100% new commitment for intact forest and year 2030 was '
                    'considered when the commitments will be realized. '),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2030, future_mha_100p, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2031, future_mha_100p, 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': 'Conservative-Achieve Commitment in 15 years w/ 44.2% intact, (Charlotte Wheeler,2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060). In this '
                    'scenario, WRI prediction for max area available for temperate forest '
                    'restoration, 44.23% new commitment for intact forest and year 2030 was '
                    'considered when the commitments will be realized. '),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2030, future_mha_44p, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2031, future_mha_44p, 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': 'Conservative-Achieve Commitment in 15 years w/ 44.2% intact with continued growth post-2030, (Charlotte Wheeler,2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060). In this '
                    'scenario, WRI prediction for max area available for temperate forest '
                    'restoration, 44.23% new commitment for intact forest and year 2030 was '
                    'considered when the commitments will be realized, with continued growth '
                    'in post 2030.'),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2030, future_mha_44p, 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': 'Conservative-Achieve Commitment in 30 years w/ 100% intact, (Charlotte Wheeler,2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060). In this '
                    'scenario, WRI prediction for max area available for temperate forest '
                    'restoration, 100% new commitment for intact forest and year 2045 was '
                    'considered when the commitments will be realized. '),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2045, future_mha_100p, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2046, future_mha_100p, 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': 'Conservative-Achieve Commitment in 30 years w/ 44.2% intact, (Charlotte Wheeler,2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060). In this '
                    'scenario, WRI prediction for max area available for temperate forest '
                    'restoration, 44.23% new commitment for intact forest and year 2045 was '
                    'considered when the commitments will be realized. '),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2045, future_mha_44p, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2046, future_mha_44p, 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': 'Conservative-Achieve Commitment in 30 years w/ 44.2% intact with continued growth, (Charlotte Wheeler,2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060). In this '
                    'scenario, WRI prediction for max area available for temperate forest '
                    'restoration, 44.23% new commitment for intact forest and year 2045 was '
                    'considered when the commitments will be realized, with continued growth '
                    'in post 2045. '),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2045, future_mha_44p, 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': 'Conservative-Achieve Commitment in 45 years w/ 100% intact (Charlotte Wheeler,2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060). In this '
                    'scenario, WRI prediction for max area available for temperate forest '
                    'restoration, 100% new commitment for intact forest and year 2060 was '
                    'considered when the commitments will be realized. '),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2060, future_mha_100p, 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': 'Conservative-Achieve Commitment in 45 years w/ 44.2% intact (Charlotte Wheeler,2016)', 'include': True,
                'description': (
                    'The adoption scenarios are calculated using the linear trendline based '
                    'on: (1) Current commitments to date, (2) Potential future commitments, (3) '
                    'The proportion of committee land restored to intact forest (100% or 44.23%), '
                    'and (4) The year commitments are realised (2030, 2045 or 2060). In this '
                    'scenario, WRI prediction for max area available for temperate forest '
                    'restoration, 44.23% new commitment for intact forest and year 2060 was '
                    'considered when the commitments will be realized. '),
                'maximum': intact_mha,
                'datapoints': pd.DataFrame([
                    [2014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                    [2060, future_mha_44p, 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)

        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)
Esempio n. 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': {
                '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)
Esempio n. 20
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)
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution())

        adconfig_list = [
            [
                'param', 'World', 'OECD90', 'Eastern Europe',
                'Asia (Sans Japan)', 'Middle East and Africa', 'Latin America',
                'China', 'India', 'EU', 'USA'
            ],
            [
                'trend', self.ac.soln_pds_adoption_prognostication_trend,
                'Medium', 'Medium', 'Medium', 'Medium', 'Medium', 'Medium',
                'Medium', 'Medium', 'Medium'
            ],
            [
                'growth', self.ac.soln_pds_adoption_prognostication_growth,
                'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE', 'NOTE',
                'NOTE'
            ],
            ['low_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            ['high_sd_mult', 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        ]
        adconfig = pd.DataFrame(adconfig_list[1:],
                                columns=adconfig_list[0],
                                dtype=np.object).set_index('param')
        ad_data_sources = {
            'Raw Data for ALL LAND TYPES': {
                'Project Drawdown 2018_Direct Seeded Rice Area (2nd Polynomial Growth)':
                THISDIR.joinpath(
                    'ad',
                    'ad_Project_Drawdown_2018_Direct_Seeded_Rice_Area_2nd_Polynomial_Growth.csv'
                ),
                'Project Drawdown 2018_Rice Area under water management (Linear Growth)':
                THISDIR.joinpath(
                    'ad',
                    'ad_Project_Drawdown_2018_Rice_Area_under_water_management_Linear_Growth.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']
        ad_2018 = self.ac.ref_base_adoption['World']

        # 2050 adoption based on Project Drawdown 2018 Direct Seeded
        # Rice Area (2nd order Polynomial Growth); Refer "Adoption Data" sheet
        ad_2050_2ndpoly = 69.9380489958066000

        # 2050 adoption based on Project Drawdown 2018_Rice Area under water
        # management (Linear Growth); Refer "Adoption Data" sheet
        ad_2050_linear = 170.3736841446970000

        # 2050 adoption based on Project Drawdown 2018_Rice Area under water
        # management (Linear Growth, divided by 2); Refer "Adoption Data" sheet
        ad_2050_linear_half = 85.1868420723484000

        ad_2050_avg = (ad_2050_2ndpoly + ad_2050_linear +
                       ad_2050_linear_half) / 3.0
        ad_2050_min = min(
            [ad_2050_2ndpoly, ad_2050_linear, ad_2050_linear_half])
        ad_2050_max = max(
            [ad_2050_2ndpoly, ad_2050_linear, ad_2050_linear_half])

        ca_pds_data_sources = [
            {
                'name':
                'Medium Growth',
                'include':
                True,
                'description':
                ('Future adoption of improved rice cultivation is projected based on the '
                 'historical growth rate of direct seeded rice and water management available '
                 'in the literature (refer "Current Adoption_LR" sheet). The historical data '
                 'was interpolated, a 2nd order polynomial growth was considered for direct '
                 'seeded rice data and linear growth for the water management, The '
                 'interpolated data is then placed in the "adoption data" sheet. The future '
                 'adoption in the present scenario is based on the "average adoption value '
                 'projected for the year 2050" based on the given data set. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, ad_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2050, ad_2050_avg, 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 Growth',
                'include':
                True,
                'description':
                ('Future adoption of improved rice cultivation is projected based on the '
                 'historical growth rate of direct seeded rice and water management available '
                 'in the literature (refer "Current Adoption_LR" sheet). The historical data '
                 'was interpolated, a 2nd order polynomial growth was considered for direct '
                 'seeded rice data and linear growth for the water management, The '
                 'interpolated data is then placed in the "adoption data" sheet. The future '
                 'adoption in the present scenario is based on the "minimum adoption value '
                 'projected for the year 2050" based on the given data set. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, ad_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2050, ad_2050_min, 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 Growth',
                'include':
                True,
                'description':
                ('Future adoption of improved rice cultivation is projected based on the '
                 'historical growth rate of direct seeded rice and water management available '
                 'in the literature (refer "Current Adoption_LR" sheet). The historical data '
                 'was interpolated, a 2nd order polynomial growth was considered for direct '
                 'seeded rice data and linear growth for the water management, The '
                 'interpolated data is then placed in the "adoption data" sheet. The future '
                 'adoption in the present scenario is based on the "maximum adoption value '
                 'projected for the year 2050" based on the given data set. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, ad_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2050, ad_2050_max, 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 Growth, Early Adoption',
                'include':
                True,
                'description':
                ('Future adoption of improved rice cultivation is projected based on the '
                 'historical growth rate of direct seeded rice and water management available '
                 'in the literature (refer "Current Adoption_LR" sheet). The historical data '
                 'was interpolated, a 2nd order polynomial growth was considered for direct '
                 'seeded rice data and linear growth for the water management, The '
                 'interpolated data is then placed in the "adoption data" sheet. The future '
                 'adoption in the present scenario is based on the "average adoption value '
                 'projected for the year 2050" based on the given data set. In addition, it '
                 'is also assumed that 75% of the projected adoption for the year 2050 will '
                 'be achieved by 2030. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, ad_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2030, 0.75 * ad_2050_avg, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2050, ad_2050_avg, 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 Growth, Early Adoption',
                'include':
                True,
                'description':
                ('Future adoption of improved rice cultivation is projected based on the '
                 'historical growth rate of direct seeded rice and water management available '
                 'in the literature (refer "Current Adoption_LR" sheet). The historical data '
                 'was interpolated, a 2nd order polynomial growth was considered for direct '
                 'seeded rice data and linear growth for the water management, The '
                 'interpolated data is then placed in the "adoption data" sheet. The future '
                 'adoption in the present scenario is based on the "minimum adoption value '
                 'projected for the year 2050" based on the given data set. In addition, it '
                 'is also assumed that 75% of the projected adoption for the year 2050 will '
                 'be achieved by 2030. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, ad_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2030, 0.75 * ad_2050_min, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2050, ad_2050_min, 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 Growth, Early Adoption',
                'include':
                False,
                'description':
                ('Future adoption of improved rice cultivation is projected based on the '
                 'historical growth rate of direct seeded rice and water management available '
                 'in the literature (refer "Current Adoption_LR" sheet). The historical data '
                 'was interpolated, a 2nd order polynomial growth was considered for direct '
                 'seeded rice data and linear growth for the water management, The '
                 'interpolated data is then placed in the "adoption data" sheet. The future '
                 'adoption in the present scenario is based on the "maximum adoption value '
                 'projected for the year 2050" based on the given data set. In addition, it '
                 'is also assumed that 75% of the projected adoption for the year 2050 will '
                 'be achieved by 2030. '),
                'datapoints':
                pd.DataFrame([
                    [
                        2018, ad_2018, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0
                    ],
                    [
                        2030, 0.75 * ad_2050_max, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                        0.0, 0.0, 0.0
                    ],
                    [
                        2050, ad_2050_max, 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']
            df.loc[2014, 'World'] = 31.2753335238409000
            df.loc[2015, 'World'] = 33.6257358946259000
            df.loc[2016, 'World'] = 35.9761382654110000
            df.loc[2017, 'World'] = 38.3265406361960000
            df.loc[2018, 'World'] = 40.6769430069810000

        # Custom REF Data
        ca_ref_data_sources = [
            {
                'name':
                '[Type Scenario 1 Name Here (REF CASE)...]',
                'include':
                True,
                'description':
                'No description entered.',
                'filename':
                THISDIR.joinpath(
                    'ca_ref_data',
                    'custom_ref_ad_Type_Scenario_1_Name_Here_REF_CASE_.csv')
            },
        ]
        self.ref_ca = customadoption.CustomAdoption(
            data_sources=ca_ref_data_sources,
            soln_adoption_custom_name=self.ac.soln_ref_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

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

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

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

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

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

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

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

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

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
Esempio n. 21
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)
Esempio n. 22
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
        ad_world_2018 = self.ac.ref_base_adoption['World']
        ad_2018 = pd.Series(self.ac.ref_base_adoption)
        tla_world_2050 = self.tla_per_region.loc[2050, 'World']

        degrade_rate_conservative = pd.Series(self.ac.degradation_rate,
                                              index=range(2014, 2061))

        degrade_rate_low = pd.Series(0, index=range(2014, 2061))
        degrade_rate_low.loc[2014] = self.ac.degradation_rate
        degrade_rate_low.loc[2020] = degrade_rate_low.loc[2014] / 2.0
        step = (degrade_rate_low.loc[2014] - degrade_rate_low.loc[2020]) / 6.0
        for year in range(2015, 2020):
            degrade_rate_low.loc[year] = degrade_rate_low.loc[2014] - (
                (year - 2014) * step)
        step = (degrade_rate_low.loc[2020] - degrade_rate_low.loc[2030]) / 10.0
        for year in range(2021, 2030):
            degrade_rate_low.loc[year] = degrade_rate_low.loc[2020] - (
                (year - 2020) * step)
        degrade_rate_low.loc[2030:] = 0.0

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

        # Data Source 1
        ds1_growth_rate = 0.0197583057035311
        ds1_datapoints = pd.DataFrame(0.0,
                                      index=range(2012, 2061),
                                      columns=dd.REGIONS)
        ds1_datapoints.loc[2012:2018, 'World'] = ad_world_2018
        ds1_maximum = 1035.0
        for year in range(2019, 2061):
            rate = 1 + ds1_growth_rate
            newval = ds1_datapoints.loc[year - 1, 'World'] * rate
            ds1_datapoints.loc[year, 'World'] = min(ds1_maximum, newval)

        # Data Source 2
        ds2_growth_rate = 0.0102232658124979
        ds2_datapoints = pd.DataFrame(0.0,
                                      index=range(2012, 2061),
                                      columns=dd.REGIONS)
        ds2_datapoints.loc[2012:2018, 'World'] = ad_world_2018
        ds2_maximum = 1016.0
        for year in range(2019, 2061):
            rate = 1 + ds2_growth_rate
            newval = ds2_datapoints.loc[year - 1, 'World'] * rate
            ds2_datapoints.loc[year, 'World'] = min(ds2_maximum, newval)

        # Data Source 3
        ds3_growth_rate = 0.00550564152557609
        ds3_datapoints = pd.DataFrame(0.0,
                                      index=range(2012, 2061),
                                      columns=dd.REGIONS)
        ds3_datapoints.loc[2012:2018, 'World'] = ad_world_2018
        ds3_maximum = 998.0
        for year in range(2019, 2061):
            rate = 1 + ds3_growth_rate
            newval = ds3_datapoints.loc[year - 1, 'World'] * rate
            ds3_datapoints.loc[year, 'World'] = min(ds3_maximum, newval)

        # Data Source 4
        ds4_growth_rate = 0.0197583057035311
        ds4_datapoints = pd.DataFrame(0.0,
                                      index=range(2012, 2061),
                                      columns=dd.REGIONS)
        ds4_datapoints.loc[2012:2018, 'World'] = ad_world_2018
        ds4_maximum = 1047.9
        for year in range(2019, 2061):
            rate = 1 + ds4_growth_rate
            newval = ds4_datapoints.loc[year - 1, 'World'] * rate
            ds4_datapoints.loc[year, 'World'] = min(ds4_maximum, newval)

        # Data Source 5
        ds5_growth_rate = 0.0102232658124979
        ds5_datapoints = pd.DataFrame(0.0,
                                      index=range(2012, 2061),
                                      columns=dd.REGIONS)
        ds5_datapoints.loc[2012:2018, 'World'] = ad_world_2018
        ds5_maximum = 1046.8
        for year in range(2019, 2061):
            rate = 1 + ds5_growth_rate
            newval = ds5_datapoints.loc[year - 1, 'World'] * rate
            ds5_datapoints.loc[year, 'World'] = min(ds5_maximum, newval)

        # Data Source 6
        ds6_growth_rate = 0.00550564152557609
        ds6_datapoints = pd.DataFrame(0.0,
                                      index=range(2012, 2061),
                                      columns=dd.REGIONS)
        ds6_datapoints.loc[2012:2018, 'World'] = ad_world_2018
        ds6_minimum = 1046.0
        for year in range(2019, 2061):
            rate = 1 + ds6_growth_rate
            newval = ds6_datapoints.loc[year - 1, 'World'] * rate
            ds6_datapoints.loc[year, 'World'] = min(ds6_minimum, newval)

        # Data Source 7
        ds7_constrained = constrained_tla(rate=degrade_rate_conservative)
        ds7_constrained_2050 = ds7_constrained.loc[2050, 'Constrained TLA']
        ds7_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds7_datapoints.loc[2014] = ad_2018
        ds7_datapoints.loc[2030] = (1.0 * ds7_constrained_2050)
        ds7_datapoints.loc[2050] = ds7_constrained_2050

        # Data Source 8
        ds8_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds8_datapoints.loc[2014] = ad_2018
        ds8_datapoints.loc[2030] = (0.9 * ds7_constrained_2050)
        ds8_datapoints.loc[2050] = ds7_constrained_2050

        # Data Source 9
        ds9_constrained = constrained_tla(rate=degrade_rate_low)
        ds9_constrained_2050 = ds9_constrained.loc[2050, 'Constrained TLA']
        ds9_datapoints = pd.DataFrame(columns=ca_pds_columns).set_index('Year')
        ds9_datapoints.loc[2014] = ad_2018
        ds9_datapoints.loc[2030] = (1.0 * ds9_constrained_2050)
        ds9_datapoints.loc[2050] = ds9_constrained_2050

        # Data Source 10
        ds10_datapoints = pd.DataFrame(
            columns=ca_pds_columns).set_index('Year')
        ds10_datapoints.loc[2014] = ad_2018
        ds10_datapoints.loc[2030] = (0.9 * ds9_constrained_2050)
        ds10_datapoints.loc[2050] = ds9_constrained_2050

        ca_pds_data_sources = [
            {
                'name':
                'High adoption and conservative degradation rate',
                'include':
                True,
                'description':
                ('The historical protected area evolution (1990-2015) in Morales-Hidalgo was '
                 'used to estimate three protected areas\' yearly increase rates: 1,98%; 1,02% '
                 'and 0,55% for the forest PA corresponding to 1990-2015, 2005- 2015 and '
                 '2010- 2015 respectively. This, coupled with the TLA\'s current degradation '
                 'rate of 0.31% result in scenarios 1, 2 and 3. The New York declaration on '
                 'Forests is used  to estimate an alternative degradation rate which starts '
                 'from 0.31% and linearly decreases to half its value in 2020 and then to '
                 'zero in 2030. The yearly increase rates from Morales- Hidalgo plus this '
                 'degradation rate result in scenarios 4, 5 and 6. '),
                'maximum':
                1035.0,
                'datapoints':
                ds1_datapoints
            },
            {
                'name':
                'Medium adoption and conservative degradation rate',
                'include':
                True,
                'description':
                ('The historical protected area evolution (1990-2015) in Morales-Hidalgo was '
                 'used to estimate three protected areas yearly increase rates: 1,98%; 1,02% '
                 'and 0,55% for the forest PA corresponding to 1990-2015, 2005- 2015 and '
                 '2010- 2015 respectively. This, coupled with the TLA\'s current degradation '
                 'rate of 0.31% result in scenarios 1, 2 and 3. The New York declaration on '
                 'Forests is used  to estimate an alternative degradation rate which starts '
                 'from 0.31% and linearly decreases to half its value in 2020 and then to '
                 'zero in 2030. The yearly increase rates from Morales- Hidalgo plus this '
                 'degradation rate result in scenarios 4, 5 and 6. '),
                'maximum':
                1016.0,
                'datapoints':
                ds2_datapoints
            },
            {
                'name':
                'Low adoption and conservative degradation rate',
                'include':
                True,
                'description':
                ('The historical protected area evolution (1990-2015) in Morales-Hidalgo was '
                 'used to estimate three protected areas yearly increase rates: 1,98%; 1,02% '
                 'and 0,55% for the forest PA corresponding to 1990-2015, 2005- 2015 and '
                 '2010- 2015 respectively. This, coupled with the TLA\'s current degradation '
                 'rate of 0.31% result in scenarios 1, 2 and 3. The New York declaration on '
                 'Forests is used  to estimate an alternative degradation rate which starts '
                 'from 0.31% and linearly decreases to half its value in 2020 and then to '
                 'zero in 2030. The yearly increase rates from Morales- Hidalgo plus this '
                 'degradation rate result in scenarios 4, 5 and 6. '),
                'maximum':
                998.0,
                'datapoints':
                ds3_datapoints
            },
            {
                'name':
                'High adoption and low degradation rate',
                'include':
                True,
                'description':
                ('The historical protected area evolution (1990-2015) in Morales-Hidalgo was '
                 'used to estimate three protected areas yearly increase rates: 1,98%; 1,02% '
                 'and 0,55% for the forest PA corresponding to 1990-2015, 2005- 2015 and '
                 '2010- 2015 respectively. This, coupled with the TLA\'s current degradation '
                 'rate of 0.31% result in scenarios 1, 2 and 3. The New York declaration on '
                 'Forests is used  to estimate an alternative degradation rate which starts '
                 'from 0.31% and linearly decreases to half its value in 2020 and then to '
                 'zero in 2030. The yearly increase rates from Morales- Hidalgo plus this '
                 'degradation rate result in scenarios 4, 5 and 6. '),
                'maximum':
                1047.9,
                'datapoints':
                ds4_datapoints
            },
            {
                'name':
                'Medium adoption and low degradation rate',
                'include':
                True,
                'description':
                ('The historical protected area evolution (1990-2015) in Morales-Hidalgo was '
                 'used to estimate three protected areas\' yearly increase rates: 1,98%; 1,02% '
                 'and 0,55% for the forest PA corresponding to 1990-2015, 2005- 2015 and '
                 '2010- 2015 respectively. This, coupled with the TLA\'s current degradation '
                 'rate of 0.31% result in scenarios 1, 2 and 3. The New York declaration on '
                 'Forests is used  to estimate an alternative degradation rate which starts '
                 'from 0.31% and linearly decreases to half its value in 2020 and then to '
                 'zero in 2030. The yearly increase rates from Morales- Hidalgo plus this '
                 'degradation rate result in scenarios 4, 5 and 6. '),
                'maximum':
                1046.8,
                'datapoints':
                ds5_datapoints
            },
            {
                'name':
                'Low adoption and low degradation rate',
                'include':
                True,
                'description':
                ('The historical protected area evolution (1990-2015) in Morales-Hidalgo was '
                 'used to estimate three protected areas\' yearly increase rates: 1,98%; 1,02% '
                 'and 0,55% for the forest PA corresponding to 1990-2015, 2005- 2015 and '
                 '2010- 2015 respectively. This, coupled with the TLA\'s current degradation '
                 'rate of 0.31% result in scenarios 1, 2 and 3. The New York declaration on '
                 'Forests is used  to estimate an alternative degradation rate which starts '
                 'from 0.31% and linearly decreases to half its value in 2020 and then to '
                 'zero in 2030. The yearly increase rates from Morales- Hidalgo plus this '
                 'degradation rate result in scenarios 4, 5 and 6. '),
                'maximum':
                1046,
                'datapoints':
                ds6_datapoints
            },
            {
                'name':
                '100% conservative degradation TLA in 2030',
                'include':
                True,
                'description':
                ('Linear increase up to 100% of TLA value in 2030 (calculated with the '
                 'conservative degradation rate) and TLA value from then onwards '
                 ),
                'maximum':
                ds7_constrained_2050,
                'datapoints':
                ds7_datapoints
            },
            {
                'name':
                '90% conservative degradation TLA in 2030',
                'include':
                True,
                'description':
                ('Linear increase up to 90% of TLA value in 2030 (calculated with the '
                 'conservative degradation rate) and then linear increase to 100% TLA value '
                 'in 2050 from then onwards '),
                'maximum':
                ds7_constrained_2050,
                'datapoints':
                ds8_datapoints
            },
            {
                'name':
                '100% low degradation TLA by 2030',
                'include':
                True,
                'description':
                ('Linear increase up to 100% of TLA value in 2030 (calculated with the low '
                 'degradation rate) and TLA value from then onwards '),
                'maximum':
                ds9_constrained_2050,
                'datapoints':
                ds9_datapoints
            },
            {
                'name':
                '90% low degradation TLA by 2030',
                'include':
                True,
                'description':
                ('Linear increase up to 90% of TLA value in 2030 (calculated with the low '
                 'degradation rate) and TLA value from then onwards '),
                'maximum':
                ds9_constrained_2050,
                'datapoints':
                ds10_datapoints
            },
        ]
        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=self.tla_per_region)

        for s in self.pds_ca.scenarios.values():
            df = s['df']
            df.loc[2014:2018, 'World'] = 651.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=False)
        soln_pds_tot_iunits_reqd = self.ua.soln_pds_tot_iunits_reqd()
        soln_ref_tot_iunits_reqd = self.ua.soln_ref_tot_iunits_reqd()
        conv_ref_tot_iunits = self.ua.conv_ref_tot_iunits()
        soln_net_annual_funits_adopted = self.ua.soln_net_annual_funits_adopted(
        )

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

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

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

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            tot_red_in_deg_land=self.ua.
            cumulative_reduction_in_total_degraded_land(),
            pds_protected_deg_land=self.ua.
            pds_cumulative_degraded_land_protected(),
            ref_protected_deg_land=self.ua.
            ref_cumulative_degraded_land_protected(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
Esempio n. 23
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)
Esempio n. 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)
        if self.ac.use_custom_tla:
            self.c_tla = tla.CustomTLA(
                filename=THISDIR.joinpath('custom_tla_data.csv'))
            custom_world_vals = self.c_tla.get_world_values()
        else:
            custom_world_vals = None
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution(),
            custom_world_values=custom_world_vals)

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Optimistic-Achieve Commitment in 15 years w/ 100% intact, (Charlotte Wheeler, 2016)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_OptimisticAchieve_Commitment_in_15_years_w_100_intact_Charlotte_Wheeler_2016.csv'
                )
            },
            {
                'name':
                'Optimistic-Achieve Commitment in 15 years w/ 100% intact, WRI estimates (Charlotte Wheeler, 2016)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_OptimisticAchieve_Commitment_in_15_years_w_100_intact_WRI_estimates_Charlotte_Wheeler_2016.csv'
                )
            },
            {
                'name':
                'Conservative-Achieve Commitment in 15 years w/ 44.2% intact, (Charlotte Wheeler,2016)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeAchieve_Commitment_in_15_years_w_44_2_intact_Charlotte_Wheeler2016.csv'
                )
            },
            {
                'name':
                'Conservative-Achieve Commitment in 15 years w/ 44.2% intact with continued growth post-2030, (Charlotte Wheeler,2016)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeAchieve_Commitment_in_15_years_w_44_2_intact_with_continued_growth_post2030__967aa8cc.csv'
                )
            },
            {
                'name':
                'Conservative-Achieve Commitment in 30 years w/ 100% intact, (Charlotte Wheeler,2016)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeAchieve_Commitment_in_30_years_w_100_intact_Charlotte_Wheeler2016.csv'
                )
            },
            {
                'name':
                'Conservative-Achieve Commitment in 30 years w/ 44.2% intact, (Charlotte Wheeler,2016)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeAchieve_Commitment_in_30_years_w_44_2_intact_Charlotte_Wheeler2016.csv'
                )
            },
            {
                'name':
                'Conservative-Achieve Commitment in 30 years w/ 44.2% intact with continued growth, (Charlotte Wheeler,2016)',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeAchieve_Commitment_in_30_years_w_44_2_intact_with_continued_growth_Charlotte_4167ecee.csv'
                )
            },
            {
                'name':
                'Conservative-Achieve Commitment in 45 years w/ 100% intact (Charlotte Wheeler,2016)',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeAchieve_Commitment_in_45_years_w_100_intact_Charlotte_Wheeler2016.csv'
                )
            },
            {
                'name':
                'Conservative-Achieve Commitment in 45 years w/ 44.2% intact (Charlotte Wheeler,2016)',
                'include':
                False,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_ConservativeAchieve_Commitment_in_45_years_w_44_2_intact_Charlotte_Wheeler2016.csv'
                )
            },
        ]
        self.pds_ca = customadoption.CustomAdoption(
            data_sources=ca_pds_data_sources,
            soln_adoption_custom_name=self.ac.soln_pds_adoption_custom_name,
            high_sd_mult=1.0,
            low_sd_mult=1.0,
            total_adoption_limit=self.tla_per_region)

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

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

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

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

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

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

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

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution())
Esempio n. 25
0
def test_ignore_allocation():
    trr_aez = aez.AEZ('Tropical Forest Restoration', ignore_allocation=True)
    res = trr_aez.soln_land_dist_df
    assert res[res == 1].all().all()
Esempio n. 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)
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution())

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.c2 = co2calcs.CO2Calcs(
            ac=self.ac,
            ch4_ppb_calculator=self.c4.ch4_ppb_calculator(),
            soln_pds_net_grid_electricity_units_saved=self.ua.
            soln_pds_net_grid_electricity_units_saved(),
            soln_pds_net_grid_electricity_units_used=self.ua.
            soln_pds_net_grid_electricity_units_used(),
            soln_pds_direct_co2eq_emissions_saved=self.ua.
            direct_co2eq_emissions_saved_land(),
            soln_pds_direct_co2_emissions_saved=self.ua.
            direct_co2_emissions_saved_land(),
            soln_pds_direct_n2o_co2_emissions_saved=self.ua.
            direct_n2o_co2_emissions_saved_land(),
            soln_pds_direct_ch4_co2_emissions_saved=self.ua.
            direct_ch4_co2_emissions_saved_land(),
            soln_pds_new_iunits_reqd=self.ua.soln_pds_new_iunits_reqd(),
            soln_ref_new_iunits_reqd=self.ua.soln_ref_new_iunits_reqd(),
            conv_ref_new_iunits=self.ua.conv_ref_new_iunits(),
            conv_ref_grid_CO2_per_KWh=self.ef.conv_ref_grid_CO2_per_KWh(),
            conv_ref_grid_CO2eq_per_KWh=self.ef.conv_ref_grid_CO2eq_per_KWh(),
            soln_net_annual_funits_adopted=soln_net_annual_funits_adopted,
            annual_land_area_harvested=self.ua.
            soln_pds_annual_land_area_harvested(),
            regime_distribution=self.ae.get_land_distribution(),
            regimes=dd.THERMAL_MOISTURE_REGIMES8)
Esempio n. 27
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)
Esempio n. 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)
        self.tla_per_region = tla.tla_per_region(
            self.ae.get_land_distribution())

        # Custom PDS Data
        ca_pds_data_sources = [
            {
                'name':
                'Low,High Early Adoption, Polynomial Trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_LowHigh_Early_Adoption_Polynomial_Trend.csv'
                )
            },
            {
                'name':
                'High,High Early Adoption, Polynomial Trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_HighHigh_Early_Adoption_Polynomial_Trend.csv'
                )
            },
            {
                'name':
                'Max, Polynomial Trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath('ca_pds_data',
                                 'custom_pds_ad_Max_Polynomial_Trend.csv')
            },
            {
                'name':
                'High, Early Adoption, Polynomial Trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_High_Early_Adoption_Polynomial_Trend.csv')
            },
            {
                'name':
                'Low, Early Adoption, Polynomial Trend',
                'include':
                True,
                'filename':
                THISDIR.joinpath(
                    'ca_pds_data',
                    'custom_pds_ad_Low_Early_Adoption_Polynomial_Trend.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([
            71.6843318543261, 21.7864515209236, 5.79724982776745,
            7.68605153649748, 0.244451347436256, 36.1701276217012, 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())
Esempio n. 29
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())
Esempio n. 30
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)
    if self.ac.use_custom_tla:
      self.c_tla = tla.CustomTLA(filename=THISDIR.joinpath('custom_tla_data.csv'))
      custom_world_vals = self.c_tla.get_world_values()
    else:
      custom_world_vals = None
    self.tla_per_region = tla.tla_per_region(self.ae.get_land_distribution(), custom_world_values=custom_world_vals)

    # Custom PDS Data
    ca_pds_columns = ['Year', 'World'] + dd.MAIN_REGIONS
    ca_pds_data_sources = [
      {'name': 'Average growth, linear trend', 'include': True,
          # This scenario is built on the historical (1962-2012) average global growth rate of
          # tropical staple crops. The historical data available for each decade was interpolated
          # based on the best curve fit and the interpolated data were then used in the
          # AdoptionData. The calculation uses the 2050 adopted value and calculates the
          # percentage with reference to the TLA, which is used to build this adoption scenario. 
          'datapoints': pd.DataFrame([
              [2014, 25.42446198181150, 0.0, 0.0, 0.0, 0.0, 0.0],
              [2050, self.tla_per_region.loc[2050, 'World'] * 0.6179095040166380,
                  0.0, 0.0, 0.0, 0.0, 0.0],
              ], columns=ca_pds_columns).set_index('Year')
          },
      {'name': 'Medium growth, linear trend', 'include': True,
          # This scenario is built on the historical (1962-2012) average global growth rate of
          # tropical staple crops. The historical data available for each decade was interpolated
          # based on the best curve fit and the interpolated data were then used in the
          # AdoptionData. This scenario presents the result assuming a 5% increase on the
          # historical growth rate. The calculation uses the 2050 adopted value and calculates
          # the percentage with reference to the TLA, which is used to build this adoption scenario.
          'datapoints': pd.DataFrame([
              [2014, 25.42446198181150, 0.0, 0.0, 0.0, 0.0, 0.0],
              [2050, self.tla_per_region.loc[2050, 'World'] * 0.648804979217470,
                  0.0, 0.0, 0.0, 0.0, 0.0],
              ], columns=ca_pds_columns).set_index('Year')
          },
      {'name': 'Low growth linear trend', 'include': True,
          # It is assumed that the adoption of tropical tree staples will reach 55% of its
          # TLA by 2050.
          'datapoints': pd.DataFrame([
              [2014, 25.42446198181150, 0.0, 0.0, 0.0, 0.0, 0.0],
              [2050, self.tla_per_region.loc[2050, 'World'] * 0.55, 0.0, 0.0, 0.0, 0.0, 0.0],
              ], columns=ca_pds_columns).set_index('Year')
          },
      {'name': 'Low early growth, linear trend', 'include': True,
          # This scenario assumes 60% adoption of the solution by 2030 and remains same until 2050.
          # The early adoption of the solution was considered because of the higher carbon and
          # financial impact of the solution and lower land availability.
          'datapoints': pd.DataFrame([
              [2014, 25.42446198181150, 0.0, 0.0, 0.0, 0.0, 0.0],
              [2030, self.tla_per_region.loc[2030, 'World'] * 0.6, 0.0, 0.0, 0.0, 0.0, 0.0],
              [2050, self.tla_per_region.loc[2050, 'World'] * 0.6, 0.0, 0.0, 0.0, 0.0, 0.0],
              ], columns=ca_pds_columns).set_index('Year')
          },
      {'name': 'Max early growth, linear trend', 'include': True,
          # This scenario assumes 100% adoption of the solution by 2050 with the assumption that
          # 70% of that adoption will be acheived by 2030. The early adoption of the solution was
          # considered because of the higher carbon and financial impact of the solution and lower
          # land availability.
          'datapoints': pd.DataFrame([
              [2014, 25.42446198181150, 0.0, 0.0, 0.0, 0.0, 0.0],
              [2030, self.tla_per_region.loc[2030, 'World'] * 0.7, 0.0, 0.0, 0.0, 0.0, 0.0],
              [2050, self.tla_per_region.loc[2050, 'World'] * 1.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)


    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(
      [25.424461981811515, 0.03142549034684199, 0.0, 28.59165470128803, 17.01389600193888,
       5.211947770049295, 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())