Brussels. Step 3.a.2 Defining simple transition scenarios NR

In [1]:
import datetime; print(datetime.datetime.now())
2018-04-09 10:51:22.613149

Notebook Abstract:

The following notebook describes the process to construct simple transition scenarios.

The transition scenarios are define as efficiency rates induced by technology development or behavioral changes. These rates can be used as proxies for all types of efficiency improvements.

In order to define transition scenarios the model need the following information:

  1. A technology penetration rate. This defines the share of the population adopting the technology. The model uses sampling rules for the selection of the population adopting this technology.
  2. Development of efficiency rates. This define the actual technology development rate.

Import libraries

In [2]:
from smum.microsim.run import transition_rate
from smum.microsim.util_plot import plot_transition_rate
from smum.microsim.run import reduce_consumption
/usr/lib/python3.6/site-packages/h5py-2.7.1-py3.6-linux-x86_64.egg/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters

In order to compute the transition scenarios we make use of three modules of the urbanmetabolism library:

  1. growth_rate. This module will return a vector with linear growth rates given a starting and end rate.
  2. plot_growth_rate. This a simple function to visualize the defined growth rates.
  3. reduce_consumption. This function creates new samples with reduced consumption levels for the selected selection of the population.

Define simple population selection rules

In [3]:
sampling_rules = {
    "e_BuildingSqm >= 2000": 10,
}

Part of the scenario development is to identified which section of the population will adopt the new technology. The model defined this by a sampling probability. This probability is initially define as a uniform distribution (i.e. each individual on the sample has equal probability of being selected). A scenario is defined by allocating new sampling probabilities to a section of the population, by defining sampling rules. The sampling rules are passes to the query function of a pandas DataFrame.

On the example above, all individuals with a Income larger of equal to 180 000 Philippine Pesos are 30 times more likely to adopt the technology that the rest of the population. The sampling probabilities will sum up. This means that an individual with Income >= 180000 and living on an urban area e_Urban == 'Urbanity_Urban' is 60 times more likely to be selected (i.e. adopt a new technology) that other individuals.

Initial sample data

In [4]:
import pandas as pd
typ = 'resampled'
file_name = "data/survey_Brussels_NonResidentialElectricity_wbias_projected_dynamic_resampled_10000_{}.csv"
sample_survey = pd.read_csv(file_name.format(2016), index_col=0)
sample_survey.head()
Out[4]:
index e_BuildingSqm elec heat cool w wf
0 0 3600.0 0.000000 0.000000 0.000000 6.3048 9.524821
1 1 525.0 66742.068354 94458.852064 0.000000 6.3048 13.568532
2 2 525.0 66742.068354 31486.284021 140893.979372 6.3048 13.568532
3 3 39.0 0.000000 117168.862933 65124.328243 6.3048 14.207635
4 4 525.0 0.000000 15185.242330 46964.659791 6.3048 13.568532

The reduce_consumption module will use as input the samples created by the MCMC algorithm and select specific sections of the population to reduce their consumption levels.

The input data is the constructed proxy sample data. Depending on the simulation type (reweight/resample) the input data is a single file containing the weights for each simulation year (reweight) or individual samples for each simulation year (resample).

Most of the variables of the sample data is formatted as categorical data. The sample data shown above presents individual records with the predefine simulation variables as well as the computed Electricity and Water consumption levels. The sample also contains two sets of weights: w and wf. The w weights correspond to the weights assign by the MCMC algorithm (uniform distributed) while the wf (final weights) are the weights computed by the GREGWT algorithm. The reduce_consumption function will use the wf weights for the selection of individuals.

Define growth rates

In [5]:
elec = transition_rate(0, 0.2, default_start=2016, default_end=2025)
heat = transition_rate(0, 0.1, default_start=2016, default_end=2025)
cool = transition_rate(0, -0.2, default_start=2016, default_end=2025)
pr   = transition_rate(0, 0.3, default_start=2016, default_end=2025)

With help of the growth_rate() function we define the efficiency growth rate and the technology penetration rate. For the technology penetration rate we define the start year to be equal to the benchmark year (2016). The function will automatically include the necessary zeros at the beginning of the growth rate vector. The function plot_growth_rate() allow us to visualize the predefined efficiency growth rates and the technology growth rates.

In [6]:
plot_transition_rate(
    {"Technology penetration rate": pr,
     "Electricity efficiency increase rate": elec,
     "Heating efficiency increase rate": heat,
     "Cooling efficiency increase rate": cool},
     "scenario 1", ylim_a=(0.5, 1.5), start_year=2016, end_year=2025)
../../_images/example_be_Ca_DefineTransitions_NR_16_0.png

Reduce consumption

The actual modifications on the sample is performed by the reduce_consumption() function. The function requires as input the following parameters:

  1. A base file name for the samples (in case of implementing the resample method).
  2. The sample year (in this case generated within the loop via range(2010, 2031).
  3. The penetration rate for the sample year (iterated from vector pr).
  4. The predefined sampling_rules.
  5. A dictionary containing the efficiency rates for specific variables. (in this case for Electricity and Water).
  6. A name for the scenario.
In [7]:
for y, p, e, h, c in zip(range(2016, 2026), pr, elec, heat, cool):
    _ = reduce_consumption(
        file_name,
        y, p, sampling_rules,
        {'elec':e, 'heat':h, 'cool':c},
        scenario_name = "scenario 1")
00.00%      both       reduction; efficiency rate 00.00%;              year 2016 and penetration rate 00.00
00.02%      elec       reduction; efficiency rate 02.22%;              year 2017 and penetration rate 00.03
00.04%      heat       reduction; efficiency rate 01.11%;              year 2017 and penetration rate 00.03
-0.03%      cool       reduction; efficiency rate -2.22%;              year 2017 and penetration rate 00.03
00.08%      elec       reduction; efficiency rate 04.44%;              year 2018 and penetration rate 00.07
00.11%      heat       reduction; efficiency rate 02.22%;              year 2018 and penetration rate 00.07
-0.25%      cool       reduction; efficiency rate -4.44%;              year 2018 and penetration rate 00.07
00.18%      elec       reduction; efficiency rate 06.67%;              year 2019 and penetration rate 00.10
00.26%      heat       reduction; efficiency rate 03.33%;              year 2019 and penetration rate 00.10
-0.52%      cool       reduction; efficiency rate -6.67%;              year 2019 and penetration rate 00.10
00.31%      elec       reduction; efficiency rate 08.89%;              year 2020 and penetration rate 00.13
00.43%      heat       reduction; efficiency rate 04.44%;              year 2020 and penetration rate 00.13
-0.85%      cool       reduction; efficiency rate -8.89%;              year 2020 and penetration rate 00.13
00.51%      elec       reduction; efficiency rate 11.11%;              year 2021 and penetration rate 00.17
00.66%      heat       reduction; efficiency rate 05.56%;              year 2021 and penetration rate 00.17
-1.15%      cool       reduction; efficiency rate -11.11%;              year 2021 and penetration rate 00.17
00.74%      elec       reduction; efficiency rate 13.33%;              year 2022 and penetration rate 00.20
01.16%      heat       reduction; efficiency rate 06.67%;              year 2022 and penetration rate 00.20
-1.95%      cool       reduction; efficiency rate -13.33%;              year 2022 and penetration rate 00.20
01.06%      elec       reduction; efficiency rate 15.56%;              year 2023 and penetration rate 00.23
01.51%      heat       reduction; efficiency rate 07.78%;              year 2023 and penetration rate 00.23
-2.38%      cool       reduction; efficiency rate -15.56%;              year 2023 and penetration rate 00.23
01.27%      elec       reduction; efficiency rate 17.78%;              year 2024 and penetration rate 00.27
01.63%      heat       reduction; efficiency rate 08.89%;              year 2024 and penetration rate 00.27
-2.70%      cool       reduction; efficiency rate -17.78%;              year 2024 and penetration rate 00.27
01.73%      elec       reduction; efficiency rate 20.00%;              year 2025 and penetration rate 00.30
02.32%      heat       reduction; efficiency rate 10.00%;              year 2025 and penetration rate 00.30
-3.81%      cool       reduction; efficiency rate -20.00%;              year 2025 and penetration rate 00.30
In [8]:
elec = transition_rate(0, 0.3, default_start=2016, default_end=2025)
heat = transition_rate(0, 0.2, default_start=2016, default_end=2025)
cool = transition_rate(0, -0.3, default_start=2016, default_end=2025)
pr   = transition_rate(0, 0.3, default_start=2016, default_end=2025)

By modifying the growht rates we can create different scenarios.

In [9]:
plot_transition_rate(
    {"Technology penetration rate": pr,
     "Electricity efficiency increase rate": elec,
     "Heating efficiency increase rate": heat,
     "Cooling efficiency increase rate": cool},
     "scenario 2", ylim_a=(0.5, 1.5), start_year=2016, end_year=2025)
../../_images/example_be_Ca_DefineTransitions_NR_22_0.png
In [10]:
for y, p, e, h, c in zip(range(2016, 2026), pr, elec, heat, cool):
    _ = reduce_consumption(
        file_name,
        y, p, sampling_rules,
        {'elec':e, 'heat':h, 'cool':c},
        scenario_name = "scenario 2")
00.00%      both       reduction; efficiency rate 00.00%;              year 2016 and penetration rate 00.00
00.03%      elec       reduction; efficiency rate 03.33%;              year 2017 and penetration rate 00.03
00.06%      heat       reduction; efficiency rate 02.22%;              year 2017 and penetration rate 00.03
-0.06%      cool       reduction; efficiency rate -3.33%;              year 2017 and penetration rate 00.03
00.11%      elec       reduction; efficiency rate 06.67%;              year 2018 and penetration rate 00.07
00.32%      heat       reduction; efficiency rate 04.44%;              year 2018 and penetration rate 00.07
-0.25%      cool       reduction; efficiency rate -6.67%;              year 2018 and penetration rate 00.07
00.29%      elec       reduction; efficiency rate 10.00%;              year 2019 and penetration rate 00.10
00.48%      heat       reduction; efficiency rate 06.67%;              year 2019 and penetration rate 00.10
-0.71%      cool       reduction; efficiency rate -10.00%;              year 2019 and penetration rate 00.10
00.43%      elec       reduction; efficiency rate 13.33%;              year 2020 and penetration rate 00.13
00.61%      heat       reduction; efficiency rate 08.89%;              year 2020 and penetration rate 00.13
-0.96%      cool       reduction; efficiency rate -13.33%;              year 2020 and penetration rate 00.13
00.76%      elec       reduction; efficiency rate 16.67%;              year 2021 and penetration rate 00.17
01.11%      heat       reduction; efficiency rate 11.11%;              year 2021 and penetration rate 00.17
-2.30%      cool       reduction; efficiency rate -16.67%;              year 2021 and penetration rate 00.17
01.15%      elec       reduction; efficiency rate 20.00%;              year 2022 and penetration rate 00.20
01.62%      heat       reduction; efficiency rate 13.33%;              year 2022 and penetration rate 00.20
-3.18%      cool       reduction; efficiency rate -20.00%;              year 2022 and penetration rate 00.20
01.51%      elec       reduction; efficiency rate 23.33%;              year 2023 and penetration rate 00.23
02.45%      heat       reduction; efficiency rate 15.56%;              year 2023 and penetration rate 00.23
-3.70%      cool       reduction; efficiency rate -23.33%;              year 2023 and penetration rate 00.23
02.00%      elec       reduction; efficiency rate 26.67%;              year 2024 and penetration rate 00.27
02.78%      heat       reduction; efficiency rate 17.78%;              year 2024 and penetration rate 00.27
-4.34%      cool       reduction; efficiency rate -26.67%;              year 2024 and penetration rate 00.27
02.53%      elec       reduction; efficiency rate 30.00%;              year 2025 and penetration rate 00.30
03.50%      heat       reduction; efficiency rate 20.00%;              year 2025 and penetration rate 00.30
-5.70%      cool       reduction; efficiency rate -30.00%;              year 2025 and penetration rate 00.30