Skip to content

Mf6Splitter fails on a model level OBS package with a second cellid #2825

Description

@jdhughes-dev

Splitting a model whose model level OBS package has an observation with a second cellid,
such as flow-ja-face, fails in Mf6Splitter._remap_obs(). The branch that remaps the
second cellid is only reached when pkg_type is None, which is the model level OBS
package (model_splitter.py:3377), and it has never worked.

  File "flopy/mf6/utils/model_splitter.py", line 3963, in split_model
    paks = self._remap_package(package)
  File "flopy/mf6/utils/model_splitter.py", line 3377, in _remap_package
    mapped_data = self._remap_obs(package, mapped_data, self._node_map)
  File "flopy/mf6/utils/model_splitter.py", line 2912, in _remap_obs
    list(cellid2[conv_idx])
TypeError: only integer scalar arrays can be converted to a scalar index

Four problems in that branch:

  • model_splitter.py:2912cellid2 is rebound to a python list at 2897 and 2906, then
    indexed with an integer array. Same for layers2 at 2947.
  • model_splitter.py:2943tmp_node[cidx].to_list(), an array has tolist().
  • model_splitter.py:2941model.modelgrid.get_lrc() is called on the split model grid.
    A VertexGrid has no get_lrc(), so this cannot work for a DISV model. It also builds a
    cellid for the split model from the split model grid, where the surrounding code uses
    _new_node_to_cellid().
  • The layer is taken from the original cellid but the node is converted with a layer of 0,
    so the two would have to be recombined the way _new_node_to_cellid() does.

Reproducer, on a model with a model level OBS package:

flopy.mf6.ModflowUtlobs(
    gwf,
    continuous={"obs.csv": [("faceflow", "flow-ja-face", (0, 4, 4), (0, 4, 5)),
                            ("h1", "head", (0, 4, 4))]},
)
Mf6Splitter(sim).split_model(array)

Note for whoever picks this up: #2820 adds an option to split a structured model into DISV
models, so a fix should build the second cellid through _new_node_to_cellid() rather than
get_lrc(), which handles both grid types.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions