Deltares / hydromt_wflow

Wflow plugin for HydroMT
https://deltares.github.io/hydromt_wflow/
GNU General Public License v3.0
15 stars 13 forks source link

Wrong dtype for wflow_subcatch map #245

Closed hboisgon closed 6 months ago

hboisgon commented 6 months ago

HydroMT-Wflow version checks

Reproducible Example

Happens if these conditions are met:

Current behaviour

The output wflow_subcatch dtype can be np.uint32 instead of np.int32. Not a problem to run wflow but for example vectorizing the map does not work anymore (which is used in the read_results method):

model.grid["wflow_subcatch"].raster.vectorize()

> ValueError: image dtype must be one of: int16, int32, uint8, uint16, float32

In case of basin variable not available in hydrography_fn, the uint32 actually pops up in the hydromt.workflows.get_basin_geometry:

https://github.com/Deltares/hydromt/blob/d634534fd1c3c5e470d6835a1ee1c518705576ad/hydromt/workflows/basin_mask.py#L380

Desired behaviour

Make sure that basin dtype is np.int32 in that part of the hyrography workflow:

https://github.com/Deltares/hydromt_wflow/blob/c2074330ea28fae65bd4f184e4c9bf8405cbf117/hydromt_wflow/workflows/basemaps.py#L204-L216

Additional context

No response