'Error extracting heads from MODFLOW-USG binary with flopy
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?
Solution 1:[1]
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()
Solution 2:[2]
hdobj = bf.HeadUFile(modelname+'.hds')
head = hdobj.get_data()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | JDub |
| Solution 2 | hydrogeologist |
