Skip to content

Commit

Permalink
Merge pull request ecmwf#25 from GermanoGuerrini/master
Browse files Browse the repository at this point in the history
Improved payloads conversion
  • Loading branch information
ricardo-correa authored Apr 23, 2024
2 parents 939e42b + 1da6331 commit e64c51d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
copyright = "2023, ECMWF"
author = "ECMWF"

release = "2.13"
version = "2.13"
release = "2.14"
version = "2.14"

# -- General configuration

Expand Down
5 changes: 1 addition & 4 deletions hda/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,7 @@ def __init__(
verify=True,
path=None,
):
credentials = {
"user": None,
"password": None
}
credentials = {"user": None, "password": None}

dotrc = path or os.environ.get("HDA_RC", os.path.expanduser("~/.hdarc"))

Expand Down
38 changes: 37 additions & 1 deletion hda/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

logger = logging.getLogger(__name__)

DATASET_MAPPING = {
"EO:CLMS:DAT:CGLS_DAILY10_LST_DC_GLOBAL_V1": "EO:CLMS:DAT:CLMS_GLOBAL_LST_5KM_V1_10DAILY-DAILY-CYCLE_NETCDF",
"EO:CLMS:DAT:CGLS_DAILY10_LST_DC_GLOBAL_V2": "EO:CLMS:DAT:CLMS_GLOBAL_LST_5KM_V2_10DAILY-DAILY-CYCLE_NETCDF",
"EO:CLMS:DAT:CGLS_DAILY10_LST_TCI_GLOBAL_V1": "EO:CLMS:DAT:CLMS_GLOBAL_LST_5KM_V1_10DAILY-TCI_NETCDF",
"EO:CLMS:DAT:CGLS_DAILY10_LST_TCI_GLOBAL_V2": "EO:CLMS:DAT:CLMS_GLOBAL_LST_5KM_V2_10DAILY-TCI_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_ALBH_V1_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_ALBH_1KM_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_ALDH_V1_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_ALDH_1KM_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_DMP300_V1_333M": "EO:CLMS:DAT:CLMS_GLOBAL_DMP_300M_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_DMP_V2_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_DMP_1KM_V2_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_FAPAR300_V1_333M": "EO:CLMS:DAT:CLMS_GLOBAL_FAPAR_300M_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_FAPAR_V1_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_FAPAR_1KM_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_FAPAR_V2_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_FAPAR_1KM_V2_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_FCOVER300_V1_333M": "EO:CLMS:DAT:CLMS_GLOBAL_FCOVER_300M_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_FCOVER_V1_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_FCOVER_1KM_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_FCOVER_V2_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_FCOVER_1KM_V2_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_GDMP300_V1_333M": "EO:CLMS:DAT:CLMS_GLOBAL_GDMP_300M_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_GDMP_V2_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_GDMP_1KM_V2_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_LAI300_V1_333M": "EO:CLMS:DAT:CLMS_GLOBAL_LAI_300M_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_LAI_V1_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_LAI_1KM_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_LAI_V2_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_LAI_1KM_V2_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_NDVI300_V1_333M": "EO:CLMS:DAT:CLMS_GLOBAL_NDVI_300M_V1_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_NDVI300_V2_333M": "EO:CLMS:DAT:CLMS_GLOBAL_NDVI_300M_V2_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_NDVI_V2_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_NDVI_1KM_V2_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_NDVI_V3_1KM": "EO:CLMS:DAT:CLMS_GLOBAL_NDVI_1KM_V3_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_GLOBAL_SWI10_V3_0.1DEGREE": "EO:CLMS:DAT:CLMS_GLOBAL_SWI_12.5KM_V3_10DAILY_NETCDF",
"EO:CLMS:DAT:CGLS_HOURLY_LST_GLOBAL_V1": "EO:CLMS:DAT:CLMS_GLOBAL_LST_5KM_V1_HOURLY_NETCDF",
"EO:CLMS:DAT:CGLS_HOURLY_LST_GLOBAL_V2": "EO:CLMS:DAT:CLMS_GLOBAL_LST_5KM_V2_HOURLY_NETCDF",
"EO:EEA:DAT:VEGETATION_DAILY_SWI_12.5KM_GLOBAL_V3": "EO:CLMS:DAT:CLMS_GLOBAL_SWI_12.5KM_V3_DAILY_NETCDF",
"EO:EEA:DAT:VEGETATION:DAILY_SWI_1KM_EUROPE_V1": "EO:CLMS:DAT:CLMS_GLOBAL_SWI_1KM_V1_DAILY_NETCDF",
"EO:EEA:DAT:ENERGY_TOCR_1KM_GLOBAL_V1": "EO:CLMS:DAT:CLMS_GLOBAL_TOCR_1KM_V1_10DAILY_NETCDF",
"EO:EEA:DAT:VEGETATION:DAILY_SWI_12.5KM_GLOBAL_V3": "EO:CLMS:DAT:CLMS_GLOBAL_SSM_1KM_V1_DAILY_NETCDF",
"EO:ESA:DAT:SENTINEL-1:SAR": "EO:ESA:DAT:SENTINEL-1",
"EO:ESA:DAT:SENTINEL-2:MSI": "EO:ESA:DAT:SENTINEL-2",
}


def convert(query):
"""Converts a query in HDA v1 format into an HDA v2 one.
Expand All @@ -19,6 +54,7 @@ def convert(query):
)

# Modify the JSON query according to the new structure
dataset_id = DATASET_MAPPING.get(dataset_id, dataset_id)
new_query = {"dataset_id": dataset_id}

# Check if the original JSON has the "dateRangeSelectValues" field
Expand All @@ -32,7 +68,7 @@ def convert(query):
if dataset_id.startswith("EO:ECMWF:DAT:CAMS_"):
new_query["dtstart"] = start
new_query["dtend"] = end
elif dataset_id.startswith("EO:CLMS:DAT:CGLS"):
elif dataset_id.startswith("EO:CLMS:DAT:"):
new_query["start"] = start
new_query["end"] = end
elif dataset_id.startswith("EO:MO:DAT:"):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def read(fname):
return io.open(file_path, encoding="utf-8").read()


version = "2.13"
version = "2.14"

setuptools.setup(
name="hda",
Expand Down

0 comments on commit e64c51d

Please sign in to comment.