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

Updating pyproject.toml to ensure users are not using Geopandas v1.0.0 #217

Closed
2 tasks done
taddyb opened this issue Sep 18, 2024 · 0 comments · Fixed by #218
Closed
2 tasks done

Updating pyproject.toml to ensure users are not using Geopandas v1.0.0 #217

taddyb opened this issue Sep 18, 2024 · 0 comments · Fixed by #218
Labels
Bug Something isn't working Needs refinement Issue still needs refinement

Comments

@taddyb
Copy link
Contributor

taddyb commented Sep 18, 2024

HydroMT-SFINCS version checks

  • I have checked that this issue has not already been reported.
  • I have checked that this bug exists on the latest version of HydroMT-SFINCS.

Reproducible Example

# Every single grid cell of the flux grid of the size inp.dx by inp.dy is defined into subgrid pixels (default is 20, nr_subgrid_pixels = 20).
# For every subgrid pixel the topobathy data is loaded, ideally this consists also of high-resolution DEM datasets that you specify as user.

sf.setup_subgrid(
    datasets_dep=datasets_dep,
    datasets_rgh=datasets_rgh,
    datasets_riv=datasets_riv,
    nr_subgrid_pixels=5,
    write_dep_tif=True,
    write_man_tif=False,
)

Current behaviour

pardon my vscode pathing

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[38], [line 1](vscode-notebook-cell:?execution_count=38&line=1)
----> [1](vscode-notebook-cell:?execution_count=38&line=1) sf.setup_subgrid(
      [2](vscode-notebook-cell:?execution_count=38&line=2)     datasets_rgh=datasets_rgh,
      [3](vscode-notebook-cell:?execution_count=38&line=3)     datasets_dep=datasets_dep,
      [4](vscode-notebook-cell:?execution_count=38&line=4)     datasets_riv=datasets_riv,
      [5](vscode-notebook-cell:?execution_count=38&line=5)     nr_subgrid_pixels=5,
      [6](vscode-notebook-cell:?execution_count=38&line=6)     write_dep_tif=False,
      [7](vscode-notebook-cell:?execution_count=38&line=7)     write_man_tif=False,
      [8](vscode-notebook-cell:?execution_count=38&line=8) )

File ~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:744, in SfincsModel.setup_subgrid(self, datasets_dep, datasets_rgh, datasets_riv, buffer_cells, nbins, nr_subgrid_pixels, nrmax, max_gradient, z_minimum, manning_land, manning_sea, rgh_lev_land, write_dep_tif, write_man_tif)
    [741](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:741)     highres_dir = None
    [743](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:743) if self.grid_type == "regular":
--> [744](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:744)     self.reggrid.subgrid.build(
    [745](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:745)         da_mask=self.mask,
    [746](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:746)         datasets_dep=datasets_dep,
    [747](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:747)         datasets_rgh=datasets_rgh,
    [748](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:748)         datasets_riv=datasets_riv,
    [749](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:749)         buffer_cells=buffer_cells,
    [750](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:750)         nbins=nbins,
    [751](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:751)         nr_subgrid_pixels=nr_subgrid_pixels,
    [752](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:752)         nrmax=nrmax,
    [753](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:753)         max_gradient=max_gradient,
    [754](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:754)         z_minimum=z_minimum,
    [755](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:755)         manning_land=manning_land,
    [756](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:756)         manning_sea=manning_sea,
    [757](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:757)         rgh_lev_land=rgh_lev_land,
    [758](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:758)         write_dep_tif=write_dep_tif,
    [759](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:759)         write_man_tif=write_man_tif,
    [760](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:760)         highres_dir=highres_dir,
    [761](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:761)         logger=self.logger,
    [762](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:762)     )
    [763](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:763)     self.subgrid = self.reggrid.subgrid.to_xarray(
    [764](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:764)         dims=self.mask.raster.dims, coords=self.mask.raster.coords
    [765](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:765)     )
    [766](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/sfincs.py:766) elif self.grid_type == "quadtree":

File ~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:456, in SubgridTableRegular.build(self, da_mask, datasets_dep, datasets_rgh, datasets_riv, nbins, nr_subgrid_pixels, nrmax, max_gradient, z_minimum, manning_land, manning_sea, rgh_lev_land, buffer_cells, write_dep_tif, write_man_tif, highres_dir, logger)
    [454](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:454)     logger.debug("Burn rivers in bathymetry and manning data")
    [455](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:455)     for riv_kwargs in datasets_riv:
--> [456](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:456)         da_dep, da_man = workflows.bathymetry.burn_river_rect(
    [457](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:457)             da_elv=da_dep, da_man=da_man, logger=logger, **riv_kwargs
    [458](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:458)         )
    [460](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:460) # optional write tile to file
    [461](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:461) # NOTE tiles have overlap! da_dep[:-refi,:-refi]
    [462](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/subgrid.py:462) x_dim_dep, y_dim_dep = da_dep.raster.x_dim, da_dep.raster.y_dim

File ~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:255, in burn_river_rect(da_elv, gdf_riv, da_man, gdf_zb, gdf_riv_mask, segment_length, riv_bank_q, rivwth_name, rivdph_name, rivbed_name, manning_name, logger)
    [253](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:253)     gdf_riv["buf"] = res / 2
    [254](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:254) if gdf_riv_mask is None:
--> [255](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:255)     gdf_riv_mask = gdf_riv.assign(geometry=gdf_riv.buffer(gdf_riv["buf"]))
    [256](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:256) else:
    [257](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:257)     # get gdf_riv outside of mask and buffer these lines
    [258](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:258)     # then merge with gdf_riv_mask to get the full river mask
    [259](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:259)     gdf_mask = gpd.GeoDataFrame(
    [260](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:260)         geometry=[gdf_riv_mask.buffer(0).unary_union],
    [261](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:261)         crs=gdf_riv_mask.crs,
    [262](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/hydromt_sfincs/workflows/bathymetry.py:262)     )  # create single polygon to clip
.
.
.
File ~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:323, in GeometryArray.__init__(self, data, crs)
    [321](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:321)     data = data._data
    [322](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:322) elif not isinstance(data, np.ndarray):
--> [323](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:323)     raise TypeError(
    [324](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:324)         "'data' should be array of geometry objects. Use from_shapely, "
    [325](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:325)         "from_wkb, from_wkt functions to construct a GeometryArray."
    [326](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:326)     )
    [327](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:327) elif not data.ndim == 1:
    [328](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:328)     raise ValueError(
    [329](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:329)         "'data' should be a 1-dimensional array of geometry objects."
    [330](https://file+.vscode-resource.vscode-cdn.net/Users/taddbindas/projects/hydromt_sfincs/examples/~/miniconda3/envs/test/lib/python3.10/site-packages/geopandas/array.py:330)     )

TypeError: 'data' should be array of geometry objects. Use from_shapely, from_wkb, from_wkt functions to construct a GeometryArray.

Desired behaviour

A successful burn of rivers into the DEM.

Additional context

There is a bug that has been documented in GeoPandas v1.0.0 which does not allow for distance buffers when using a pd.Series object: geopandas/geopandas#3362

This bug was fixed, and a patch was put out. In the hydromt_sfincs pyproject.toml file there is a requirement for geopandas>=1.0 this allows someone to download the buggy geopandas version and their code to fail. The pyproject.toml should be updated to state geopandas>1.0

@taddyb taddyb added Bug Something isn't working Needs refinement Issue still needs refinement labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Needs refinement Issue still needs refinement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant