Skip to content

Commit

Permalink
implement suggestions by @rubencalje
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrakenhoff committed Nov 18, 2024
1 parent c8ae530 commit 62cf72b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
7 changes: 3 additions & 4 deletions nlmod/dims/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_icell2d_from_xy(x, y, ds, gi=None, rotated=True):
Raises
------
ValueError
Raises a ValueError if the point is outside of the model grid.
Returns
Expand Down Expand Up @@ -171,7 +171,6 @@ def xy_to_row_col(xy, ds):
col : int
number of the column value of a cell containing the xy point.
"""

logger.warning(
"nlmod.grid.xy_to_row_col is deprecated. "
"Use nlmod.grid.get_row_col_from_xy instead"
Expand Down Expand Up @@ -203,7 +202,7 @@ def get_row_col_from_xy(x, y, ds, rotated=True, gi=None):
Raises
------
ValueError
Raises a ValueError if the point is outside of the model grid.
Returns
Expand Down Expand Up @@ -242,7 +241,7 @@ def xyz_to_cid(xyz, ds=None, modelgrid=None):
Parameters
----------
xyz : list, tuple
coordinates of ta point.
coordinates of a point.
ds : xr.Dataset
model dataset.
modelgrid : StructuredGrid, VertexGrid, optional
Expand Down
30 changes: 22 additions & 8 deletions nlmod/read/rws.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,28 @@ def get_gdr_configuration() -> dict:


def get_bathymetry_gdf(
resolution: str = "1m",
resolution: str = "20m",
extent: Optional[list[float]] = None,
config: Optional[dict] = None,
) -> gpd.GeoDataFrame:
"""Get bathymetry dataframe from RWS.
Note that the 20m resolution does not contain bathymetry data for the major rivers.
If you need the bathymetry of the major rivers, use the 1m resolution.
Parameters
----------
resolution : str, optional
resolution of the bathymetry data, "1m" or "20m". The default is "1m".
resolution of the bathymetry data, "1m" or "20m". The default is "20m".
extent : tuple, optional
extent of the model domain. The default is None.
config : dict, optional
configuration dictionary containing urls and layer numbers for GDR data. The
default is None, which uses the default configuration provided by
the function `get_gdr_configuration()`.
"""
config = get_gdr_configuration()
if config is None:
config = get_gdr_configuration()
url = config["bodemhoogte"]["index"]["url"]
layer = config["bodemhoogte"][resolution]["layer"]
return arcrest(url, layer, extent=extent)
Expand All @@ -312,23 +321,24 @@ def get_bathymetry_gdf(
@cache.cache_netcdf()
def get_bathymetry(
extent: list[float],
resolution: str = "1m",
resolution: str = "20m",
res: Optional[float] = None,
method: Optional[str] = None,
chunks: Optional[Union[str, dict[str, int]]] = "auto",
config: Optional[dict] = None,
) -> xr.DataArray:
"""Get bathymetry data from RWS.
Bathymetry is available at 20m resolution and at 1m resolution. The 20m
resolution is available for large water bodies, but not in the rivers. The
1m dataset covers the whole Netherlands.
resolution is available for large water bodies, but not in the major rivers.
The 1m dataset covers the major waterbodies across all of the Netherlands.
Parameters
----------
extent : tuple
extent of the model domain
resolution : str, optional
resolution of the bathymetry data, "1m" or "20m". The default is "1m".
resolution of the bathymetry data, "1m" or "20m". The default is "20m".
res : float, optional
resolution of the output data array. The default is None, which uses
resolution of the input datasets. Resampling method is provided by the method
Expand All @@ -339,13 +349,17 @@ def get_bathymetry(
chunks : dict, optional
chunks for the output data array. The default is "auto", which lets xarray/dask
pick the chunksize. Set to None to avoid chunking.
config : dict, optional
configuration dictionary containing urls and layer numbers for GDR data. The
default is None, which uses the default configuration provided by
the function `get_gdr_configuration()`.
Returns
-------
bathymetry : xr.DataArray
bathymetry data
"""
gdf = get_bathymetry_gdf(resolution=resolution, extent=extent)
gdf = get_bathymetry_gdf(resolution=resolution, extent=extent, config=config)

xmin, xmax, ymin, ymax = extent
dataarrays = []
Expand Down

0 comments on commit 62cf72b

Please sign in to comment.