diff --git a/hda/utils.py b/hda/utils.py index e247f6b..538f208 100644 --- a/hda/utils.py +++ b/hda/utils.py @@ -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. @@ -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 @@ -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:"):