modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
520 stars 314 forks source link

feature: allow `get_ts()` to get auxiliary variables from the budget file #2270

Open cneyens opened 3 months ago

cneyens commented 3 months ago

Is your feature request related to a problem? Please describe. Unless I'm missing something, it is currently not possible to read time-series of auxiliary variables from the cell-by-cell budget file using the get_ts() method. Darcy fluxes ('DATA-SPDIS') and saturated thickness ('DATA-SAT') are saved to the budget file as auxiliary variables, but get_ts() only returns the q variable, which in those cases is set to a dummy value of zero.

Example code ```py import flopy ws = './mymodel' name = 'mymodel' sim = flopy.mf6.MFSimulation(sim_name=name, sim_ws=ws, exe_name='mf6') tdis = flopy.mf6.ModflowTdis(sim) ims = flopy.mf6.ModflowIms(sim) gwf = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True) dis = flopy.mf6.ModflowGwfdis(gwf, nrow=10, ncol=10) ic = flopy.mf6.ModflowGwfic(gwf) npf = flopy.mf6.ModflowGwfnpf(gwf, save_specific_discharge=True) chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=[[(0, 0, 0), 1.], [(0, 9, 9), 0.]]) budget_file = name + '.bud' head_file = name + '.hds' oc = flopy.mf6.ModflowGwfoc(gwf, budget_filerecord=budget_file, head_filerecord=head_file, saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')]) sim.write_simulation(silent=True) sim.run_simulation(silent=True) head = gwf.output.head().get_data() bud = gwf.output.budget() # this only returns the dummy q variable bud.get_ts(idx=(0,5,5), text='DATA-SPDIS') ```

Describe the solution you'd like A way for get_ts() to retrieve the values of one (or all) auxiliary variables for a given record. Perhaps all aux variables are always returned, or the user gets to set some sort or variable argument in get_ts() which defaults to 'q'?

Describe alternatives you've considered For specific discharge, loop over the required times and get the full gridded values using get_data(text='DATA-SPDIS', totim=t)[0], then use flopy.utils.postprocessing.get_specific_discharge() and subset the required cell id.

Additional context Flopy v3.8.0