Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#289 add damage unit #292

Merged
merged 11 commits into from
Apr 24, 2024
1 change: 1 addition & 0 deletions hydromt_fiat/api/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ExposureBuildingsSettings(BaseModel):
unit: Units
extraction_method: ExtractionMethod
damage_types : Optional[List[str]] = None
damage_unit: str


class ExposureSetupGroundFloorHeight(BaseModel):
Expand Down
2 changes: 2 additions & 0 deletions hydromt_fiat/api/exposure_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def set_asset_locations_source_and_get_data(
logger=self.logger,
region=region,
crs=crs,
damage_unit= "$"
)

self.exposure.setup_buildings_from_single_source(
Expand Down Expand Up @@ -111,6 +112,7 @@ def set_asset_locations_source(
unit=Units.ft.value, # TODO: make flexible
extraction_method=ExtractionMethod.centroid.value,
damage_types=["structure", "content"],
damage_unit = "$"
)
elif source == "file" and fiat_key_maps is not None:
# maybe save fiat_key_maps file in database
Expand Down
12 changes: 9 additions & 3 deletions hydromt_fiat/fiat.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def setup_exposure_buildings(
occupancy_attr: Union[str, None] = None,
occupancy_object_type: Union[str, List[str]] = None,
extraction_method: str = "centroid",
damage_types: List[str] = ["structure", "content"],
damage_types: List[str] = ["structure", "content"],
damage_unit: str = "$",
country: Union[str, None] = None,
ground_elevation_file: Union[int, float, str, Path, None] = None,
) -> None:
Expand Down Expand Up @@ -324,14 +325,16 @@ def setup_exposure_buildings(
The damage types that should be used for the exposure data, by default
["structure", "content"]. The damage types are used to link the
vulnerability functions to the exposure data.
damage_unit: str, optional
The currency/unit of the Damage data, default in USD $
country : Union[str, None], optional
The country that is used for the exposure data, by default None. This is
only required when using the JRC vulnerability curves.
"""
# In case the unit is passed as a pydantic value get the string
if hasattr(unit, "value"):
unit = unit.value
self.exposure = ExposureVector(self.data_catalog, self.logger, self.region, unit=unit)
self.exposure = ExposureVector(self.data_catalog, self.logger, self.region, unit=unit, damage_unit=damage_unit)

if asset_locations == max_potential_damage:
# The source for the asset locations, occupancy type and maximum potential
Expand Down Expand Up @@ -382,13 +385,15 @@ def setup_exposure_buildings(
self.set_config("exposure.csv.file", "./exposure/exposure.csv")
self.set_config("exposure.geom.crs", self.exposure.crs)
self.set_config("exposure.geom.unit", unit)
self.set_config("exposure.damage_unit", damage_unit)

def setup_exposure_roads(
self,
roads_fn: Union[str, Path],
road_damage: Union[str, Path, int],
road_types: Union[str, List[str], bool] = True,
unit: str = "m",

):
"""Setup road exposure data for Delft-FIAT.

Expand All @@ -401,7 +406,7 @@ def setup_exposure_roads(
"""
if not self.exposure:
self.exposure = ExposureVector(
self.data_catalog, self.logger, self.region, unit=unit
self.data_catalog, self.logger, self.region, unit=unit,
)
self.exposure.setup_roads(roads_fn, road_damage, road_types)

Expand Down Expand Up @@ -962,6 +967,7 @@ def read_tables(self):
crs=self.get_config("exposure.geom.crs"),
logger=self.logger,
unit=self.get_config("exposure.geom.unit"),
damage_unit= self.get_config("exposure.damage_unit"),
data_catalog=self.data_catalog, # TODO: See if this works also when no data catalog is provided
)
self.exposure.read_table(exposure_fn)
Expand Down
1 change: 1 addition & 0 deletions hydromt_fiat/interface/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ExposureGeomModel(BaseModel):
file1: str
file2: str
unit: str
damage_unit: str


class ExposureModel(BaseModel):
Expand Down
4 changes: 4 additions & 0 deletions hydromt_fiat/workflows/exposure_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(
region: gpd.GeoDataFrame = None,
crs: str = None,
unit: str = "m",
damage_unit = "$"
) -> None:
"""Transforms data into Vector Exposure data for Delft-FIAT.

Expand All @@ -85,13 +86,16 @@ def __init__(
The region of interest, by default None
crs : str, optional
The CRS of the Exposure data, by default None
damage_unit : str, optional
The unit/currency of the (potential) damages, by default USD$
"""
super().__init__(
data_catalog=data_catalog, logger=logger, region=region, crs=crs
)
self.exposure_db = pd.DataFrame()
self.exposure_geoms = list() # A list of GeoDataFrames
self.unit = unit
self.damage_unit = damage_unit
self._geom_names = list() # A list of (original) names of the geometry (files)

def bounding_box(self):
Expand Down
Loading