Skip to content

Commit

Permalink
Merge pull request #363 from gwmod/dev
Browse files Browse the repository at this point in the history
Release v0.8.1
  • Loading branch information
rubencalje authored Jul 25, 2024
2 parents 9fe0e50 + e8e5f1d commit 383f420
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions nlmod/read/regis.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def get_regis(
remove_nan_layers=True,
drop_layer_dim_from_top=True,
probabilities=False,
nodata=-9999,
):
"""Get a regis dataset projected on the modelgrid.
Expand All @@ -125,6 +126,9 @@ def get_regis(
possibilities of gaps between layers. The default is True.
probabilities : bool, optional
if True, also download probability data. The default is False.
nodata : int or float, optional
When nodata is not None, set values equal to nodata to nan. The default is
-9999.
Returns
-------
Expand Down Expand Up @@ -158,6 +162,18 @@ def get_regis(
# rename bottom to botm, as it is called in FloPy
ds = ds.rename_vars({"bottom": "botm"})

# slice data vars
if variables is not None:
if probabilities:
variables = variables + ("sdh", "sdv")
ds = ds[list(variables)]

# since version REGIS v02r2s2 (22.07.2024) NaN values are replaced by -9999
# we set these values to NaN again
if nodata is not None:
for var in variables:
ds[var] = ds[var].where(ds[var] != nodata)

if remove_nan_layers:
# only keep layers with at least one active cell
ds = ds.sel(layer=~(np.isnan(ds["botm"])).all(ds["botm"].dims[1:]))
Expand All @@ -168,12 +184,6 @@ def get_regis(
if drop_layer_dim_from_top:
ds = remove_layer_dim_from_top(ds)

# slice data vars
if variables is not None:
if probabilities:
variables = variables + ("sdh", "sdv")
ds = ds[list(variables)]

ds.attrs["gridtype"] = "structured"
ds.attrs["extent"] = extent
for datavar in ds:
Expand Down
2 changes: 1 addition & 1 deletion nlmod/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from importlib import metadata
from platform import python_version

__version__ = "0.8.0"
__version__ = "0.8.1"


def show_versions() -> None:
Expand Down

0 comments on commit 383f420

Please sign in to comment.