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

OSError: obtaining file position failed #277

Closed person0712 closed 6 years ago

person0712 commented 6 years ago

I am learning to use flopy to read a cell budget binary file (test.ccf) output from MODFLOW-USG. I followed the tutorial (flopy.utils.binaryfile Module) to read the binary file. But I got an error showing obtaining file position failed. It seems like it's a different issue from the issue "no such file or directory". I tried to figure it out what's the reason causing this, but I didn't get it. Does anyone know what steps I miss so that I got the error? Thanks. The version of Python I use is 3.6.3.

import flopy.utils.binaryfile as bf cbb = bf.CellBudgetFile('test.ccf') Traceback (most recent call last): File "", line 1, in File "C:\Users\user\Anaconda3\lib\site-packages\flopy\utils\binaryfile.py", line 601, in init self._build_index() File "C:\Users\user\Anaconda3\lib\site-packages\flopy\utils\binaryfile.py", line 654, in _build_index header = self._get_header() File "C:\Users\user\Anaconda3\lib\site-packages\flopy\utils\binaryfile.py", line 764, in _get_header header1 = binaryread(self.file, self.header1_dtype, (1,)) File "C:\Users\user\Anaconda3\lib\site-packages\flopy\utils\binaryfile.py", line 156, in binaryread result = np.fromfile(file, vartype, nval) OSError: obtaining file position failed

langevin-usgs commented 6 years ago

Can you tell me the size of the file? And if the file is small, less than a megabyte, then you can paste it into this issue. You might also set verbose = True to see if that gives you some idea of the problem.

cbb = bf.CellBudgetFile('test.ccf', verbose=True)
person0712 commented 6 years ago

The size of the file is 2.4 GB. Maybe it's the reason of the error?

langevin-usgs commented 6 years ago

Did you try the verbose argument?

person0712 commented 6 years ago

Yes, I did. It showed some information for each stress period like below. But it stopped in stress period 56, the total stress period of the model is 67. Also, the error of obtaining file position failed is showed at the end.

kstp: 1 kper: 56 text: FLOW JA FACE ncol: 8415864 nrow: 1 nlay: -1 imeth: 1 delt: 1.0 pertim: 1.0 totim: 56.0 modelnam: paknam: modelnam2: paknam2: file position: 2126773140

langevin-usgs commented 6 years ago

That is a good clue. I might have an idea. Any chance you are using a 32-bit version of Windows?

person0712 commented 6 years ago

I have a desktop with a 32-bit version of Windows 7, or I can install VirtualBox to use a 32-bit version of Windows.

langevin-usgs commented 6 years ago

This appears to be related to the large file size and the use of a 32-bit Windows OS. I'm not positive of that, but from what I can tell, that file position cannot be represented accurately enough. As mentioned here (https://stackoverflow.com/questions/7604966/maximum-and-minimum-values-for-ints), 2**31 is equal to 2147483648, which is similar to the file position value you report. I'd suggest that you save your values less frequently, or try reading this file on a 64-bit OS. Let me know if you discover otherwise, and I can take a deeper look.