Skip to content

Commit 50218b7

Browse files
authored
Merge pull request #536 from gwmod/dev
Quick fix to update regis-url
2 parents 1c9b462 + 6cb89e1 commit 50218b7

File tree

6 files changed

+54
-14
lines changed

6 files changed

+54
-14
lines changed

nlmod/dims/base.py

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515

1616

1717
def set_ds_attrs(
18-
ds, model_name, model_ws, mfversion="mf6", exe_name=None, version_tag=None
18+
ds,
19+
model_name,
20+
model_ws,
21+
mfversion="mf6",
22+
exe_name=None,
23+
version_tag=None,
24+
download_exe=True,
1925
):
2026
"""Set the attribute of a model dataset.
2127
@@ -38,6 +44,9 @@ def set_ds_attrs(
3844
the most recent installation location of MODFLOW is found in flopy metadata
3945
that respects `version_tag`. If not found, the executables are downloaded.
4046
Not compatible with exe_name.
47+
download_exe : bool, optional
48+
If True, download the executable if it is not found locally. The default is
49+
True.
4150
4251
Returns
4352
-------
@@ -52,9 +61,17 @@ def set_ds_attrs(
5261
ds.attrs["created_on"] = dt.datetime.now().strftime(fmt)
5362

5463
if exe_name is None:
55-
exe_name = util.get_exe_path(exe_name=mfversion, version_tag=version_tag)
64+
exe_name = util.get_exe_path(
65+
exe_name=mfversion,
66+
version_tag=version_tag,
67+
download_if_not_found=download_exe,
68+
)
5669
else:
57-
exe_name = util.get_exe_path(exe_name=exe_name, version_tag=version_tag)
70+
exe_name = util.get_exe_path(
71+
exe_name=exe_name,
72+
version_tag=version_tag,
73+
download_if_not_found=download_exe,
74+
)
5875

5976
ds.attrs["exe_name"] = exe_name
6077

@@ -87,6 +104,7 @@ def to_model_ds(
87104
transport=False,
88105
remove_nan_layers=True,
89106
version_tag=None,
107+
download_exe=True,
90108
):
91109
"""Transform an input dataset to a groundwater model dataset.
92110
@@ -150,6 +168,9 @@ def to_model_ds(
150168
the most recent installation location of MODFLOW is found in flopy metadata
151169
that respects `version_tag`. If not found, the executables are downloaded.
152170
Not compatible with exe_name.
171+
download_exe : bool, optional
172+
If True, download the executable if it is not found locally. The default is
173+
True.
153174
154175
Returns
155176
-------
@@ -189,7 +210,12 @@ def to_model_ds(
189210

190211
# add attributes
191212
ds = set_ds_attrs(
192-
ds, model_name, model_ws, mfversion="mf6", version_tag=version_tag
213+
ds,
214+
model_name,
215+
model_ws,
216+
mfversion="mf6",
217+
version_tag=version_tag,
218+
download_exe=download_exe,
193219
)
194220
ds.attrs["transport"] = int(transport)
195221

@@ -538,6 +564,8 @@ def get_ds(
538564
extrapolate=True,
539565
fill_nan=True,
540566
transport=False,
567+
version_tag=None,
568+
download_exe=True,
541569
**kwargs,
542570
):
543571
"""Create a model dataset from scratch.
@@ -607,9 +635,17 @@ def get_ds(
607635
transport : bool, optional
608636
flag indicating whether dataset includes data for a groundwater
609637
transport model (GWT). Default is False, no transport.
638+
version_tag : str, default None
639+
GitHub release ID: for example "18.0" or "latest". If version_tag is provided,
640+
the most recent installation location of MODFLOW is found in flopy metadata
641+
that respects `version_tag`. If not found, the executables are downloaded if
642+
download_exe is True (see below). Not compatible with exe_name.
643+
download_exe : bool, optional
644+
If True, download the executable if it is not found locally. The default is
645+
True.
610646
**kwargs : dict
611-
Kwargs are passed into mbase.to_ds. These can be the model_name
612-
or ds.
647+
Kwargs are passed into nlmod.to_model_ds(). See nlmod.to_model_ds() for
648+
more information.
613649
614650
Returns
615651
-------
@@ -707,6 +743,8 @@ def check_variable(var, shape):
707743
extrapolate=extrapolate,
708744
fill_nan=fill_nan,
709745
transport=transport,
746+
version_tag=version_tag,
747+
download_exe=download_exe,
710748
**kwargs,
711749
)
712750
ds.rio.write_crs(crs, inplace=True)

nlmod/read/geotop.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
logger = logging.getLogger(__name__)
1515

16-
GEOTOP_URL = "https://dinodata.nl/opendap/GeoTOP/geotop.nc"
16+
GEOTOP_URL = "https://www.dinodata.nl/opendap/GeoTOP/geotop.nc"
1717

1818

1919
def get_lithok_props(rgb_colors=True):
@@ -263,7 +263,7 @@ def get_geotop(*args, **kwargs):
263263
extent : list, tuple or np.array
264264
desired model extent (xmin, xmax, ymin, ymax)
265265
url : str, optional
266-
url of geotop netcdf file. The default is
266+
url of geotop netcdf file. The default is nlmod.read.geotop.GEOTOP_URL:
267267
http://www.dinodata.nl/opendap/GeoTOP/geotop.nc
268268
probabilities : bool, optional
269269
if True, also download probability data. The default is False.
@@ -282,7 +282,7 @@ def get_geotop(*args, **kwargs):
282282

283283

284284
@cache.cache_netcdf()
285-
def download_geotop(extent, url=GEOTOP_URL, probabilities=False, chunks="auto"):
285+
def download_geotop(extent, url=None, probabilities=False, chunks="auto"):
286286
"""Get a slice of the geotop netcdf url within the extent, set the x and y
287287
coordinates to match the cell centers and keep only the strat and lithok data
288288
variables.
@@ -292,7 +292,7 @@ def download_geotop(extent, url=GEOTOP_URL, probabilities=False, chunks="auto"):
292292
extent : list, tuple or np.array
293293
desired model extent (xmin, xmax, ymin, ymax)
294294
url : str, optional
295-
url of geotop netcdf file. The default is
295+
url of geotop netcdf file. The default is nlmod.read.geotop.GEOTOP_URL:
296296
http://www.dinodata.nl/opendap/GeoTOP/geotop.nc
297297
probabilities : bool, optional
298298
if True, also download probability data. The default is False.
@@ -312,6 +312,8 @@ def download_geotop(extent, url=GEOTOP_URL, probabilities=False, chunks="auto"):
312312
gt : xarray Dataset
313313
slices geotop netcdf.
314314
"""
315+
if url is None:
316+
url = GEOTOP_URL
315317
gt = xr.open_dataset(url, chunks=chunks)
316318

317319
# only download requisite data

nlmod/read/regis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
logger = logging.getLogger(__name__)
1616

17-
REGIS_URL = "https://dinodata.nl/opendap/REGIS/REGIS.nc"
17+
REGIS_URL = "https://www.dinodata.nl/opendap/REGIS/REGIS.nc"
1818

1919

2020
@cache.cache_netcdf()

nlmod/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def get_bin_directory(
212212
exe_name : str, optional
213213
The name of the executable, by default mf6.
214214
bindir : Path, optional
215-
The directory where the executables are stored, by default "mf6".
215+
The directory where the executables are stored, by default "None".
216216
download_if_not_found : bool, optional
217217
Download the executables if they are not found, by default True.
218218
repo : str, default "executables"

nlmod/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from importlib import metadata
22
from platform import python_version
33

4-
__version__ = "0.11.0"
4+
__version__ = "0.11.1"
55

66

77
def show_versions() -> None:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ full = [
6969
"owslib>=0.24.1",
7070
"pyshp>=2.1.3",
7171
]
72-
knmi = ["h5netcdf", "nlmod[grib]"]
72+
knmi = ["h5netcdf", "h5py", "nlmod[grib]"]
7373
grib = ["cfgrib", "ecmwflibs"]
7474
test = ["pytest>=7", "pytest-cov", "pytest-dependency"]
7575
nbtest = ["nbformat", "nbconvert>6.4.5"]

0 commit comments

Comments
 (0)