1
|
|
|
"""Create a basic scenario from the internal data structure. |
2
|
|
|
|
3
|
|
|
SPDX-FileCopyrightText: 2016-2019 Uwe Krien <[email protected]> |
4
|
|
|
|
5
|
|
|
SPDX-License-Identifier: MIT |
6
|
|
|
""" |
7
|
|
|
|
8
|
|
|
import pandas as pd |
9
|
|
|
from reegis import mobility |
10
|
|
|
from scenario_builder import config as cfg |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
def scenario_mobility(year, table): |
14
|
|
|
""" |
15
|
|
|
|
16
|
|
|
Parameters |
17
|
|
|
---------- |
18
|
|
|
year |
19
|
|
|
table |
20
|
|
|
|
21
|
|
|
Returns |
22
|
|
|
------- |
23
|
|
|
|
24
|
|
|
Examples |
25
|
|
|
-------- |
26
|
|
|
>>> table = scenario_mobility(2015, {}) |
27
|
|
|
>>> table["mobility_mileage"]["DE"].sum() |
28
|
|
|
diesel 3.769021e+11 |
29
|
|
|
petrol 3.272263e+11 |
30
|
|
|
other 1.334462e+10 |
31
|
|
|
dtype: float64 |
32
|
|
|
>>> table["mobility_spec_demand"]["DE"].loc["passenger car"] |
33
|
|
|
diesel 0.067 |
34
|
|
|
petrol 0.079 |
35
|
|
|
other 0.000 |
36
|
|
|
Name: passenger car, dtype: float64 |
37
|
|
|
>>> table["mobility_energy_content"]["DE"]["diesel"] |
38
|
|
|
energy_per_liter [MJ/l] 34.7 |
39
|
|
|
Name: diesel, dtype: float64 |
40
|
|
|
""" |
41
|
|
|
|
42
|
|
|
table["mobility_mileage"] = mobility.get_mileage_by_type_and_fuel(year) |
43
|
|
|
|
44
|
|
|
# fetch table of specific demand by fuel and vehicle type (from 2011) |
45
|
|
|
table["mobility_spec_demand"] = ( |
46
|
|
|
pd.DataFrame( |
47
|
|
|
cfg.get_dict_list("fuel consumption"), |
48
|
|
|
index=["diesel", "petrol", "other"], |
49
|
|
|
) |
50
|
|
|
.astype(float) |
51
|
|
|
.transpose() |
52
|
|
|
) |
53
|
|
|
|
54
|
|
|
# fetch the energy content of the different fuel types |
55
|
|
|
table["mobility_energy_content"] = pd.DataFrame( |
56
|
|
|
cfg.get_dict("energy_per_liter"), index=["energy_per_liter [MJ/l]"] |
57
|
|
|
)[["diesel", "petrol", "other"]] |
58
|
|
|
|
59
|
|
|
for key in [ |
60
|
|
|
"mobility_mileage", |
61
|
|
|
"mobility_spec_demand", |
62
|
|
|
"mobility_energy_content", |
63
|
|
|
]: |
64
|
|
|
# Add "DE" as region level to be consistent to other tables |
65
|
|
|
table[key].columns = pd.MultiIndex.from_product( |
66
|
|
|
[["DE"], table[key].columns] |
67
|
|
|
) |
68
|
|
|
return table |
69
|
|
|
|