CADS API Python客户端
项目描述
cads-api-client
CADS API Python客户端
文档: https://ecmwf-projects.github.io/cads-api-client/
ApiClient
需要API根的URL和有效的API key
。您还可以设置环境变量CADS_API_URL
和CADS_API_KEY
,或使用配置文件。配置文件必须位于~/.cads-api-client.json
,或由环境变量CADS_API_RC
指定的路径。
$ cat $HOME/.cads-api-client.json
{"url": "https://cds.climate.copernicus.eu/api", "key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}
(尽管不推荐)可以使用测试用户之一的API密钥,00112233-4455-6677-c899-aabbccddeeff
。此密钥用于匿名测试,旨在成为访问系统的最低性能选项。
草稿Python API
>>> import logging
>>> logging.basicConfig(level="INFO")
>>> import cads_api_client
>>> client = cads_api_client.ApiClient()
>>> client.check_authentication()
{...}
>>> collection_id = "reanalysis-era5-pressure-levels"
>>> collection = client.get_collection(collection_id)
>>> collection.end_datetime
datetime.datetime(...)
>>> request = {
... "product_type": "reanalysis",
... "variable": "temperature",
... "year": "2022",
... "month": "01",
... "day": "01",
... "level": "1000",
... "time": "00:00",
... }
>>> client.retrieve(collection_id, **request, target="tmp1-era5.grib") # blocks
'tmp1-era5.grib'
>>> remote = client.submit(collection_id, **request) # doesn't block
>>> remote.request_uid
'...'
>>> remote.status
'...'
>>> remote.download("tmp2-era5.grib") # blocks
'tmp2-era5.grib'
开发者/贡献者工作流程
为了获得最佳体验,请创建一个新的conda环境(例如DEVELOP)并使用Python 3.11
conda create -n DEVELOP -c conda-forge python=3.11
conda activate DEVELOP
在推送到GitHub之前,请运行以下命令
- 更新conda环境:
make conda-env-update
- 安装此包:
pip install -e .
- 与最新的模板同步(可选):
make template-update
- 运行质量保证检查:
make qa
- 运行测试:
make unit-tests
- 运行静态类型检查器:
make type-check
- 构建文档(请参阅Sphinx教程):
make docs-build
许可
Copyright 2022, European Union.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
项目详情
下载文件
下载适用于您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。
源分发
cads_api_client-1.4.3.tar.gz (40.8 kB 查看哈希值)
构建分发
cads_api_client-1.4.3-py3-none-any.whl (24.3 kB 查看哈希值)