0

I'm trying to extract the simulated heads from a MODFLOW-USG binary head-save file, so I'm using flopy as follows:

modelname = 'Model'

import flopy.utils.binaryfile as bf

# Create the headfile object
headobj = bf.HeadFile(modelname+'.hds')
head = headobj.get_data()

However, with the last line I got the following error:

ValueError: cannot reshape array of size 17349 into shape (17338,8670)

The list of records is

(1, 1, 1., 1., b'           HEADU', 1, 8669, 1)
(1, 1, 1., 1., b'           HEADU', 8670, 17338, 2)

What is the correct way to load the heads from an existing MODFLOW-USG model with flopy?

wovano
  • 4,543
  • 5
  • 22
  • 49
Tami
  • 11
  • 1
  • Does this answer your question? [Extract heads from MODFLOW-USG binary output using flopy](https://stackoverflow.com/questions/51734703/extract-heads-from-modflow-usg-binary-output-using-flopy) – wovano Apr 23 '22 at 07:23
  • Have you tried using `get_alldata()` instead of `get_data`? – Robin Thibaut Oct 24 '22 at 12:12

2 Answers2

0

If I pass text='headu' to the HeadFile constructor, then I can read the headsave file for a pretty simple MODFLOW-USG model:

headobj = bf.HeadFile(modelname+'.hds',text='headu')
head = headobj.get_data()
JDub
  • 76
  • 2
0
hdobj = bf.HeadUFile(modelname+'.hds')
head = hdobj.get_data()
  • Welcome to Stack Overflow and thanks for your contribution. While this answer might be correct, code-only answers are generally not preferred. Could you add at least a few lines of text explaining why this code solves the issue? Adding a link to the official documentation (of the `HeadUFile` method) would be useful as well. – wovano Apr 23 '22 at 07:24