要从 CMIP6 官网下载气象数据,可以使用 Python 的 wget 模块或者 requests 模块来实现。以下是使用 wget 模块的示例代码:

import wget

# 设置下载链接
url = "https://data.mips.copernicus-climate.eu/thredds/fileServer/esg_dataroot/CMIP6/CMIP/INM/INM-CM4-8/historical/r1i1p1f1/Amon/tas/gr/v20190610/tas_Amon_INM-CM4-8_historical_r1i1p1f1_gr_185001-201412.nc"

# 设置保存路径
save_path = "/path/to/save/directory/"

# 下载数据
wget.download(url, save_path)

如果你没有安装 wget 模块,可以使用以下命令进行安装:

pip install wget

另外,如果你想要使用 requests 模块进行下载,可以使用以下示例代码:

import requests

# 设置下载链接
url = "https://data.mips.copernicus-climate.eu/thredds/fileServer/esg_dataroot/CMIP6/CMIP/INM/INM-CM4-8/historical/r1i1p1f1/Amon/tas/gr/v20190610/tas_Amon_INM-CM4-8_historical_r1i1p1f1_gr_185001-201412.nc"

# 设置保存路径
save_path = "/path/to/save/directory/"

# 发起请求并下载数据
response = requests.get(url)
with open(save_path, "wb") as f:
    f.write(response.content)

如果你没有安装 requests 模块,可以使用以下命令进行安装:

pip install requests

请记得将 url 设置为你要下载的具体数据的链接,并将 save_path 设置为你要保存数据的路径。

Python CMIP6 气象数据下载教程:wget 和 requests 模块方法

原文地址: https://www.cveoy.top/t/topic/nSdg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录