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

flopy.utils.binaryfile.HeadFile will not read Henry.hds binary #46

Closed Huite closed 9 years ago

Huite commented 9 years ago

When I run the Henry Saltwater Intrusion Problem script, I can't seem to read the .hds file using flopy.utils.binaryfile.HeadFile. Everything else works just like in the example, I can get the concentrations and cell budgets and make the plot as shown in the example.

When reading a different .hds file, e.g. the lake example or tutorial 2, it works fine.

Running the following snippet

import flopy.utils.binaryfile as bf
bf.HeadFile('lake_example.hds')

gives, as expected

Out[55]:
<flopy.utils.binaryfile.HeadFile at 0x15eba8d0>

But from

import flopy.utils.binaryfile as bf
bf.HeadFile('henry.hds')

I get the following error:

Traceback (most recent call last):

  File "<ipython-input-48-7d116619a952>", line 1, in <module>
    bf.HeadFile('henry.hds')

  File "C:\Anaconda\lib\site-packages\flopy\utils\binaryfile.py", line 562, in __init__
    super(HeadFile, self).__init__(filename, precision, verbose)

  File "C:\Anaconda\lib\site-packages\flopy\utils\binaryfile.py", line 218, in __init__
    self._build_index()

  File "C:\Anaconda\lib\site-packages\flopy\utils\binaryfile.py", line 253, in _build_index
    self.file.seek(self.databytes, 1)

IOError: [Errno 22] Invalid argument

Maybe it has something to do with SEAWAT, since bf.HeadFile works for steady state and transient MODFLOW. Incidentally, none of the examples seem to feature getting the heads from SEAWAT (I'm just starting out though, so my intuitions probably aren't worth much).

It this error reproducible, or is it something on my side?

langevin-usgs commented 9 years ago

Yes, this is a problem with the notebook. The issue is that ipakcb is set to 51 for the well package. So the well budgets are being written to the heads file. If you remove "ipakcb=51" from the well constructor, then it works fine. We will fix the notebook. Thanks for the note.

Huite commented 9 years ago

Great, that fixes it. Thanks.