gwmod / nlmod

Python package to build, run and visualize MODFLOW 6 groundwater models in the Netherlands.
https://nlmod.readthedocs.io
MIT License
31 stars 2 forks source link

Getting specific discharge data as DataArrays from DATA-SPDIS #282

Closed dbrakenhoff closed 10 months ago

dbrakenhoff commented 10 months ago

Currently, getting specific discharge information as a data-array is not possible with nlmod.

da = nlmod.gwf.output.get_budget_da("DATA-SPDIS", ds=ds)

Since we always use the create3D option in our binary read files we currently cannot access any other data than ["q"] in the budget rec-array. This works fine for most budget terms but will not work on budget datasets like "DATA-SPDIS", where "q" is filled with all zeros, and other variables ["qx", "qy", "qz"] contain the actual interesting data.

One option to deal with this would be to introduce some logic in the parsing of the text argument to get_budget_da(). For example:

qz = nlmod.gwf.output.get_budget_da("DATA-SPDIS.qz", ds=ds)

Here the ".qz" indicates we want to load the data not from the default "q" variable in the rec-array, but the "qz" variable. This requires a minimal change to the current code, and allows you to access other data from more complex budget files. If no "." is present in the text, it defaults to the q variable (the current (flopy) default). This does require some knowledge about the budget rec-array, which users will have to figure out using flopy.

Perhaps we should also include a warning when loading DATA-SPDIS as currently the code completes just fine, but you're left with a data-array filled with zeros.

What do you think about introducing this .-logic to the text argument @rubencalje, @OnnoEbbens ?

rubencalje commented 10 months ago

Without knowing how this may impact the code, I am more in favor of adding an extra argument called columnwith a default value of "q" to get_budget_da:

qz = nlmod.gwf.output.get_budget_da("DATA-SPDIS", column="qz", ds=ds)
dbrakenhoff commented 10 months ago

That also works but requires a few more lines of code (passing along the column key). But I guess that is more clear for users.

OnnoEbbens commented 10 months ago

I agree that it is easier for the user to have an extra column argument

rubencalje commented 10 months ago

Solved by PR #285