Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: flopy.utils.binaryfile.HeadUFile.get_ts() gives error for idx= 0 #1519

Closed
giovannifi opened this issue Aug 29, 2022 · 15 comments
Closed
Labels

Comments

@giovannifi
Copy link

giovannifi commented Aug 29, 2022

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.

@giovannifi giovannifi added the bug label Aug 29, 2022
@giovannifi giovannifi changed the title bug: flopy.utils.binaryfile.HeadUFile.get_ts() gives error for node = 0 bug: flopy.utils.binaryfile.HeadUFile.get_ts() gives error for idx= 0 Aug 29, 2022
@wpbonelli
Copy link
Contributor

Hey @giovannifi, this should be fixed by #1510. To get around this until a new release you can work from the head of the develop branch.

@wpbonelli
Copy link
Contributor

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.

@giovannifi
Copy link
Author

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?

@cnicol-gwlogic
Copy link
Contributor

cnicol-gwlogic commented Nov 13, 2022

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

@giovannifi
Copy link
Author

tried that, it installs version 3.3.5.

@cnicol-gwlogic
Copy link
Contributor

See my edited comment

@giovannifi
Copy link
Author

giovannifi commented Nov 13, 2022

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)')))

@cnicol-gwlogic
Copy link
Contributor

Not sure on that one. You could try this instead:
Pip install -U --force-reinstall git+https://github.com/modflowpy/flopy@develop

@wpbonelli
Copy link
Contributor

@giovannifi if you're on mac and haven't previously installed certificates for your Python distribution, this might help

@giovannifi
Copy link
Author

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

@mbakker7
Copy link
Contributor

For future reference, @giovannifi, how did you manage to install it?

@giovannifi
Copy link
Author

giovannifi commented Nov 14, 2022

@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.

@mbakker7
Copy link
Contributor

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.

@giovannifi
Copy link
Author

giovannifi commented Nov 14, 2022

@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.

@mwtoews
Copy link
Contributor

mwtoews commented Nov 15, 2022

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 f9e98ed 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants