Skip to content

unexpected keyword argument 'method' when using nlmod.gwf.wells.wel_from_df #540

@tomvansteijn

Description

@tomvansteijn

Describe the bug

Error is thrown when using when using nlmod.gwf.wells.wel_from_df. Probably because of changes in GridIntersect in a new version of Flopy?

Expected behavior

Create wel package for model using a dataframe as input.

Code to reproduce

ds = nlmod.get_ds([0., 1e3, 0., 1e3], model_ws="test")
sim = nlmod.sim.sim(ds)
gwf = nlmod.gwf.gwf(ds, sim)
wel_df = pd.DataFrame.from_dict({
    0: {"x": 5e2, "y": 5e2, "top": 0., "botm": -10., "Q": -100.},
}, orient="index")
wel = nlmod.gwf.wells.wel_from_df(wel_df, gwf)

Package and Python version

Python version     : 3.13.7
NumPy version      : 2.3.3
Xarray version     : 2025.12.0
Matplotlib version : 3.10.6
Flopy version      : 3.10.0

nlmod version      : 0.10.0

Additional context

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[25], [line 7](vscode-notebook-cell:?execution_count=25&line=7)
      3 gwf = nlmod.gwf.gwf(ds, sim)
      4 wel_df = pd.DataFrame.from_dict({
      5     0: {"x": 5e2, "y": 5e2, "top": 0., "botm": -10., "Q": -100.},
      6 }, orient="index")
----> [7](vscode-notebook-cell:?execution_count=25&line=7) wel = nlmod.gwf.wells.wel_from_df(wel_df, gwf)

File d:\temp\conda-envs\bw_basis\Lib\site-packages\nlmod\gwf\wells.py:79, in wel_from_df(df, gwf, x, y, top, botm, Q, aux, boundnames, ds, auxmultname, **kwargs)
     76 if not isinstance(aux, list):
     77     aux = [aux]
---> [79](file:///D:/temp/conda-envs/bw_basis/Lib/site-packages/nlmod/gwf/wells.py:79) df = _add_cellid(df, ds=ds, gwf=gwf, x=x, y=y)
     80 multipliers = _get_layer_multiplier_for_wells(df, top, botm, ds=ds, gwf=gwf)
     82 # collect data

File d:\temp\conda-envs\bw_basis\Lib\site-packages\nlmod\gwf\wells.py:317, in _add_cellid(df, ds, gwf, x, y, silent)
    315     df = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df[x], df[y]))
    316 if "cellid" not in df.columns:
--> [317](file:///D:/temp/conda-envs/bw_basis/Lib/site-packages/nlmod/gwf/wells.py:317)     df = gdf_to_grid(df, gwf if ds is None else ds, silent=silent)
    318 return df

File d:\temp\conda-envs\bw_basis\Lib\site-packages\nlmod\cache.py:415, in cache_pickle.<locals>.decorator(cachedir, cachename, *args, **kwargs)
    411 @functools.wraps(func)
    412 def decorator(*args, cachedir=None, cachename=None, **kwargs):
...
-> [2022](file:///D:/temp/conda-envs/bw_basis/Lib/site-packages/nlmod/dims/grid.py:2022)     ix = flopy.utils.GridIntersect(modelgrid, method=method)
   2023 shps = []
   2024 geometry = gdf.geometry.name

TypeError: GridIntersect.__init__() got an unexpected keyword argument 'method'

Issue checklist

  • [ x] Add labels
  • [ x] Add issue type
  • Assign yourself, a nlmod developer or no one
  • [x ] Check if there is not already an existing issue for this bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions