Sorsogon. Step 3.b. Visualize transition scenarios¶
In [1]:
import datetime; print(datetime.datetime.now())
2018-04-09 11:47:05.326151
Notebook Abstract:
The following notebook visualize the the simple transition scenarios by plotting the total consumption over all simulation years and the per-capita consumption rate. Depending on the define scenarios the per-capita consumption rate can be maintained constant. The per-capita consumption value is computed as total consumption divided by population size.
Import libraries¶
In [2]:
from smum.microsim.util_plot import plot_data_projection
The visualization is performed with help of the module function
plot_data_projection()
.
Global variables¶
In [3]:
iterations = 1000
typ = 'resampled'
model_name = 'Sorsogon_Electricity_Water_wbias_projected_dynamic_{}'.format(typ)
reweighted_survey = 'data/survey_{}_{}'.format(model_name, iterations)
Base scenario¶
In [4]:
var = ['Income', 'Water', 'Electricity']
data = plot_data_projection(
reweighted_survey, var, "{}, {}".format(iterations, typ),
benchmark_year=2016,
)
Base scenario grouped by Urban-Rural households¶
In [5]:
var = ['Income', 'Water', 'Electricity']
groupby = 'i_Urbanity'
data = plot_data_projection(
reweighted_survey, var, "{}, {} by {}".format(iterations, typ, groupby),
benchmark_year = 2016,
groupby = groupby
)
Base scenario grouped by family size¶
In [6]:
var = ['Income', 'Water', 'Electricity']
groupby = 'i_FamilySize'
data = plot_data_projection(
reweighted_survey, var, "{}, {} by {}".format(iterations, typ, groupby),
benchmark_year = 2016,
groupby = groupby
)
Base scenario grouped by AC ownership¶
In [7]:
var = ['Income', 'Water', 'Electricity']
groupby = 'e_AC'
data = plot_data_projection(
reweighted_survey, var, "{}, {} by {}".format(iterations, typ, groupby),
benchmark_year = 2016,
verbose = False,
groupby = groupby
)
Scenario 1 compared to base scenario¶
In [8]:
import numpy as np
pr = [i for i in np.linspace(0, 0.3, num=15)]
pr = [0]*6 + pr
scenario_name = 'scenario 1'
In [9]:
reweighted_survey
Out[9]:
'data/survey_Sorsogon_Electricity_Water_wbias_projected_dynamic_resampled_1000'
In [10]:
variables = ['Income', 'Water', 'Electricity']
for var in variables:
var = [var]
data = plot_data_projection(
reweighted_survey, var, "{}, {}, alt. scenario 1".format(iterations, typ),
benchmark_year=2016, pr = pr, scenario_name = scenario_name,
aspect_ratio = 2,
)
Scenario 1 grouped by education¶
In [11]:
variables = ['Income', 'Water', 'Electricity']
groupby = 'i_Education'
for var in variables:
var = [var]
data = plot_data_projection(
reweighted_survey, var, "{}, {} by {}, alt. scenario 1".format(iterations, typ, groupby),
#benchmark_year=2016,
pr = pr, scenario_name = scenario_name,
groupby = groupby,
aspect_ratio = 2,
)
In [12]:
import numpy as np
pr = [i for i in np.linspace(0, 0.6, num=15)]
pr = [0]*6 + pr
scenario_name = 'scenario 2'
Scenario 2 compared to base scenario¶
In [13]:
variables = ['Income', 'Water', 'Electricity']
for var in variables:
var = [var]
data = plot_data_projection(
reweighted_survey, var, "{}, {}, alt. scenario 2".format(iterations, typ),
benchmark_year=2016, pr = pr, scenario_name = scenario_name,
aspect_ratio = 2,
)
Scenario 2 grouped by education¶
In [14]:
variables = ['Income', 'Water', 'Electricity']
groupby = 'i_Education'
for var in variables:
var = [var]
data = plot_data_projection(
reweighted_survey, var, "{}, {} by {}, alt. scenario 2".format(iterations, typ, groupby),
#benchmark_year=2016,
pr = pr, scenario_name = scenario_name,
groupby = groupby,
aspect_ratio = 2,
)
Scenario 2 grouped by education, cross tabulation¶
In [15]:
from smum.microsim.util_plot import cross_tab
In [16]:
a = 'Water'
b = 'i_Education'
ct = cross_tab(a, b, 2030, reweighted_survey + "_{}_scenario 2_0.60.csv", split_a = True)
data saved as: data/Water_i_Education_2030.xlsx
In [17]:
ct
Out[17]:
i_Education | Education_College | Education_Elementary_School | Education_High_School | Education_Post_Graduate | Education_Post_Secondary |
---|---|---|---|---|---|
Water | |||||
Low | NaN | 5764.04 | 2933.70 | NaN | 70.00 |
mid-Low | NaN | 560.96 | 2584.57 | NaN | 9002.94 |
Middle | 1212.00 | NaN | 94.72 | NaN | 5369.71 |
mid-High | 9647.67 | NaN | NaN | 1807.0 | 282.68 |
High | 4434.33 | NaN | NaN | 1142.0 | NaN |
In [18]:
iterations = 1000
typ = 'resampled'
model_name = 'Sorsogon_Electricity_Water_wbias_projected_dynamic_{}'.format(typ)
reweighted_survey = 'data/survey_{}_{}'.format(model_name, iterations)
In [19]:
a = 'Electricity'
b = 'i_Education'
ct = cross_tab(a, b, 2030, reweighted_survey + "_{}_scenario 2_0.60.csv", split_a = True)
data saved as: data/Electricity_i_Education_2030.xlsx
In [20]:
ct
Out[20]:
i_Education | Education_College | Education_Elementary_School | Education_High_School | Education_Post_Graduate | Education_Post_Secondary |
---|---|---|---|---|---|
Electricity | |||||
Low | NaN | 2033.00 | 1886.00 | NaN | 4222.00 |
mid-Low | 5259.0 | 1009.25 | 96.89 | 283.0 | 5919.00 |
Middle | 5559.0 | 2934.69 | 2283.14 | 1797.0 | 56.18 |
mid-High | NaN | 348.06 | 1346.96 | NaN | 4509.38 |
High | 4476.0 | NaN | NaN | 869.0 | 18.77 |