无法使用新测试版CDS下载era5的数据

问题描述 投票:0回答:1

我无法使用Python中的cdsapi代码从era5下载数据。

这可能是由于我的 cdsapi 更新不正确,但不确定。

我已经分享了我的代码和错误消息.....如果有人知道其更正,请指导。

import cdsapi

dataset = "reanalysis-era5-single-levels"
request = {
    'product_type': ['reanalysis'],
    'variable': ['10m_u_component_of_wind', '10m_v_component_of_wind'],
    'year': ['2024'],
    'month': ['05'],
    'day': ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14',       '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
    'time': ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00',   '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00',   '20:00', '21:00', '22:00', '23:00'],
    'data_format': 'netcdf',
    'download_format': 'unarchived',
    'area': [38, 61, 23, 81]
}

client = cdsapi.Client()
client.retrieve(dataset, request).download()

使用上面的代码,我收到以下错误消息。 在我看来,这可能是因为新的 cdsapi key 的语法问题

2024-08-05 17:14:42,529 INFO Sending request to https://cds-beta.climate.copernicus.eu/api/resources/reanalysis-era5-single-levels
Traceback (most recent call last):
File "C:\\Users\\SHAHID HUSSAIN\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\cdsapi\\api.py", line 442, in \_api
result.raise_for_status()
File "C:\\Users\\SHAHID HUSSAIN\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\requests\\models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://cds-beta.climate.copernicus.eu/api/resources/reanalysis-era5-single-levels

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\\Year 2024\\may_uvwind10m.py", line 17, in \<module\>
client.retrieve(dataset, request).download()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\\Users\\SHAHID HUSSAIN\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\cdsapi\\api.py", line 364, in retrieve
result = self.\_api("%s/resources/%s" % (self.url, name), request, "POST")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\\Users\\SHAHID HUSSAIN\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\cdsapi\\api.py", line 464, in \_api
raise Exception(error)
Exception: Not Found
era5 cds.copernicus
1个回答
0
投票

有同样的问题,我需要更新 .cdsapi 文件,因为 url 和密钥由于某种原因发生了更改。

https://cds.climate.copernicus.eu/how-to-api

目前它表示该文件应包含: 网址:https://cds.climate.copernicus.eu/api 密钥:db7a9f5c-2064-4a6e-9b4f-d220a04a128e

© www.soinside.com 2019 - 2024. All rights reserved.