Skip to content
New issue

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

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

Already on GitHub? # to your account

feature: support custom packages for mf2k and modflow2005 #2396

Closed
dbrakenhoff opened this issue Dec 19, 2024 · 0 comments · Fixed by #2404
Closed

feature: support custom packages for mf2k and modflow2005 #2396

dbrakenhoff opened this issue Dec 19, 2024 · 0 comments · Fixed by #2404

Comments

@dbrakenhoff
Copy link
Contributor

dbrakenhoff commented Dec 19, 2024

Is your feature request related to a problem? Please describe.
I'm currently working on a project where we have some ancient models lying around using a custom version of MF2K. This custom version of MF2K uses the SWI1 package and a specially developed unsaturated zone package. I wrote custom flopy package classes to read/write these two special packages, and I wanted to extend flopy with those custom packages so I could use all of flopy's wonderful functionality to load/post-process these models.

Now I realize that development on MF2k and Modflow2005 stuff is probably well past its due date... But, with a very minor change, the supported package list in flopy.modflow.Modflow could be exposed allowing users like me to inject custom package definition classes 😇.

Describe the solution you'd like
By moving self.mfnam_packages to a separate function with a keyword argument that allows specification of custom packages, and adding an extra_pkgs argument to the class constructor and load methods, custom classes can easily be supported.

import flopy
from my_flopy_additions import ModflowSwi1, ModflowUnsaturatedZone

custom_pkgs = {
    "SWI1": ModflowSwi1,
    "UZR": ModflowUnsaturatedZone,
}

ml = flopy.modflow.Modflow.load("namfile.nam", extra_pkgs=custom_pkgs)

# the Modflow.mfnam_packages is updated with the extra_pkgs kwarg in the class constructor.

Is this something you guys would consider changing? Let me know.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant