Repository navigation
Description
I found, what i guess is a bug in the netcdf4 library.
I am using anaconda with python 3.6.3 and Ipython 6.1.0
I tried to read a file via opendap when just starting my ipython, which works:
import netCDF4
ds = netCDF4.Dataset('http://thredds.socib.es/thredds/dodsC/hf_radar/hf_radar_ibiza-scb_codarssproc001/L1/2016/dep0001_hf-radar-ibiza_scb-codarssproc001_L1_2016-02.nc')
The problem arises when I load some other libraries and try to load the same file. Doing the following:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
OSError: [Errno -36] NetCDF: Invalid argument: b'http://thredds.socib.es/thredds/dodsC/hf_radar/hf_radar_ibiza-scb_codarssproc001/L1/2016/dep0001_hf-radar-ibiza_scb-codarssproc001_L1_2016-02.nc'
However, I can read local netcdf files and also files via opendap with a shorter name:
This works fine! It also works fine when executing the same code in jupyter notebook. Any explanation? Cheers
Activity
jswhit commentedon Jan 18, 2018
Sorry, but I have no idea. Does it work if you don't import pandas, or if you import netCDF4 last?
rsignell-usgs commentedon Jan 18, 2018
The provided example:
works fine for me, produces no errors.
My NetCDF version is 1.3.1
jswhit commentedon Jan 18, 2018
Works here too.
jhlasheras commentedon Jan 18, 2018
That's rigth. I have tried it in a macbook and it works fine. However in my ubuntu 14.04 it continuosly give an error. Both of them using netCDF4 version 1.3.1. Also in other mates computer with similar configuration the same error happened.
May anaconda netcdf library be interfering with some other netcdf library?
dopplershift commentedon Jan 18, 2018
This might depend on the version of the netCDF-C library being used. IIRC, there were some versions that got a bit more picky about some of the opendap parsing.
cgohlke commentedon Feb 18, 2018
At least on Windows, this issue is fixed by Unidata/netcdf-c#366 (for me)
jhlasheras commentedon Feb 20, 2018
I found the problem may be due to the matplotlib backend.
When initializing with Tk backend the problem dissaspears.
Adding this at the begining of the script solves the problem:
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
everything works fine untill I execute %matplotlib