CHEERSafe Inventory and Building Geometry¶
This notebook loads bundled building archetypes, inspects constructor inputs, and visualizes derived roof sheathing panel coordinates.
In [1]:
Copied!
from pathlib import Path
import os
repo_root = Path.cwd()
while not (repo_root / "pyproject.toml").exists() and repo_root != repo_root.parent:
repo_root = repo_root.parent
os.chdir(repo_root)
repo_root
from pathlib import Path
import os
repo_root = Path.cwd()
while not (repo_root / "pyproject.toml").exists() and repo_root != repo_root.parent:
repo_root = repo_root.parent
os.chdir(repo_root)
repo_root
Out[1]:
PosixPath('/home/mammad/Documents/EDU/cope/CHEERSafe/LossModel')
In [2]:
Copied!
from cheersafe.config import Config
Config.reset_flags()
Config.NUM_OF_WORKERS = 1
Config.NUM_OF_WORKERS_SAMPLING = 1
Config.RANDOM_SEED = 42
from cheersafe.config import Config
Config.reset_flags()
Config.NUM_OF_WORKERS = 1
Config.NUM_OF_WORKERS_SAMPLING = 1
Config.RANDOM_SEED = 42
In [3]:
Copied!
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from cheersafe.inventory import Building, BuildingInventory
from cheersafe.tools import Utils
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from cheersafe.inventory import Building, BuildingInventory
from cheersafe.tools import Utils
In [4]:
Copied!
inventory = BuildingInventory(buildings_file_name="BuildingGeometry_Old.json")
summary = pd.DataFrame([
{
"BldgType": b.BldgType,
"RoofShape": "hip" if b.RoofShape == 1 else "gable",
"Length_ft": b.BldgLength,
"Width_ft": b.BldgWidth,
"MeanRoofHeight_ft": b.MeanRoofHeight,
"Panels": int(np.sum(b.NumPanel)),
"Connections": int(np.sum(b.NumConnection)),
}
for b in inventory.buildings
])
summary
inventory = BuildingInventory(buildings_file_name="BuildingGeometry_Old.json")
summary = pd.DataFrame([
{
"BldgType": b.BldgType,
"RoofShape": "hip" if b.RoofShape == 1 else "gable",
"Length_ft": b.BldgLength,
"Width_ft": b.BldgWidth,
"MeanRoofHeight_ft": b.MeanRoofHeight,
"Panels": int(np.sum(b.NumPanel)),
"Connections": int(np.sum(b.NumConnection)),
}
for b in inventory.buildings
])
summary
Out[4]:
| BldgType | RoofShape | Length_ft | Width_ft | MeanRoofHeight_ft | Panels | Connections | |
|---|---|---|---|---|---|---|---|
| 0 | 1 | hip | 60.0 | 30.0 | 12.125 | 96 | 94 |
| 1 | 2 | gable | 60.0 | 30.0 | 12.125 | 80 | 74 |
| 2 | 3 | hip | 60.0 | 30.0 | 12.125 | 96 | 94 |
| 3 | 4 | gable | 60.0 | 30.0 | 12.125 | 80 | 74 |
| 4 | 5 | hip | 60.0 | 30.0 | 21.125 | 96 | 94 |
| 5 | 6 | gable | 60.0 | 30.0 | 21.125 | 80 | 74 |
| 6 | 7 | hip | 60.0 | 30.0 | 21.125 | 96 | 94 |
| 7 | 8 | gable | 60.0 | 30.0 | 21.125 | 80 | 74 |
In [5]:
Copied!
building = inventory.buildings[0]
fig, ax = plt.subplots(figsize=(8, 4))
for idx in range(int(np.sum(building.NumPanel))):
x = building.PanelCoordinate[[0, 1, 3, 2, 0], idx]
y = building.PanelCoordinate[[4, 4, 5, 5, 4], idx]
ax.plot(x, y, color="tab:blue", alpha=0.35)
ax.set_title(f"Building type {building.BldgType}: derived roof panel layout")
ax.set_xlabel("x coordinate (ft)")
ax.set_ylabel("y coordinate (ft)")
ax.set_aspect("equal", adjustable="box")
plt.show()
building = inventory.buildings[0]
fig, ax = plt.subplots(figsize=(8, 4))
for idx in range(int(np.sum(building.NumPanel))):
x = building.PanelCoordinate[[0, 1, 3, 2, 0], idx]
y = building.PanelCoordinate[[4, 4, 5, 5, 4], idx]
ax.plot(x, y, color="tab:blue", alpha=0.35)
ax.set_title(f"Building type {building.BldgType}: derived roof panel layout")
ax.set_xlabel("x coordinate (ft)")
ax.set_ylabel("y coordinate (ft)")
ax.set_aspect("equal", adjustable="box")
plt.show()
Manual mode exposes the same calculations as returned values.
In [6]:
Copied!
Config.AUTO_LOAD_DATASETS = False
Config.AUTO_EXECUTE_METHODS = False
raw = Utils.from_json("Inputs/BuildingGeometry_Old.json")
manual_building = Building(*raw[:, 1])
manual_building.PanelCoordinate, manual_building.NumPanel = manual_building.fn_panel_coordinate()
manual_building.ConnectionCoordinate, manual_building.NumConnection = manual_building.fn_connection_coordinate()
print(f"manual building type: {manual_building.BldgType}")
print(f"panel count: {int(np.sum(manual_building.NumPanel))}")
Config.reset_flags()
Config.AUTO_LOAD_DATASETS = False
Config.AUTO_EXECUTE_METHODS = False
raw = Utils.from_json("Inputs/BuildingGeometry_Old.json")
manual_building = Building(*raw[:, 1])
manual_building.PanelCoordinate, manual_building.NumPanel = manual_building.fn_panel_coordinate()
manual_building.ConnectionCoordinate, manual_building.NumConnection = manual_building.fn_connection_coordinate()
print(f"manual building type: {manual_building.BldgType}")
print(f"panel count: {int(np.sum(manual_building.NumPanel))}")
Config.reset_flags()
manual building type: 2 panel count: 80