Bases: Buildings
Milliman-specific subclass with field name overrides for Milliman data formats.
This class defines Milliman-specific field aliases that map their column names
to the standard Buildings fields, leveraging the existing alias system.
Initialize MillimanBuildings with Milliman-specific field aliases.
Parameters:
| Name |
Type |
Description |
Default |
gdf
|
GeoDataFrame
|
GeoDataFrame containing Milliman building data
|
required
|
overrides
|
Optional[Dict[str, str]]
|
Optional user overrides that take precedence over Milliman defaults
|
None
|
Source code in src/inland_consequences/milliman_buildings.py
| def __init__(self, gdf: gpd.GeoDataFrame, overrides: Optional[Dict[str, str]] = None):
"""
Initialize MillimanBuildings with Milliman-specific field aliases.
Args:
gdf: GeoDataFrame containing Milliman building data
overrides: Optional user overrides that take precedence over Milliman defaults
"""
# Define Milliman-specific field name mappings (keys = target fields, values = Milliman fields) from sample data
milliman_overrides = {
"id": "location",
"building_cost": "BLDG_VALUE",
"content_cost": "CNT_VALUE",
"general_building_type": "general_building_type", # created in preprocessing from CONSTR_CODE (imputed with "W" if missing)
"foundation_type": "foundation_type", # created in preprocessing from foundationtype (imputed with "SLAB" if missing)
"number_stories": "NUM_STORIES",
"first_floor_height": "FIRST_FLOOR_ELEV",
}
# Merge with user overrides (user overrides take precedence during unpacking)
if overrides is None:
final_overrides = milliman_overrides
else:
final_overrides = {**milliman_overrides, **overrides}
# Pre-process the GeoDataFrame (foundation and construction type conversion, imputation)
# This creates the standard 'foundation_type' and 'general_building_type' columns
gdf = self._preprocess_gdf(gdf)
# Ensure required fields are present
self._ensure_required_fields(gdf, final_overrides)
# Ensure required fields have no missing values
self._ensure_required_fields_complete(gdf, final_overrides)
# Delegate to base Buildings class with Milliman overrides
super().__init__(gdf, final_overrides)
|
Functions