跳转到主要内容

CADS Toolbox库提供了访问CADS数据和软件的入口点

项目描述

免责声明

本项目的状态为ALPHA,在可预见的未来将处于实验状态。接口和功能可能会更改。请勿在任何运行中的项目/软件中使用此软件。

cads-toolbox

CADS Toolbox库提供了访问CADS数据和软件的入口点

快速入门

导入包

>>> import cads_toolbox
>>> cads_toolbox.config.USE_CACHE = True  # opt-in to use the cache globally

请求一些数据并下载到本地位置

>>> request = [
...    "reanalysis-era5-single-levels",
...    {
...        'variable': '2m_temperature',
...        'product_type': 'reanalysis',
...        'year': '2017',
...        'month': '01',
...        'day': '01',
...        'time': '12:00',
...    }
... ]
>>> remote = cads_toolbox.catalogue.retrieve(*request)
>>> remote.download() # Uses filename on server for downloaded result
'...'
>>> remote.download(target='./test.grib') # Saves result in ./test.ext
'./test.grib'

请求一些数据并探索多态性和缓存

>>> remote = cads_toolbox.catalogue.retrieve(*request)
>>> dataset = remote.to_xarray() # Involves download to your local cache disk (cacholote) and harmonisation of data coordinates and unit names (cgul)
>>> dataset
<xarray.Dataset>
Dimensions:  ...
>>> dataframe = remote.to_pandas() # Uses cached interim result from to_xarray so re-download is not required.

请求一些数据,以xarray数据集的形式打开并使用xarray方法进行绘图

>>> remote = cads_toolbox.catalogue.retrieve(*request)
>>> dataset = remote.to_xarray()
>>> dataset
<xarray.Dataset>
Dimensions:  ...
>>> dataarray = dataset.to_array()  # Use xarray methods to manipulate the object
>>> dataarray
<xarray.DataArray ...
>>> dataarray.isel(time=0).plot()
<matplotlib.collections.QuadMesh object ...

尚未实现:使用CADS工具箱服务在CADS基础设施上执行大型计算作业

>>> remote = cads_toolbox.catalogue.retrieve(*request)  # doctest: +SKIP
>>> climatology = cads_toolbox.climatology(remote, **kwargs)  # doctest: +SKIP
>>> climatology_ds = climatology.to_xarray()  # doctest: +SKIP
>>> # OR downloaded directly:
>>> climatology.download("./my_climatology.nc")  # doctest: +SKIP
'./my_climatology.nc'  # doctest: +SKIP

开发者/贡献者的工作流程

为了获得最佳体验,请创建一个新的conda环境(例如DEVELOP),使用Python 3.10

conda create -n DEVELOP -c conda-forge python=3.10
conda activate DEVELOP

在推送到GitHub之前,请运行以下命令

  1. 更新conda环境: make conda-env-update
  2. 安装此包: pip install -e .
  3. 与最新模板同步(可选): make template-update
  4. 运行质量保证检查: make qa
  5. 运行测试: make unit-tests
  6. 运行静态类型检查器: make type-check
  7. 构建文档(请参阅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-toolbox-0.0.2b0.tar.gz (162.4 kB 查看哈希值)

上传时间 源代码

构建分布

cads_toolbox-0.0.2b0-py3-none-any.whl (11.6 kB 查看哈希值)

上传时间 Python 3

由以下机构支持