Chris' Dataset Helper - Utilities for retrieving climate datasets
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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.post1.dev1.tar.gz.
File metadata
- Download URL: cds_helper-0.0.post1.dev1.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 |
b81fc613239a7240c61508db2a51be9487469e045516584539ad9750912047ea
|
|
| MD5 |
4f7adb018bac99e6367ef7a98d4af53b
|
|
| BLAKE2b-256 |
54ab7ecf6876161774706047a547b72ea84a8070b99b9b4f563f324333f37f04
|
File details
Details for the file cds_helper-0.0.post1.dev1-py3-none-any.whl.
File metadata
- Download URL: cds_helper-0.0.post1.dev1-py3-none-any.whl
- Upload date:
- Size: 9.8 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 |
fdb60df8b9040e42a94cf23957a304528c9ec87c0f6234b72a9b19703dc3a6db
|
|
| MD5 |
2dd1502deddb87e1757920110ec9c08c
|
|
| BLAKE2b-256 |
0daacda5ede089b4f2de3f899422004e3b3787527228a976ca5be626e2ddcf1d
|