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)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cds_helper-0.0.1a2.tar.gz
(10.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cds_helper-0.0.1a2.tar.gz.
File metadata
- Download URL: cds_helper-0.0.1a2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8f3d2735cedccbaa7719f3354714d23bac8da4181b837d9a595673c0ecd5672
|
|
| MD5 |
efe3fa68566eaf2973af766474d93a88
|
|
| BLAKE2b-256 |
6101ebf808550487f3ce7dbe87f5ff75e1b9e2ba58e84e19171439f137efa98b
|
File details
Details for the file cds_helper-0.0.1a2-py3-none-any.whl.
File metadata
- Download URL: cds_helper-0.0.1a2-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22a60d405c3137afb28e945e6ca5b8a925e3eacbf565995e4cff522060da23ba
|
|
| MD5 |
2dc348bb0a8367a773f14fb5bcb6ac36
|
|
| BLAKE2b-256 |
72960f5eff1d239129aa5d77558ec9d1cc54bf837ff5927c89ecec64352a7a97
|