metno / NWPdocs

Description of the numerical weather prediction products at MET Norway
GNU General Public License v3.0
14 stars 4 forks source link

Python scripts to download nc files are not working? #16

Closed paapu88 closed 1 year ago

paapu88 commented 1 year ago

Dear developers,

I try to run (copy pasted from https://github.com/metno/NWPdocs/wiki/Examples#extracting-and-plotting-a-variable )

import netCDF4
filename = "https://thredds.met.no/thredds/dodsC/metpparchive/"+\
           "2021/08/01/met_analysis_1_0km_nordic_20210801T12Z.nc"
ncfile   = netCDF4.Dataset(filename)

This results to

Error:curl error: Problem with the SSL CA cert (path? access rights?)
curl error details: 
Warning:oc_open: Could not read url
Traceback (most recent call last):
  File "/home/hu-mka/git/linux-weatherstation/machinelearning/dev/metno_demo1.py", line 7, in <module>
    ncfile = netCDF4.Dataset(filename)
  File "src/netCDF4/_netCDF4.pyx", line 2353, in netCDF4._netCDF4.Dataset.__init__
  File "src/netCDF4/_netCDF4.pyx", line 1963, in netCDF4._netCDF4._ensure_nc_success
OSError: [Errno -68] NetCDF: I/O failure: b'https://thredds.met.no/thredds/dodsC/metpparchive/2021/08/01/met_analysis_1_0km_nordic_20210801T12Z.nc'

pip command given (as instructed in https://github.com/metno/NWPdocs/wiki/Examples#extracting-and-plotting-a-variable) pip install matplotlib netCDF4 numpy pyproj xarray

pip freeze shows

certifi==2022.6.15
cftime==1.6.1
cycler==0.11.0
fonttools==4.37.1
kiwisolver==1.4.4
matplotlib==3.5.3
netCDF4==1.6.0
numpy==1.23.2
packaging==21.3
pandas==1.4.3
Pillow==9.2.0
pyparsing==3.0.9
pyproj==3.3.1
python-dateutil==2.8.2
pytz==2022.2.1
six==1.16.0
xarray==2022.6.0

I have ubuntu 22.04

Are there some special versions of the libraries one should use? I remember this did work earlier (but with different versions of the libraries).

Terveisin, Markus

paapu88 commented 1 year ago

Ok, that seemed to be a problem related to netcdf, for the moment could not fiind other solution than downgrading netcdf to 1.5.7 (see below)

The following code works now fine, in pip environment given below

import netCDF4

filename = (
    "https://thredds.met.no/thredds/dodsC/metpparchive/"
    + "2021/08/01/met_analysis_1_0km_nordic_20210801T12Z.nc"
)
ncfile = netCDF4.Dataset(filename)
print(f"nc: {ncfile}")

pip freeze (after pip install netcdf4==1.5.7) `

certifi==2022.6.15
cftime==1.6.1
cycler==0.11.0
fonttools==4.37.1
kiwisolver==1.4.4
matplotlib==3.5.3
netCDF4==1.5.7
numpy==1.23.2
packaging==21.3
pandas==1.4.3
Pillow==9.2.0
pyparsing==3.0.9
pyproj==3.3.1
python-dateutil==2.8.2
pytz==2022.2.1
six==1.16.0
xarray==2022.6.0