Pre-release
This release is a pre-release and may not be stable for production use.
CDS-Helper
Utility to make retrieval of a contiguous set of data files easier.
Installation
pip install cds-helper
Using the CLI
1. Parameterize a request
Create a JSON file describing your desired download.
// cdsrequest.json
{
"dataset": "reanalysis-era5-single-levels",
"start_date": "2027-01-01",
"end_date": "2027-12-31",
"dataset": "reanalysis",
"variables": [
"10m_u_component_of_wind",
"10m_v_component_of_wind",
"2m_dewpoint_temperature",
"2m_temperature",
"sea_surface_temperature",
"total_precipitation",
"surface_net_solar_radiation",
"surface_thermal_radiation_downwards",
]
}
[!NOTE] You can let the cli generate a template
JSONfile for you:cdshelper template -request ./request.json
2. Execute the request
Pass the path to your JSON file to cdshelper request
cdshelper request ./cdsrequest.json
Using the library in your code
import asyncio
import datetime
import logging
import pathlib
import sys
from cds_helper.core import (
CdsDataRequest,
download_monthly_data,
)
async def retrieval_demo(log: logging.Logger) -> None:
"""Demo usage of the method `download_monthly_data` from CDS helper."""
# Create a CdsDataRequest defining the parameters for retrieval.
request = CdsDataRequest(
"reanalysis-era5-single-levels",
datetime(2017, 1, 1),
datetime(2017, 2, 1),
"reanalysis",
variables=[
"10m_u_component_of_wind",
"10m_v_component_of_wind",
"2m_dewpoint_temperature",
"2m_temperature",
"sea_surface_temperature",
"total_precipitation",
"surface_net_solar_radiation",
"surface_thermal_radiation_downwards",
],
)
# Create a mapping from the paths in the archive to the desired
# local paths. Add a string template `{0}` to allow cds-helper to
# rename output files based on the request parameters.
file_map = {
"data_stream-oper_stepType-instant.nc": "{0}_inst.nc",
"data_stream-oper_stepType-accum.nc": "{0}_inst.nc",
}
# Specify the directory where output will be stored.
output_to = pathlib.Path("~/datasets").expanduser()
# Trigger retrieval.
download_monthly_data(request, file_map, output_to)
async def main(_args_list: list[str]) -> int:
"""Execute the cds-helper CLI."""
logging.basicConfig(level=logging.INFO)
log = logging.getLogger()
retrieval_demo(log)
if __name__ == "__main__":
rc = asyncio.run(main(sys.argv[1:]))
sys.exit(rc)
Metadata
Release files for cds-helper 0.0.1a2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cds_helper-0.0.1a2.tar.gz | 10.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cds_helper-0.0.1a2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.9 kB
Release files / cds_helper-0.0.1a2.tar.gz
| Download URL | cds_helper-0.0.1a2.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8f3d2735cedccbaa7719f3354714d23bac8da4181b837d9a595673c0ecd5672
|
|
BLAKE2b-256 checksum How to use checksums |
6101ebf808550487f3ce7dbe87f5ff75e1b9e2ba58e84e19171439f137efa98b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.12
|
Release files / cds_helper-0.0.1a2-py3-none-any.whl
| Download URL | cds_helper-0.0.1a2-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22a60d405c3137afb28e945e6ca5b8a925e3eacbf565995e4cff522060da23ba
|
|
BLAKE2b-256 checksum How to use checksums |
72960f5eff1d239129aa5d77558ec9d1cc54bf837ff5927c89ecec64352a7a97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.12
|