flopy
flopy copied to clipboard
bug: flopy.utils.binaryfile.HeadUFile.get_ts() gives error for idx= 0
I am trying to run this script:
import flopy
import flopy.utils.binaryfile as bf
path_exe = r'C:\modflow'
path_model = r'c:\models'
modelname = 'mymodel'
heads = bf.HeadUFile(path_model + '\\' + modelname + '.hds') # hds file generated with the software mf-usg
print(heads.get_ts(idx=0))
and I get the following error message:
{IndexError}index -682005 is out of bounds for axis 0 with size XXXX
If I use any number between 1 and (XXXX - 1), I get a timeseries without any problem. I have the feeling that the command does not read node 0.
PS I am running flopy v 3.3.5 on a python 3.9 environment.
Hey @giovannifi, this should be fixed by https://github.com/modflowpy/flopy/pull/1510. To get around this until a new release you can work from the head of the develop branch.
Hi @giovannifi was this problem resolved for you? I rechecked some of flopy's example .hds
files and didn't encounter the issue. Wanted to confirm before closing as there is a new release coming shortly.
I am currently using python 3.9. I tried to run pip install flopy --upgrade
but it does not give me the possibility to get the latest version of flopy (3.3.6). So I cannot really verify. Do I need to run python 3.10 to be able to install the latest version of flopy?
Try to add the --force-reinstall switch
...just noticed you aren't pointing it to the develop branch. Use this: Pip install https://github.com/modflowpy/flopy/zipball/develop -U --force-reinstall
tried that, it installs version 3.3.5.
See my edited comment
The command does not work for me due to SSL certificate limitation imposed by my company policies. it seems I can get the package only from the official repository. I have to work out with IT how I can run your command. For the moment this is the error message I get:
Collecting https://github.com/modflowpy/flopy/zipball/develop
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate signature failure (_ssl.c:1123)'))': /modflowpy/flopy/zipball/develop
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate signature failure (_ssl.c:1123)'))': /modflowpy/flopy/zipball/develop
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate signature failure (_ssl.c:1123)'))': /modflowpy/flopy/zipball/develop
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate signature failure (_ssl.c:1123)'))': /modflowpy/flopy/zipball/develop
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate signature failure (_ssl.c:1123)'))': /modflowpy/flopy/zipball/develop
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /modflowpy/flopy/zipball/develop (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate signature failure (_ssl.c:1123)')))
Not sure on that one. You could try this instead: Pip install -U --force-reinstall git+https://github.com/modflowpy/flopy@develop
@giovannifi if you're on mac and haven't previously installed certificates for your Python distribution, this might help
Thanks all for the suggestions. I have finally managed to bypass the SSL issue by downloading the zip flopy package and manually install version 3.3.6. I re-run my script and it does not throw any error. So, yes this can be closed.
Thanks
For future reference, @giovannifi, how did you manage to install it?
@mbakker7 I used the link provided by @cnicol-gwlogic in the post above (https://github.com/modflowpy/flopy/zipball/develop). This allowed me to download a zip file. Then I simply run the command: pip install <zipfilename>.zip
As you are asking, I take advantage of this to say the things I do not understand:
- why is the zip file called modflowpy-flopy-3.3.5-215-g00757a4.zip, i.e. why does the file name contain the old flopy version? I can confirm that after the installation I had version 3.3.6 installed.
- why is not posible to install the upgrade from the official repository (pypi.org)? if you check this page https://pypi.org/project/flopy/ the latest version is still 3.3.5.
Let me start with a question: Did the suggestion from @cnicol-gwlogic not work? I think that is the official approach to pip install a version from a specific branch on github (although I have never tried that myself). Did you try it that way or do you have administrator restrictions to run that command? Or does that command only give you the zip file?
Version 3.3.6 has not been officially released. You installed the development branch from github, which has a file called version.py which contains the version number for when the development branch becomes the latest release. Once the development branch is the latest release, it will be possible to install it with pip install.
@mbakker7 I thought my previous messages were pretty clear in this regard. I explained that @cnicol-gwlogic command did not work in my case as my company restricts the access to some external websites via command line executions. I do not really know the details of the problem, I sent a request to the IT of my company to discover the issue but I got no answer. In any case the command returned a SSL certificate issue. I had similar problems in the past that were related to my company policy restrictions. Indeed, I do not have admin rights for my PC. If you want to see the error message I got, please check my post above. I simply copied and pasted the link in the command provided by @cnicol-gwlogic into a web browser and this downloaded the above mentioned zip file.
I normally recommend the zipfile approach for two reasons: (1) it does not depend on git being installed (with certificates, etc.), and (2) it is faster to process. The git+https method does not work without git, and takes longer since it needs to clone every commit from the repo (from the first f9e98ed8428fa8ddb4e8b1e5ab493cacb8eab238 and onwards).
This should work to upgrade a pip-installed version:
pip uninstall --yes flopy
pip install https://github.com/modflowpy/flopy/archive/refs/heads/develop.zip