Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes #85

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/source/config-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,25 @@ Some additional notes on YAML
* ``[12,1.2]`` parses to ``[12,1.2]``
* ``(12,1.2)`` parses to ``"(12,1.2)"``
* ``{12,1.2}`` parses to ``{12: None, 1.2: None}``
* dictionaries can be represented with indentation, but spaces are needed after the colon(s):

.. code-block:: yaml

items:
0:1
1:2

parses to ``'0:1 1:2'``

.. code-block:: yaml

items:
0: 1
1: 2

parses to ``{0:1, 1:2}``

Using a YAML-aware text editor such as VS Code can help with these issues, for example by changing the highlighting color to indicate a string in the first dictionary example above and an interpreted python data structure in the second dictionary example.

.. _JSON: https://www.json.org/json-en.html
.. _pyyaml: https://pyyaml.org/
Expand Down
20 changes: 12 additions & 8 deletions mfsetup/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,14 +986,14 @@ def setup_structured_grid(xoff=None, yoff=None, xul=None, yul=None,
if parent_model is not None and snap_to_parent:
to_grid_units_parent = convert_length_units(get_model_length_units(parent_model), grid_units)
# parent model grid spacing in meters
parent_delr_grid = np.round(parent_model.dis.delr.array[0] * to_grid_units_parent, 4)
if not parent_delr_grid % delr_grid % parent_delr_grid == 0:
raise ValueError('inset delr spacing of {} must be factor of parent spacing of {}'.format(delr_grid,
parent_delr_grid))
parent_delc_grid = np.round(parent_model.dis.delc.array[0] * to_grid_units_parent, 4)
if not parent_delc_grid % delc_grid % parent_delc_grid == 0:
raise ValueError('inset delc spacing of {} must be factor of parent spacing of {}'.format(delc_grid,
parent_delc_grid))
#parent_delr_grid = np.round(parent_model.dis.delr.array[0] * to_grid_units_parent, 4)
#if not parent_delr_grid % delr_grid % parent_delr_grid == 0:
# raise ValueError('inset delr spacing of {} must be factor of parent spacing of {}'.format(delr_grid,
# parent_delr_grid))
#parent_delc_grid = np.round(parent_model.dis.delc.array[0] * to_grid_units_parent, 4)
#if not parent_delc_grid % delc_grid % parent_delc_grid == 0:
# raise ValueError('inset delc spacing of {} must be factor of parent spacing of {}'.format(delc_grid,
# parent_delc_grid))

# option 1: make grid from xoff, yoff and specified dimensions
if xoff is not None and yoff is not None:
Expand Down Expand Up @@ -1057,6 +1057,10 @@ def setup_structured_grid(xoff=None, yoff=None, xul=None, yul=None,
df.to_crs(crs, inplace=True)
# use all features by default
features = df.geometry.tolist()
elif features is None and features_shapefile is not None:
raise ValueError(
"setup_grid: need one of xoff/yoff, xul/yul, features_shapefile or "
"features inputs")
# alternatively, accept features as an argument
# convert multiple features to a MultiPolygon
if isinstance(features, list):
Expand Down
2 changes: 1 addition & 1 deletion mfsetup/mf6model.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def create_lgr_models(self):
last_refined_layer = max(np.where(is_refined > 0)[0])
consecutive = all(np.diff(is_refined)[:last_refined_layer] == 0)
if (is_refined[0] != 1) | (not consecutive):
raise ValueError("Configuration input: layer_refinement must"
raise ValueError("Configuration input: layer_refinement must "
"include consecutive sequence of layers, "
"starting with the top layer.")
# check the specified DIS package input is consistent
Expand Down
6 changes: 6 additions & 0 deletions mfsetup/mfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,12 @@ def setup_grid(self):
self._modelgrid.cfg = self.cfg['grid']
else:
kwargs = get_input_arguments(cfg, setup_structured_grid)
if not set(kwargs.keys()).intersection({
'features_shapefile', 'features', 'xoff', 'yoff', 'xul', 'yul'}):
raise ValueError(
"No features_shapefile or xoff, yoff supplied "
"to setup_grid: block. Check configuration file input, "
"including for accidental indentation of the setup_grid: block.")
self._modelgrid = setup_structured_grid(**kwargs)
self.cfg['grid'] = self._modelgrid.cfg
# update DIS package configuration
Expand Down
Loading