我试图使用NetCDF打开托管在OpenDAP上的THREDDS服务器上的多个xarray.open_mfdataset()文件,但我得到了一个错误。如果我只打开一个文件(但仍然使用open_mfdataset()),它就能工作,如果打开两个,它就不能打开。
例如,它工作得很好:
import xarray as xr
chunks = {'time' : 1, 'depth' : 1}
paths = [
'http://thredds.met.no/thredds/dodsC/fou-hi/norkyst800m-1h/NorKyst-800m_ZDEPTHS_his.an.2017022000.nc',
]
d = xr.open_mfdataset(paths, chunks = chunks)虽然这并不是:
import xarray as xr
chunks = {'time' : 1, 'depth' : 1}
paths = [
'http://thredds.met.no/thredds/dodsC/fou-hi/norkyst800m-1h/NorKyst-800m_ZDEPTHS_his.an.2017022000.nc',
'http://thredds.met.no/thredds/dodsC/fou-hi/norkyst800m-1h/NorKyst-800m_ZDEPTHS_his.an.2017022100.nc',
]
d = xr.open_mfdataset(paths, chunks = chunks)我正在一个jupyter笔记本上运行这个程序,我在笔记本中没有任何输出,它只是一直在运行,而在终端中它会打印以下内容
CURL Error: Failed initialization
curl error details:
CURL Error: Failed initialization
CURL Error: Failed initialization
CURL Error: Failed initialization
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: !�zF^@L������@L�Ы�J�@L�y@L�G`Lp@L�X�ڭ@L�/��a@L���@L��{�:@@L�Hl�D@L���i@L�f���@L�>����@L�x��f@L��DA�h@L�����@L��ڭ�M@L�u���@M
CURL Error: Failed initialization
curl error details:
CURL Error: Failed initialization
CURL Error: Failed initialization
syntax error, unexpected WORD_WORD, expecting $end
context: Dataset { Structure { Float64 lon[Y = 902][X = 2602]; } lon;} fou-hi/norkyst800m-1h/NorKyst-800m_ZDEPTHS_his.an.2017022100.nc;Data^:
CURL Error: Failed initialization
CURL Error: Failed initialization
CURL Error: Failed initialization
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: �@��&��D^@�h�N�{@��I$�@B�从那时起,它就退化成印刷更多的垃圾。
这不是很好吗?
编辑:
我以前并没有意识到这一点,但是事实证明,netCDF4库也支持将多个路径作为一个数据集打开。我不确定这是否相关,因为我不知道xarray和netCDF4是否使用相同的后端,但无论如何,下面的工作都很好。至少这表明问题不在服务器端。
import netCDF4 as nc
d = nc.MFDataset([
'http://thredds.met.no/thredds/dodsC/fou-hi/norkyst800m-1h/NorKyst-800m_ZDEPTHS_his.an.2017022000.nc',
'http://thredds.met.no/thredds/dodsC/fou-hi/norkyst800m-1h/NorKyst-800m_ZDEPTHS_his.an.2017022100.nc',
])发布于 2017-03-07 17:09:41
在我看来,这就像是某种错误--你正确地使用了API,没有内在的理由让它不能工作。但我不知道哪个系统出了故障--很可能是netCDF阅读器还是远程OpenDAP服务器。
https://stackoverflow.com/questions/42651863
复制相似问题