modflowpy / flopy

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

bug: warning when calling get_alldata() of class HeadUFile for Unstructured MODFLOW-USG HeadUFile #1502

Open flydream0428 opened 2 years ago

flydream0428 commented 2 years ago

Describe the bug The warning below is encountered when get_alldata is called. I also did a test. It will not work even a nodata value is specified.

C:\Anaconda\envs\py38\lib\site-packages\flopy\utils\datafile.py:573: DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
  rv[rv == nodata] = np.nan

To Reproduce Call the function using some lines as below, hf_reg = bf.HeadUFile('a_USG_head_file.hds') h_all_reg = hf_reg.get_alldata()

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

wpbonelli commented 4 months ago

I cannot reproduce the reported warning — however HeadUFile.get_alldata() fails on the previous line

https://github.com/modflowpy/flopy/blob/4e1d53ac3685d9027b1ced45749c9e20d8b701d5/flopy/utils/datafile.py#L578

when called on HeadUFile("<project root>/examples/data/unstructured/headu.githds") due to array inhomogeneity

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (5, 3) + inhomogeneous part.

It seems like get_alldata() either needs to be overridden for HeadUFile to return a list instead of an array, which would change the semantics as compared to the base implementation in LayerFile, or just be unsupported for USG head files. Am I thinking about this right @langevin-usgs @jdhughes-usgs ?