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.1a0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

cads_toolbox-0.0.1a0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file cads-toolbox-0.0.1a0.tar.gz.

File metadata

  • Download URL: cads-toolbox-0.0.1a0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for cads-toolbox-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 b6af7b3fff9003b20221a9aafc7d1634c82b0483f18a6f8d61ac8b7c256df25a
MD5 2ba2d43fb274b8e670600e8a48b46e17
BLAKE2b-256 ca9cf7fea5d500d74d2c62aa44a46be14fb138738a01af6f3a48ea5f58863037

See more details on using hashes here.

File details

Details for the file cads_toolbox-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for cads_toolbox-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 7713ac0526235a8b8caa8bfba5ac04d7e4c4e0f90846ff286ebcb2c866fdfe5a
MD5 ba0e927bcbcdf8eefdb0a42d39ac0fa8
BLAKE2b-256 deee04b9a11f36e18d7040329a02eeb988d97d21bdccbf39f649183c2f7bde5e

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