You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
I encountered an error when setting river inflow points. How can I fix it? Can someone please help me? Thank you.
IndexError Traceback (most recent call last)
Cell In[9], line 4
1 # derive river from hydrography data based on a minimum river length (river_len)
2 # and minimum upstream area (river_upa)
----> 4 sf.setup_river_inflow(
5 hydrography="merit_hydro", river_len=1000, river_upa=50, keep_rivers_geom=True
6 )
8 # Make a plot of model
9 # note the src points and derived river network
10 fig, ax = sf.plot_basemap(variable="dep", plot_bounds=False, bmap="sat", zoomlevel=12)
File c:\Users\lucan\anaconda3\envs\hydromt-sfincs\lib\site-packages\hydromt_sfincs\sfincs.py:907, in SfincsModel.setup_river_inflow(self, rivers, hydrography, buffer, river_upa, river_len, river_width, merge, first_index, keep_rivers_geom, reverse_river_geom, src_type)
903 gdf_riv = self.data_catalog.get_geodataframe(
904 rivers, geom=self.region
905 ).to_crs(self.crs)
906 elif hydrography is not None:
--> 907 gdf_riv = workflows.river_centerline_from_hydrography(
908 da_flwdir=ds["flwdir"],
909 da_uparea=da_uparea,
910 river_upa=river_upa,
911 river_len=river_len,
912 gdf_mask=self.region,
913 )
914 elif hydrography is None:
915 raise ValueError("Either hydrography or rivers must be provided.")
File c:\Users\lucan\anaconda3\envs\hydromt-sfincs\lib\site-packages\hydromt_sfincs\workflows\flwdir.py:71, in river_centerline_from_hydrography(da_flwdir, da_uparea, river_upa, river_len, gdf_mask)
69 return gdf_riv
70 # accumulate to get river length from outlet
---> 71 flwdir = pyflwdir.from_dataframe(gdf_riv.set_index("idx"), ds_col="idx_ds")
72 gdf_riv["rivdst"] = flwdir.accuflux(gdf_riv["seglen"].values, direction="down")
73 # get maximum river length from outlet (at headwater segments) for each river segment
File c:\Users\lucan\anaconda3\envs\hydromt-sfincs\lib\site-packages\pyflwdir\flwdir.py:32, in get_loc_idx(idxs, idxs_ds)
30 idx_map.fill(-1) # Fill with -1 to indicate missing values
31 idx_map[idxs] = np.arange(idxs.size)
---> 32 return idx_map[idxs_ds]
IndexError: index 16162 is out of bounds for axis 0 with size 10589
Current behaviour
The formal steps were completely correct, but when I added river inflow points, this issue occurred. I tried the old version of sfincs, but it didn't work.
Desired behaviour
Please help me resolve this index error, thanks.
Additional context
No response
The text was updated successfully, but these errors were encountered:
HydroMT-SFINCS version checks
Reproducible Example
I encountered an error when setting river inflow points. How can I fix it? Can someone please help me? Thank you.
IndexError Traceback (most recent call last)
Cell In[9], line 4
1 # derive river from hydrography data based on a minimum river length (river_len)
2 # and minimum upstream area (river_upa)
----> 4 sf.setup_river_inflow(
5 hydrography="merit_hydro", river_len=1000, river_upa=50, keep_rivers_geom=True
6 )
8 # Make a plot of model
9 # note the src points and derived river network
10 fig, ax = sf.plot_basemap(variable="dep", plot_bounds=False, bmap="sat", zoomlevel=12)
File c:\Users\lucan\anaconda3\envs\hydromt-sfincs\lib\site-packages\hydromt_sfincs\sfincs.py:907, in SfincsModel.setup_river_inflow(self, rivers, hydrography, buffer, river_upa, river_len, river_width, merge, first_index, keep_rivers_geom, reverse_river_geom, src_type)
903 gdf_riv = self.data_catalog.get_geodataframe(
904 rivers, geom=self.region
905 ).to_crs(self.crs)
906 elif hydrography is not None:
--> 907 gdf_riv = workflows.river_centerline_from_hydrography(
908 da_flwdir=ds["flwdir"],
909 da_uparea=da_uparea,
910 river_upa=river_upa,
911 river_len=river_len,
912 gdf_mask=self.region,
913 )
914 elif hydrography is None:
915 raise ValueError("Either hydrography or rivers must be provided.")
File c:\Users\lucan\anaconda3\envs\hydromt-sfincs\lib\site-packages\hydromt_sfincs\workflows\flwdir.py:71, in river_centerline_from_hydrography(da_flwdir, da_uparea, river_upa, river_len, gdf_mask)
69 return gdf_riv
70 # accumulate to get river length from outlet
---> 71 flwdir = pyflwdir.from_dataframe(gdf_riv.set_index("idx"), ds_col="idx_ds")
72 gdf_riv["rivdst"] = flwdir.accuflux(gdf_riv["seglen"].values, direction="down")
73 # get maximum river length from outlet (at headwater segments) for each river segment
File c:\Users\lucan\anaconda3\envs\hydromt-sfincs\lib\site-packages\pyflwdir\flwdir.py:53, in from_dataframe(df, ds_col)
51 idxs_ds = df[ds_col].values
52 idxs = df.index.values
---> 53 return Flwdir(idxs_ds=get_loc_idx(idxs=idxs, idxs_ds=idxs_ds))
File c:\Users\lucan\anaconda3\envs\hydromt-sfincs\lib\site-packages\pyflwdir\flwdir.py:32, in get_loc_idx(idxs, idxs_ds)
30 idx_map.fill(-1) # Fill with -1 to indicate missing values
31 idx_map[idxs] = np.arange(idxs.size)
---> 32 return idx_map[idxs_ds]
IndexError: index 16162 is out of bounds for axis 0 with size 10589
Current behaviour
The formal steps were completely correct, but when I added river inflow points, this issue occurred. I tried the old version of sfincs, but it didn't work.
Desired behaviour
Please help me resolve this index error, thanks.
Additional context
No response
The text was updated successfully, but these errors were encountered: