modflowpy / flopy

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

bug: ModflowUtlobs only loads last "continuous" block #2058

Closed dannbuckley closed 7 months ago

dannbuckley commented 9 months ago

Describe the bug The flopy.mf6.modflow.mfutlobs.ModflowUtlobs class does not load both of the continuous blocks from the ex-gwf-advtidal.obs file within the ex-gwf-advtidal MODFLOW 6 example. This is what the loaded class currently looks like:

package_name = obs_1
filename = ex-gwf-advtidal.obs
package_type = obs
model_or_simulation_package = model
model_name = ex-gwf-advtidal

Block continuous
--------------------
continuous
{internal}
(rec.array([('h1_13_8', 'head', (2, 12, 7), None)],
          dtype=[('obsname', 'O'), ('obstype', 'O'), ('id', 'O'), ('id2', 'O')]))

Expected behavior The class should have both continuous blocks from the observation file:

# File generated by Flopy version 3.3.6 on 12/07/2022 at 20:40:00.
BEGIN options
END options

BEGIN continuous  FILEOUT  ex-gwf-advtidal.obs.flow.csv
  icf1  flow-ja-face  1 5 6  1 6 6
END continuous  FILEOUT  ex-gwf-advtidal.obs.flow.csv

BEGIN continuous  FILEOUT  ex-gwf-advtidal.obs.head.csv
  h1_13_8  head  3 13 8
END continuous  FILEOUT  ex-gwf-advtidal.obs.head.csv

Desktop (please complete the following information):

spaulins-usgs commented 9 months ago

@dannbuckley, I have merged a fix for this problem into the develop branch.

dannbuckley commented 9 months ago

Hey @spaulins-usgs,

I can confirm that the data is there:

>>> model.get_package("obs_1").continuous.get_data()
{'ex-gwf-advtidal.obs.flow.csv': rec.array([('icf1', 'flow-ja-face', (0, 4, 5), (0, 5, 5))],
           dtype=[('obsname', 'O'), ('obstype', 'O'), ('id', 'O'), ('id2', 'O')]),
 'ex-gwf-advtidal.obs.head.csv': rec.array([('h1_13_8', 'head', (2, 12, 7), None)],
           dtype=[('obsname', 'O'), ('obstype', 'O'), ('id', 'O'), ('id2', 'O')])}

The class summary still looks like it does in the original comment:

>>> model.get_package("obs_1")
package_name = obs_1
filename = ex-gwf-advtidal.obs
package_type = obs
model_or_simulation_package = model
model_name = ex-gwf-advtidal

Block continuous
--------------------
continuous
{internal}
(rec.array([('h1_13_8', 'head', (2, 12, 7), None)],
          dtype=[('obsname', 'O'), ('obstype', 'O'), ('id', 'O'), ('id2', 'O')]))
spaulins-usgs commented 9 months ago

@dannbuckley, yes the class summary is being abbreviated when there are multiple blocks of the same type. It also gets abbreviated for stress period data. I will discuss with the rest of the flopy team the best way to display the class summary in these cases. Note that it is probably best to abbreviate the class summary in at least some cases since there can be 100s or even 1000s of stress periods in some models.

dannbuckley commented 9 months ago

@spaulins-usgs That makes sense. In that case, then, it might be easier to print the number of instances of the block within the package instead of printing all the data (e.g., "continuous: 100 blocks" or similar). Also, printing something like "only last block shown" or similar might help.