Skip to main content

CADS Toolbox library provides an entry point to the CADS data and software

Project description

DISCLAIMER:

This project is ALPHA and will be Experimental for the forseable time. Interfaces and functionality are likely to change. DO NOT use this software in any project/software that is operational.

cads-toolbox

CADS Toolbox library provides an entry point to the CADS data and software

Quick Start

import the package

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

Request some data and download to a local location

>>> 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'

Request some data and explore polymorphism and caching

>>> 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.

Request some data, open as an xarray dataset and plot using xarray methods

>>> 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 ...

NOT YET IMPLEMENTED: Use the CADS toolbox service to execute large compute jobs on the CADS infrastructure

>>> 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

Workflow for developers/contributors

For best experience create a new conda environment (e.g. DEVELOP) with Python 3.10:

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

Before pushing to GitHub, run the following commands:

  1. Update conda environment: make conda-env-update
  2. Install this package: pip install -e .
  3. Sync with the latest template (optional): make template-update
  4. Run quality assurance checks: make qa
  5. Run tests: make unit-tests
  6. Run the static type checker: make type-check
  7. Build the documentation (see Sphinx tutorial): make docs-build

License

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

    http://www.apache.org/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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cads-toolbox-0.0.2b0.tar.gz (162.4 kB view details)

Uploaded Source

Built Distribution

cads_toolbox-0.0.2b0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file cads-toolbox-0.0.2b0.tar.gz.

File metadata

  • Download URL: cads-toolbox-0.0.2b0.tar.gz
  • Upload date:
  • Size: 162.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for cads-toolbox-0.0.2b0.tar.gz
Algorithm Hash digest
SHA256 9b9ad782028b67406d3ff514afa75b53b6167495d7108188bad7e0b9d20988b6
MD5 61c11eaa9799751d79d1bbf1fc8e3007
BLAKE2b-256 a9d8b1e1981525eb26c6c24c5097edc5c6c3e50bc257c002982ff04f8d7bda56

See more details on using hashes here.

File details

Details for the file cads_toolbox-0.0.2b0-py3-none-any.whl.

File metadata

File hashes

Hashes for cads_toolbox-0.0.2b0-py3-none-any.whl
Algorithm Hash digest
SHA256 82c1f7b1ba11ae0f5556a86baaf43b2255cfa8052ba13370997a8dfbbd026a8d
MD5 a7e948b14faea19a6b2b083fdc5e47e6
BLAKE2b-256 0cfc65c2c8e61f02df7117591dc4b3fedd482b9d4c873d42e58384c709829af1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page