# HG changeset patch # User climate # Date 1773065503 0 # Node ID d7b62d55f8dda18588600f8c666d247cb399499e # Parent 21e8386cf36f9e6c979d3cde7dd1876110b780bd planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/c3s commit 706e03c8e81940b6e10d3fd7b412d30b46b46ce7 diff -r 21e8386cf36f -r d7b62d55f8dd c3s.xml --- a/c3s.xml Fri Sep 27 19:34:36 2024 +0000 +++ b/c3s.xml Mon Mar 09 14:11:43 2026 +0000 @@ -1,4 +1,4 @@ - + for retrieving climate data topic_3855 @@ -15,15 +15,17 @@ cdo tar unzip + + + + + + + Preferences -> Manage Information" && - #else - cp '$cds_key_file' .cdsapirc && - #end if + #if str($is_file.has_req).strip() == 'yes' python3 '$__tool_directory__/c3s_retrieve.py' --request '$is_file.api_req_file' --output request.txt && @@ -35,11 +37,6 @@ echo "C3S data retrieval is done" ]]> - yes - - + + - - + + @@ -65,26 +62,14 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + `_. -- Set your CDS API Key via: User -> Preferences -> Manage Information" +- Set your CDS API Key in the Credentials - Documentation on where to get the CDS API key can be found `here `_. - Compose your request directly on C3S and extract the relevant information, which should be put in the input field "Request" or saved in a file. The format should be, for example:: - import cdsapi c = cdsapi.Client() diff -r 21e8386cf36f -r d7b62d55f8dd c3s_retrieve.py --- a/c3s_retrieve.py Fri Sep 27 19:34:36 2024 +0000 +++ b/c3s_retrieve.py Mon Mar 09 14:11:43 2026 +0000 @@ -1,5 +1,6 @@ import argparse import ast +import sys from os import environ, path import cdsapi @@ -47,14 +48,28 @@ print("start retrieving data...") -cdapi_file = path.join(environ.get('HOME'), '.cdsapirc') +api_key = environ.get("CDS_API_KEY") -if path.isfile(cdapi_file): - c = cdsapi.Client() +if not api_key: + sys.stderr.write( + "CDS retrieval failed, make sure you filled in your CDS API Key\n" + ) + sys.exit(1) + +try: + c = cdsapi.Client( + url="https://cds.climate.copernicus.eu/api", + key=api_key + ) c.retrieve( c3s_type, c3s_req_dict, - c3s_output) - + c3s_output + ) print("data retrieval successful") +except Exception: + sys.stderr.write( + "CDS retrieval failed, make sure you filled in your CDS API Key\n" + ) + sys.exit(1)