DOI-USGS / dataretrieval-python

Python package for retrieving water data from USGS or the multi-agency Water Quality Portal
https://doi-usgs.github.io/dataretrieval-python/
Other
162 stars 38 forks source link

retreiving record using gwlevels fails with ValueError date in wrong format (using example provided online) #166

Open Ben-Choat opened 1 week ago

Ben-Choat commented 1 week ago

Using the example linked below and provided in the official documentation fails with: ValueError: time data '1945-10-12 22:35 +0000' does not match format 'ISO8601' (match).

df = dataretrieval.nwis.get_record( sites="434400121275801", service="gwlevels" )

https://doi-usgs.github.io/dataretrieval-python/reference/nwis.html#dataretrieval.nwis.get_record:~:text=%23%20Get%20latest%20groundwater%20level%20for%20site%20434400121275801%0A%3E%3E%3E%20df%20%3D%20dataretrieval.nwis.get_record(%0A...%20%20%20%20%20sites%3D%22434400121275801%22%2C%20service%3D%22gwlevels%22%0A...%20)

ehinman commented 1 week ago

Hi @Ben-Choat, thanks for identifying an issue. Are you using the latest version of dataretrieval-python? The gwlevels service recently changed, and we made some updates to the package. You can see details in the read me here: https://github.com/DOI-USGS/dataretrieval-python?tab=readme-ov-file#dataretrieval-download-hydrologic-data

I just ran this line of code using the latest version of the package and it worked ok for me, but please let me know if this issue persists for you. Thanks so much!

Ben-Choat commented 1 week ago

Hello @ehinman, Version seemed to be the issue. I just checked the version using dataretrieval.version and it came back as 0.0.0 which is very surprising. I just installed it this past Friday (the 27th) using conda install dataretrieval -c conda-forge.

I just tried updating using conda update dataretrieval but it still says version 0.0.0.

I tried specifying the version conda install dataretrieval=1.0.10 -c conda-forge . I received a message that it is already installed and .version still returns 0.0.0.

Running conda install conda-forge::dataretrieval had the same effect.

Building a new virtual environment with venv and installing via pip install dataretrieval seems to have done the job with .version now showing 1.0.10 and the sample code running as expected.

When I was using conda, I was trying to install in an existing conda environment, so that may have caused issues for some reason. I have not tried installing in a fresh conda environment.

ehinman commented 1 week ago

Thanks for the info, I will investigate on my machine as well.