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

Fix Hamtide #188

Closed
SorooshMani-NOAA opened this issue Jun 18, 2024 · 5 comments · Fixed by #189
Closed

Fix Hamtide #188

SorooshMani-NOAA opened this issue Jun 18, 2024 · 5 comments · Fixed by #189
Assignees

Comments

@SorooshMani-NOAA
Copy link
Collaborator

SorooshMani-NOAA commented Jun 18, 2024

It seems that the updated netCDF4 package cannot work with the OPeNDAP link

@SorooshMani-NOAA SorooshMani-NOAA self-assigned this Jun 20, 2024
@SorooshMani-NOAA
Copy link
Collaborator Author

Pinning numpy to <2 and netCDF4 to <1.7 will resolve the issue:

In [1]: from netCDF4 import Dataset

In [2]: Dataset('https://icdc.cen.uni-hamburg.de/thredds/dodsC/ftpthredds/hamtide/k2.hamtide11a.nc')
Error:curl error: Problem with the SSL CA cert (path? access rights?)
curl error details:
Warning:oc_open: Could not read url
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Cell In[2], line 1
----> 1 Dataset('https://icdc.cen.uni-hamburg.de/thredds/dodsC/ftpthredds/hamtide/k2.hamtide11a.nc')

File src/netCDF4/_netCDF4.pyx:2470, in netCDF4._netCDF4.Dataset.__init__()

File src/netCDF4/_netCDF4.pyx:2107, in netCDF4._netCDF4._ensure_nc_success()

OSError: [Errno -68] NetCDF: I/O failure: 'https://icdc.cen.uni-hamburg.de/thredds/dodsC/ftpthredds/hamtide/k2.hamtide11a.nc' 

Ideally we should try to resolve this without the need to pin packages!

@SorooshMani-NOAA
Copy link
Collaborator Author

SorooshMani-NOAA commented Jun 20, 2024

It's obvious, but just for the sake of completeness, if I try to read opendap netcdf through the xarray it fails with version 1.7 and up.

Note that the version of numpy above was required due to compatibility issue with netCDF-python. It seems numpy==2 doesn't work with older versions of netCDF4 (<1.7)!

In [1]: from netCDF4 import Dataset
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 from netCDF4 import Dataset

File ~/miniconda3/envs/adcircpy/lib/python3.10/site-packages/netCDF4/__init__.py:3
      1 # init for netCDF4. package
      2 # Docstring comes from extension module _netCDF4.
----> 3 from ._netCDF4 import *
      4 # Need explicit imports for names beginning with underscores
      5 from ._netCDF4 import __doc__

File src/netCDF4/_netCDF4.pyx:1, in init netCDF4._netCDF4()

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

@SorooshMani-NOAA
Copy link
Collaborator Author

SorooshMani-NOAA commented Jun 21, 2024

If I install netCDF4 python package using conda/mamba I won't run into the original issue with Hamtide; I can read the URL. Maybe we need to just find the right way to install it using PIP, or just pin the version in the CI tests installation

@SorooshMani-NOAA
Copy link
Collaborator Author

This seems to be the solution! Unidata/netcdf4-python#1179 (comment)

We need to install the netcdf library by rebuilding:

python -m pip install --upgrade --force-reinstall --no-deps --no-cache-dir netcdf4 --no-binary netcdf4

@SorooshMani-NOAA
Copy link
Collaborator Author

There seems to be a fix for netcdf4 on python. 1.7.1.post1 let's try that as well!

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

Successfully merging a pull request may close this issue.

1 participant