Multiple Inference¶
This notebook demonstrates how to run a complete simulation with multiple inferences
[14]:
from pathlib import Path
from buildingmodel.main import (
run_all,
Parameters,
run_multiple_inference,
run_parallel_inference,
get_case_summary,
)
from buildingmodel import data_path
import seaborn as sns
import pandas as pd
import geopandas as gpd
[3]:
parameters = Parameters(
districts="districts_test_sample.gpkg",
district_level_census="district_level_census_test_sample.hdf",
district_level_diagnosis="district_level_diagnosis_data_test_sample.hdf",
gas_network_route="gas_network_route_sample.gpkg",
max_iteration=5,
)
building_data = Path(data_path["gis"]) / "testing" / "test_sample.gpkg"
climate_data = Path(data_path["climate"]) / "Brest.epw"
[5]:
result_dicts = run_multiple_inference(building_data, climate_data, parameters)
/home/yassine/miniconda3/envs/buildingmodel_dev/lib/python3.8/site-packages/topojson/core/cut.py:112: ShapelyDeprecationWarning: STRtree will be changed in 2.0.0 and will not be compatible with versions < 2.
tree_splitter = STRtree(mp)
The results are contained in a list of dicts, with each dict containing the results of a single iteration
[8]:
len(result_dicts)
[8]:
5
[12]:
heating_systems = []
for i in range(5):
heating_systems.append(
result_dicts[i]["buildings"].groupby("heating_system").living_area.sum()
)
pd.concat(heating_systems, axis=1)
[12]:
living_area | living_area | living_area | living_area | living_area | |
---|---|---|---|---|---|
heating_system | |||||
biomass/coal boiler | 97.763742 | NaN | 366.372807 | 105.738981 | 105.738981 |
biomass/coal stove | 165.298166 | 377.446924 | 542.377794 | 384.661871 | 594.025749 |
electric heat pump | 194.981852 | 197.711972 | 133.118416 | 307.103694 | 325.842962 |
electric heater | 1973.564159 | 1876.964996 | 1366.230181 | 1940.063266 | 1675.594299 |
liquified petroleum gas boiler | 194.288916 | 90.897371 | 111.852418 | NaN | NaN |
oil boiler | 465.910346 | 465.155456 | 552.113633 | 329.396253 | 357.956677 |
[15]:
get_case_summary(result_dicts)
[15]:
annual_electricity_consumption | annual_electricity_heating | annual_electricity_dhw | annual_liquified_petroleum_gas_consumption | annual_liquified_petroleum_gas_heating | annual_liquified_petroleum_gas_dhw | annual_fossil_gas_consumption | annual_fossil_gas_heating | annual_fossil_gas_dhw | annual_oil_consumption | ... | dwelling_count | actual_heating_set_point | iteration_id | annual_electricity_specific | annual_electricity_cooking | annual_liquified_petroleum_gas_cooking | annual_fossil_gas_cooking | peak_electricity_cooking | peak_liquified_petroleum_gas_cooking | peak_fossil_gas_cooking | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 152616.590204 | 37564.595256 | 20300.626806 | 12414.496124 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 42921.030950 | ... | 31.0 | 20.0 | 0.0 | 76018.750000 | 15500.891473 | 12414.496124 | 0.0 | 5.166964 | 4.138165 | 0.0 |
1 | 247223.772754 | 112165.588862 | 36724.623957 | 11646.589147 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 39176.020230 | ... | 32.0 | 20.0 | 1.0 | 81850.000000 | 12951.046512 | 11646.589147 | 0.0 | 4.317016 | 3.882196 | 0.0 |
2 | 211886.236168 | 68490.673607 | 42707.896531 | 8493.740310 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 99354.833220 | ... | 33.0 | 20.0 | 2.0 | 84856.250000 | 14656.686047 | 8493.740310 | 0.0 | 4.885562 | 2.831247 | 0.0 |
3 | 208510.755739 | 68463.409467 | 44632.294039 | 14464.709302 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 78948.436067 | ... | 31.0 | 20.0 | 3.0 | 78662.500000 | 12701.476744 | 14464.709302 | 0.0 | 4.233826 | 4.821570 | 0.0 |
4 | 189712.753522 | 74758.622440 | 37451.014858 | 9816.796976 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 16941.837981 | ... | 26.0 | 20.0 | 4.0 | 61239.240255 | 16263.875969 | 9816.796976 | 0.0 | 5.421292 | 3.272266 | 0.0 |
5 rows × 65 columns
[19]:
result_dicts[0]["buildings"].to_crs("EPSG:4326").explore(
column="annual_electricity_consumption", cmap="viridis"
)
[19]:
Make this Notebook Trusted to load map: File -> Trust Notebook