Skip to content

Commit

Permalink
allow to save the merged landuse and paddy map
Browse files Browse the repository at this point in the history
  • Loading branch information
hboisgon committed Oct 16, 2024
1 parent a6182f8 commit 527e2f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Setup components
WflowModel.setup_laimaps
WflowModel.setup_laimaps_from_lulc_mapping
WflowModel.setup_allocation_areas
WflowModel.setup_surfacewaterfrac
WflowModel.setup_allocation_surfacewaterfrac
WflowModel.setup_domestic_demand
WflowModel.setup_other_demand
WflowModel.setup_irrigation
Expand Down
4 changes: 2 additions & 2 deletions docs/user_guide/wflow_model_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ a specific method see its documentation.
- Setup constant parameter maps for all active model cells.
* - :py:func:`~WflowModel.setup_allocation_areas`
- Create water demand allocation areas.
* - :py:func:`~WflowModel.setup_surfacewaterfrac`
- Create water demand surface water consumption fraction.
* - :py:func:`~WflowModel.setup_allocation_surfacewaterfrac`
- Create fraction of surface water used for allocation of the water demands.
* - :py:func:`~WflowModel.setup_domestic_demand`
- Create domestic water demand.
* - :py:func:`~WflowModel.setup_other_demand`
Expand Down
11 changes: 11 additions & 0 deletions hydromt_wflow/wflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,7 @@ def setup_lulcmaps_with_paddy(
"h4",
],
paddy_waterlevels: Dict = {"h_min": 20, "h_opt": 50, "h_max": 80},
save_high_resolution_lulc: bool = False,
):
"""Set up landuse maps and parameters including for paddy fields.
Expand Down Expand Up @@ -2270,6 +2271,9 @@ def setup_lulcmaps_with_paddy(
paddy_waterlevels : dict
Dictionary with the minimum, optimal and maximum water levels for paddy
fields [mm]. By default {"h_min": 20, "h_opt": 50, "h_max": 80}
save_high_resolution_lulc : bool
Save the high resolution landuse map merged with the paddies to the static
folder. By default False.
"""
self.logger.info("Preparing LULC parameter maps including paddies.")
# Check if soil data is available
Expand Down Expand Up @@ -2315,6 +2319,13 @@ def setup_lulcmaps_with_paddy(
df_paddy_mapping=df_paddy_mapping,
)

if save_high_resolution_lulc:
output_dir = join(self.root, "maps")
if not os.path.exists(output_dir):
os.path.makedirs(output_dir)
landuse.raster.to_raster(join(output_dir, "landuse_with_paddy.tif"))
df_mapping.to_csv(join(output_dir, "landuse_with_paddy_mapping.csv"))

# Prepare landuse parameters
landuse_maps = workflows.landuse(
da=landuse,
Expand Down

0 comments on commit 527e2f1

Please sign in to comment.