Skip to content

Commit

Permalink
only error for budgets without grid information
Browse files Browse the repository at this point in the history
  • Loading branch information
rubencalje committed Oct 31, 2023
1 parent 887e184 commit 4adf501
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 10 additions & 5 deletions nlmod/mfoutput/mfoutput.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import logging
import warnings

import dask
import xarray as xr
Expand Down Expand Up @@ -275,12 +276,16 @@ def _get_flopy_data_object(var, ds=None, gwml=None, fname=None, grbfile=None):
elif ds is not None:
modelgrid = modelgrid_from_ds(ds)
else:
logger.error(f"Cannot create {var} data-array without grid information.")
raise ValueError(
"Please provide grid information by passing path to the "
"binary grid file with `grbfile=<path to file>`."
)
modelgrid = None

msg = f"Cannot create {var} data-array without grid information."
if var == "budget":
if modelgrid is None:
logger.error(msg)
raise ValueError(msg)
return flopy.utils.CellBudgetFile(fname, modelgrid=modelgrid)
else:
if modelgrid is None:
logger.warning(msg)
warnings.warn(msg)
return flopy.utils.HeadFile(fname, text=var, modelgrid=modelgrid)
5 changes: 1 addition & 4 deletions tests/test_015_gwf_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
tmpdir = tempfile.gettempdir()
tst_model_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")

grberror = (
"Please provide grid information by passing path to the "
"binary grid file with `grbfile=<path to file>`."
)
grberror = "Cannot create budget data-array without grid information."


def test_create_small_model_grid_only(tmpdir, model_name="test"):
Expand Down

0 comments on commit 4adf501

Please sign in to comment.