Skip to content

Commit

Permalink
Merge pull request #174 from Deltares/env_fix
Browse files Browse the repository at this point in the history
Update fiat_integrator with env_fix
  • Loading branch information
frederique-hub authored Oct 13, 2023
2 parents de2e12d + 6fadf32 commit b6399cf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
7 changes: 3 additions & 4 deletions hydromt_fiat/fiat.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ def setup_hazard(
# da = da.squeeze('timemax').drop('timemax')
da = da.isel(timemax=0).drop("timemax")

# Convert to units of the exposure data if required
if self.exposure.unit != da.units:
da = da * unit_conversion_factor

else:
if not self.region.empty:
Expand All @@ -415,6 +412,7 @@ def setup_hazard(
da = self.data_catalog.get_rasterdataset(da_map_fn)
else:
da = self.data_catalog.get_rasterdataset(da_map_fn)
# Convert to units of the exposure data if required
# reading from the datacatalog
else:
if not self.region.empty:
Expand All @@ -424,7 +422,8 @@ def setup_hazard(
da = self.data_catalog.get_rasterdataset(map_fn, variables=da_name)
else:
da = self.data_catalog.get_rasterdataset(map_fn, variables=da_name)

if self.exposure.unit != da.units:
da = da * unit_conversion_factor
da.encoding["_FillValue"] = None
da = da.raster.gdal_compliant()

Expand Down
6 changes: 3 additions & 3 deletions hydromt_fiat/workflows/exposure_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,9 @@ def raise_ground_floor_height(
"Raising the ground floor height of the properties relative to Datum."
)
self.exposure_db.loc[
self.exposure_db["Ground Floor Height"] < raise_by,
"Ground Floor Height",
].iloc[idx, :] = raise_by
(self.exposure_db["Ground Floor Height"] < raise_by) & self.exposure_db.index.isin(idx),
"Ground Floor Height",
] = raise_by

elif height_reference.lower() in ["geom", "table"]:
# Elevate the objects relative to the surface water elevation map that the
Expand Down
19 changes: 13 additions & 6 deletions tests/test_raise_ground_floor_height.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@
)

_cases = {
"raise_ground_floor_height": {
"data_catalogue": EXAMPLEDIR / "fiat_catalog.yml",
"raise_ground_floor_height_geom": {
"dir": "test_read",
"ini": EXAMPLEDIR / "test_read.ini",
"new_root": EXAMPLEDIR / "test_raise_ground_floor_height_geom",
"ground_floor_height_reference": EXAMPLEDIR
/ "test_read"
/ "reference_groundHeight_test.shp",
"new_root": EXAMPLEDIR / "test_raise_ground_floor_height",
"height_reference": "geom",
"attr_ref": "bfe",
},
"raise_ground_floor_height_datum": {
"dir": "test_read",
"new_root": EXAMPLEDIR / "test_raise_ground_floor_height_datum",
"ground_floor_height_reference": None,
"height_reference": "datum",
"attr_ref": None,
},
}

Expand All @@ -38,9 +45,9 @@ def test_raise_ground_floor_height(case):
fm.exposure.raise_ground_floor_height(
raise_by=2,
objectids=objectids,
height_reference="geom",
height_reference=_cases[case]["height_reference"],
path_ref=_cases[case]["ground_floor_height_reference"],
attr_ref="bfe",
attr_ref=_cases[case]["attr_ref"],
)

if _cases[case]["new_root"].exists():
Expand Down

0 comments on commit b6399cf

Please sign in to comment.