我试图从以下网址读取netCDF数据:http://esg-dn1.nsc.liu.se/thredds/fileServer/esg_dataroot4/cordexdata/cordex/output/SEA-22/SMHI/MOHC-HadGEM2-ES/historical/r1i1p1/SMHI-RCA4/v1/day/pr/v20180528/pr_SEA-22_MOHC-HadGEM2-ES_historical_r1i1p1_SMHI-RCA4_v1_day_19510101-19551230.nc
使用xarray,我无法打开文件:
url='http://esg-dn1.nsc.liu.se/thredds/fileServer/esg_dataroot4/cordexdata/cordex/output/SEA-22/SMHI/MOHC-HadGEM2-ES/historical/r1i1p1/SMHI-RCA4/v1/day/pr/v20180528/pr_SEA-22_MOHC-HadGEM2-ES_historical_r1i1p1_SMHI-RCA4_v1_day_19510101-19551230.nc'
import xarray as xr
ds = xr.open_dataset(url)
# xarray cannot open the url
OSError: [Errno -77] NetCDF: Access failure: b'http:...但是当我将url粘贴到浏览器时,它就可以下载了。
有解决办法吗?
发布于 2022-07-26 07:59:24
您可能可以使用esgf:https://esgf-pyclient.readthedocs.io/en/latest/进行访问。正如Michael在评论中所说,您需要一种机制来验证自己。esgf客户端应该允许您对这些数据执行此操作。
首先,您需要注册数据访问。当你打开你给出的网址时,你就可以做到这一点。这将给你一个用户名和密码。完成之后,安装python客户端。然后在python中运行下面的命令,然后尝试在xarray中打开url。
from pyesgf.logon import LogonManager
lm = LogonManager()
lm.is_logged_on()
lm.logon(hostname='esgf-node.llnl.gov', interactive=True, bootstrap=True)
lm.is_logged_on()注意:您似乎有一个访问完整netCDF的url,而您可能希望使用opendap打开它。这将意味着您不需要下载完整的文件,但只需要您想要的。通常,您可以按以下方式修改url:
url = url.replace("fileServer","dodsC")https://stackoverflow.com/questions/73095228
复制相似问题