如果您访问此网站:
https://ruc.noaa.gov/raobs/raobs/data_request.cgi? Byr = 2010& bmo = 5& bdy = 26& bhr = 12& eyr = 2010& emo = 5& eDy = 27& ehr = 15& amp; shour = all+times+times+times& ltype = all+lacte& amp; amp; amp; wunits = knots = knots& amp& amp; amp; amp; amp; amp; amp; amp; amp; amp》 = = WMO+站+标识符
键入框中的“ 72632”,然后将“格式”更改为“ NetCDF格式(二进制)”,然后单击“继续数据访问”,将NETCDF文件下载到您的计算机上。
如果我使用Chrome Developer工具在单击此按钮后跟踪网络活动,我可以看到导致该文件下载的“请求URL”是:
https:> https://ruc.noaa.gov/getraobs/getraobs/getraobs/getraobs/getraobs。 CGI? oformat = netcdf+格式+%28Binary%29
如果将URL复制并粘贴到Web浏览器中,则将下载该文件。
我要做的是使用Python进行像上面的URL格式化,并检索关联的NetCDF文件。
过去,我很幸运地做了类似的事情,
url = 'https://ruc.noaa.gov/raobs/GetRaobs.cgi?shour=All+Times<ype=All+Levels&wunits=Knots&bdate=2010052612&edate=2010052715&access=WMO+Station+Identifier&view=NO&StationIDs=72632&osort=Station+Series+Sort&oformat=NetCDF+format+%28Binary%29'
da = xr.open_dataset(url)
但是在这种情况下这不起作用:
OSError: [Errno -75] NetCDF: Malformed or unexpected Constraint: b'https://ruc.noaa.gov/raobs/GetRaobs.cgi?shour=All+Times<ype=All+Levels&wunits=Knots&bdate=2010052612&edate=2010052715&access=WMO+Station+Identifier&view=NO&StationIDs=72632&osort=Station+Series+Sort&oformat=NetCDF+format+%28Binary%29'
我也尝试 wget
url,但这只是下载了我的“ .cgi”文件不要认为有用。
感谢您的帮助!
If you go to this website:
https://ruc.noaa.gov/raobs/Data_request.cgi?byr=2010&bmo=5&bdy=26&bhr=12&eyr=2010&emo=5&edy=27&ehr=15&shour=All+Times<ype=All+Levels&wunits=Knots&access=WMO+Station+Identifier
Type "72632" into the box, and change "Format" to "NetCDF format (binary)", and then click "Continue Data Access", a NetCDF file is downloaded to your computer.
If I use the Chrome developer tools to track network activity after clicking this button, I can see the the "Request URL" which leads to this file being downloaded is:
https://ruc.noaa.gov/raobs/GetRaobs.cgi?shour=All+Times<ype=All+Levels&wunits=Knots&bdate=2010052612&edate=2010052715&access=WMO+Station+Identifier&view=NO&StationIDs=72632&osort=Station+Series+Sort&oformat=NetCDF+format+%28Binary%29
If you copy and paste that URL into a web browser, the file is downloaded.
What I want to do is use Python to take a URL formatted like the one above, and retrieve the associated NetCDF file.
I've had luck in the past doing something like
url = 'https://ruc.noaa.gov/raobs/GetRaobs.cgi?shour=All+Times<ype=All+Levels&wunits=Knots&bdate=2010052612&edate=2010052715&access=WMO+Station+Identifier&view=NO&StationIDs=72632&osort=Station+Series+Sort&oformat=NetCDF+format+%28Binary%29'
da = xr.open_dataset(url)
But that doesn't work in this case:
OSError: [Errno -75] NetCDF: Malformed or unexpected Constraint: b'https://ruc.noaa.gov/raobs/GetRaobs.cgi?shour=All+Times<ype=All+Levels&wunits=Knots&bdate=2010052612&edate=2010052715&access=WMO+Station+Identifier&view=NO&StationIDs=72632&osort=Station+Series+Sort&oformat=NetCDF+format+%28Binary%29'
I've also tried to wget
the URL, but that just downloads a ".cgi" file which I don't think is useful.
Thanks for any help!
发布评论
评论(1)
您可以使用我的软件包nctoolkit下载文件,然后导出到Xarray。这将将文件保存到临时目录中,但一旦会话完成,将其删除。
You could use my package nctoolkit to download the file and then export to xarray. This will save the file to a temporary directory, but will remove it once the session is done.