Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Deltares/hydromt_fiat into …
Browse files Browse the repository at this point in the history
…improvements
  • Loading branch information
Santonia27 committed Oct 17, 2024
2 parents 3d02c58 + 8b707c0 commit 0ee447d
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 47 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ jobs:
uses: actions/checkout@v3

- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
python-version: "3.10"
miniforge-variant: Mambaforge
miniforge-version: latest
channels: conda-forge
use-mamba: true
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ for the Delft-FIAT_ model.
.. pip install hydromt_fiat
Installation as a User
------------
----------------------

For Use HydroMT-FIAT, do:
Hydromt-FIAT can be installled in an existing environment or the user can create a new environment. We recommened to create a new environment to avoid issues with other dependencies and packages.
Expand Down Expand Up @@ -84,7 +84,7 @@ If you want to install FIAT into an existing environment, simply activate the de
Installation as a Developer
------------
---------------------------
For developing on HydroMT-FIAT, do:

.. code-block:: console
Expand Down
173 changes: 154 additions & 19 deletions docs/_static/fiat_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion hydromt_fiat/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Versioning."""

major = 0
minor = 3
minor = 4
patch = 2
suffix = ".dev"

Expand Down
56 changes: 33 additions & 23 deletions hydromt_fiat/workflows/exposure_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,19 @@ def setup_new_composite_areas(
# Add the new development area as an object to the Exposure Modification file.
new_area = gpd.read_file(geom_file, engine="pyogrio")
# check_crs(new_area, geom_file) #TODO implement again

# Check if the column "height" is in the provided spatial file, which indicates the individual heights above the reference
# If not the provided value will be used uniformly
if "height" not in new_area.columns:
new_area["height"] = ground_floor_height
self.logger.info(f"Using uniform value of {ground_floor_height}"
f"to specify the elevation above {elevation_reference} of FFE of new composite area(s).")
else:
self.logger.info(f"Using 'height' column from {geom_file} to specify the elevation above {elevation_reference} "
"for FFE of new composite area(s).")

new_area["Object ID"] = None # add object id column to area file

new_objects = []

# Calculate the total area to use for adding the damages relative to area
Expand All @@ -1361,15 +1374,8 @@ def setup_new_composite_areas(
for i in range(len(new_area.index)):
new_geom = new_area.geometry.iloc[i]
new_id = max_id + 1

new_area["Object ID"].iloc[i] = new_id # assign Object ID to polygons
perc_damages = new_geom.area / total_area
# Alert the user that the ground elevation is set to 0.
# TODO: Take ground elevation from DEM?
# For water level calculation this will not take into account the
# non-flooded cells separately, just averaged over the whole area.
self.logger.warning(
"The ground elevation is set to 0 if no DEM is supplied."
)

# Idea: Reduction factor for the part of the area is not build-up?

Expand Down Expand Up @@ -1411,15 +1417,28 @@ def setup_new_composite_areas(
data=new_geoms_ids, columns=["geometry", "Object ID"], crs=self.crs
)

# If the user supplied ground elevation data, assign that to the new
# composite areas
if ground_elevation is not None:
new_objects["Ground Elevation"] = ground_elevation_from_dem(
ground_elevation=ground_elevation,
exposure_db=new_objects,
exposure_geoms=_new_exposure_geoms,
)

if elevation_reference == "datum":
new_objects["Ground Floor Height"] = ground_floor_height
# Ensure that the new objects have a first floor height that elevates them above the requirement
new_objects["Ground Floor Height"] = new_objects.apply(
lambda row: max(row["Ground Floor Height"], new_area.loc[row.name, "height"] - row["Ground Elevation"]),
axis=1
)
self.logger.info(
f"The elevation of the new development area is {ground_floor_height} ft"
f"The elevation of the new development area is {new_area['height'].values} {self.unit}"
" relative to datum." # TODO: make unit flexible
)
elif elevation_reference == "geom":
self.logger.info(
f"The elevation of the new development area is {ground_floor_height} ft"
f"The elevation of the new development area is {new_area['height'].values} {self.unit}"
f" relative to {Path(path_ref).stem}. The height of the floodmap is"
f" identified with column {attr_ref}." # TODO: make unit flexible
)
Expand All @@ -1429,23 +1448,14 @@ def setup_new_composite_areas(
elevation_reference,
path_ref,
attr_ref,
ground_floor_height,
new_area.set_index("Object ID")["height"],
self.crs,
)

# Update the exposure_geoms
self.set_geom_names("new_development_area")
self.set_exposure_geoms(_new_exposure_geoms)

# If the user supplied ground elevation data, assign that to the new
# composite areas
if ground_elevation is not None:
new_objects["Ground Elevation"] = ground_elevation_from_dem(
ground_elevation=ground_elevation,
exposure_db=new_objects,
exposure_geoms=_new_exposure_geoms,
)

# If the user supplied aggregation area data, assign that to the
# new composite areas
if aggregation_area_fn is not None:
Expand Down Expand Up @@ -1762,7 +1772,7 @@ def set_height_relative_to_reference(
height_reference: str,
path_ref: str,
attr_ref: str,
raise_by: Union[int, float],
raise_by: Union[int, float, pd.Series],
out_crs: str,
) -> gpd.GeoDataFrame:
"""Sets the height of exposure_to_modify to the level of the reference file.
Expand All @@ -1779,7 +1789,7 @@ def set_height_relative_to_reference(
_description_
attr_ref : str
_description_
raise_by : Union[int, float]
raise_by : Union[int, float, pd.Series]
_description_
out_crs : _type_
_description_
Expand Down

0 comments on commit 0ee447d

Please sign in to comment.