"""Data catalog for predefined datasets in GEB."""

from typing import Any

from .aquastat import AQUASTAT
from .base import Adapter
from .coast_rp import CoastRP
from .cwatm_water_demand import CWATMIndustryWaterDemand, CWATMLivestockWaterDemand
from .deltadtm import DeltaDTM
from .destination_earth import DestinationEarth
from .earth_data import GlobalSoilRegolithSediment
from .ecmwf import ECMWFForecasts
from .esa_worldcover import ESAWorldCover
from .fabdem import Fabdem as Fabdem
from .fao import FAOSTAT, GMIA
from .forest_restoration import ForestRestorationPotential
from .gadm import GADM, GADM28
from .gebco import GEBCO
from .global_data_lab import GlobalDataLabShapefile
from .global_exposure_model import GlobalExposureModel
from .global_ocean_mean_dynamic_topography import (
    GlobalOceanMeanDynamicTopography as GlobalOceanMeanDynamicTopography,
)
from .global_preferences_survey import GlobalPreferencesSurvey
from .globgm import GlobGM, GlobGMDEM
from .glopop_sg import GLOPOP_SG
from .grdc import GRDC
from .gtsm import GTSM
from .hydrolakes import HydroLakes
from .isimip import ISIMIPCO2
from .lisflood import LISFLOOD
from .lowder import Lowder
from .merit_basins import MeritBasinsCatchments, MeritBasinsRivers
from .merit_hydro import MeritHydroDir, MeritHydroElv
from .merit_sword import MeritSword
from .mirca2000 import MIRCA2000
from .mirca_os import MIRCAOS
from .oecd import OECD
from .open_building_map import OpenBuildingMap
from .open_street_map import OpenStreetMap
from .osm_data import OpenStreetMapCoastlines, OpenStreetMapLandPolygons
from .soilgrids import SoilGridsV1, SoilGridsV2
from .superwell import GCAMElectricityRates
from .sword import Sword
from .undp import HumanDevelopmentIndex
from .why_map import WhyMap
from .world_bank import WorldBankData

data_catalog: dict[str, dict[str, Any]] = {
    "isimip_co2": {
        "adapter": ISIMIPCO2(),
        "url": "https://files.isimip.org",
        "source": {
            "name": "ISIMIP CO2",
            "author": "Matthias Büchner, Christopher P.O. Reyer",
            "url": "https://data.isimip.org",
            "license": "CC BY-SA 4.0",
            "paper_doi": "10.1007/s10584-011-0156-z",
        },
    },
    "era5": {
        "adapter": DestinationEarth(),
        "url": "https://data.earthdatahub.destine.eu/era5/reanalysis-era5-land-no-antartica-v0.zarr",
        "source": {
            "name": "ERA5",
            "author": "ECMWF",
        },
    },
    "ecmwf_forecasts": {
        "adapter": ECMWFForecasts(
            folder="ecmwf_forecasts",
            filename="ecmwf_{forecast_date}_{forecast_model}_{forecast_resolution}_{forecast_horizon}h_{forecast_timestep_hours}h.grb",
            local_version=1,
            cache="local",
        ),
        "url": None,
        "source": {
            "name": "ECMWF Forecasts",
            "author": "ECMWF",
            "url": "https://www.ecmwf.int/en/forecasts/access-forecasts/access-archive-datasets",
            "license": "https://www.ecmwf.int/en/forecasts/accessing-forecasts/licences-available",
        },
    },
    "soilgridsv1": {
        "adapter": SoilGridsV1(),
        "url": "https://files.isric.org/soilgrids/former/2017-03-10/data/{variable}.tif",
        "source": {
            "name": "SoilGrids V1",
            "author": "ISRIC - World Soil Information",
            "license": "CC BY 4.0",
            "url": "https://soilgrids.org",
            "version": "2017",
            "paper_doi": "10.1371/journal.pone.0169748",
        },
    },
    "soilgridsv2": {
        "adapter": SoilGridsV2(),
        "url": "https://files.isric.org/soilgrids/latest/data/{variable}/{variable}_{depth}_mean.vrt",
        "source": {
            "name": "SoilGrids V2",
            "author": "ISRIC - World Soil Information",
            "license": "CC BY 4.0",
            "url": "https://soilgrids.org",
            "version": "2020",
            "paper_doi": "10.5194/soil-2020-65",
        },
    },
    "forest_restoration_potential": {
        "adapter": ForestRestorationPotential(
            folder="forest_restoration_potential",
            local_version=1,
            filename="restoration_potential.tif",
            cache="global",
        ),
        "url": "https://www.research-collection.ethz.ch/bitstreams/77c1863d-b9b0-417e-8e49-d13079fb7825/download",
        "source": {
            "name": "Forest Restoration Potential",
            "author": "Bastin, Jean-François et al.",
            "url": "https://www.research-collection.ethz.ch/entities/researchdata/7234f0a1-e37d-4362-99e9-d0e6e75793dc",
            "license": "In Copyright - Non-Commercial Use Permitted",
            "doi": "10.3929/ethz-b-000350258",
            "year": "2019",
        },
    },
    "lisflood_crop_group_number_forest": {
        "adapter": LISFLOOD(
            folder="lisflood",
            local_version=1,
            filename="cropgrpn_f_Global_03min.nc",
            cache="global",
        ),
        "url": "https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/CEMS-GLOFAS/LISFLOOD_static_and_parameter_maps_for_GloFAS/Vegetation_properties/cropgrpn_f_Global_03min.nc",
        "source": {
            "name": "LISFLOOD Vegetation Properties - Crop Group Number (forest)",
            "author": "European Commission, Joint Research Centre (JRC)",
            "license": "CC BY 4.0",
            "url": "https://data.jrc.ec.europa.eu/dataset/f572c443-7466-4adf-87aa-c0847a169f23",
        },
    },
    "lisflood_crop_group_number_grassland_like": {
        "adapter": LISFLOOD(
            folder="lisflood",
            local_version=1,
            filename="cropgrpn_o_Global_03min.nc",
            cache="global",
        ),
        "url": "https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/CEMS-GLOFAS/LISFLOOD_static_and_parameter_maps_for_GloFAS/Vegetation_properties/cropgrpn_o_Global_03min.nc",
        "source": {
            "name": "LISFLOOD Vegetation Properties - Crop Group Number (other)",
            "author": "European Commission, Joint Research Centre (JRC)",
            "license": "CC BY 4.0",
            "url": "https://data.jrc.ec.europa.eu/dataset/f572c443-7466-4adf-87aa-c0847a169f23",
        },
    },
    "lisflood_leaf_area_index_forest": {
        "adapter": LISFLOOD(
            folder="lisflood",
            local_version=1,
            filename="laif.nc",
            cache="global",
        ),
        "url": "https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/CEMS-GLOFAS/LISFLOOD_static_and_parameter_maps_for_GloFAS/Vegetation_properties/laif.nc",
        "source": {
            "name": "LISFLOOD Vegetation Properties - Leaf Area Index (forest)",
            "author": "European Commission, Joint Research Centre (JRC)",
            "license": "CC BY 4.0",
            "url": "https://data.jrc.ec.europa.eu/dataset/f572c443-7466-4adf-87aa-c0847a169f23",
        },
    },
    "lisflood_leaf_area_index_grassland_like": {
        "adapter": LISFLOOD(
            folder="lisflood",
            local_version=1,
            filename="laio.nc",
            cache="global",
        ),
        "url": "https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/CEMS-GLOFAS/LISFLOOD_static_and_parameter_maps_for_GloFAS/Vegetation_properties/laio.nc",
        "source": {
            "name": "LISFLOOD Vegetation Properties - Leaf Area Index (other)",
            "author": "European Commission, Joint Research Centre (JRC)",
            "license": "CC BY 4.0",
            "url": "https://data.jrc.ec.europa.eu/dataset/f572c443-7466-4adf-87aa-c0847a169f23",
        },
    },
    "why_map": {
        "adapter": WhyMap(
            folder="why_map",
            local_version=1,
            filename="whymap.parquet",
            cache="global",
        ),
        "url": "https://download.bgr.de/bgr/grundwasser/whymap/shp/WHYMAP_GWR_v1.zip",
        "source": {
            "name": "WHYMAP",
            "author": "BGR (Federal Institute for Geosciences and Natural Resources)",
            "license": "CC BY-SA",
            "url": "https://www.whymap.org/whymap/EN/Maps_Data/Gwr/gwr_node_en.html",
        },
    },
    "lowder_farm_size_distribution": {
        "adapter": Lowder(
            folder="lowder_farm_size_distribution",
            local_version=1,
            filename="lowder_farm_size_distribution.xlsx",
            cache="global",
        ),
        "url": "https://ars.els-cdn.com/content/image/1-s2.0-S0305750X15002703-mmc1.xlsx",
        "source": {
            "name": "The Number, Size, and Distribution of Farms, Smallholder Farms, and Family Farms Worldwide",
            "author": "Lowder et al. (2016)",
            "paper_doi": "10.1016/j.worlddev.2015.10.041",
            "license": "CC BY-NC-ND 4.0",
            "url": "https://doi.org/10.1016/j.worlddev.2015.10.041",
        },
    },
    "gebco": {
        "adapter": GEBCO(
            folder="gebco",
            local_version=1,
            filename="gebco.zarr",
            cache="global",
        ),
        "url": "https://www.bodc.ac.uk/data/open_download/gebco/gebco_2024/geotiff/",
        "source": {
            "name": "GEBCO",
            "author": "Weatherall et al (2020)",
            "license": "https://www.gebco.net/data-products/gridded-bathymetry/terms-of-use",
            "url": "https://www.gebco.net/",
            "paper_doi": "10.5285/a29c5465-b138-234d-e053-6c86abc040b9",
        },
    },
    "aquastat": {
        "adapter": AQUASTAT(
            folder="aquastat",
            local_version=1,
            filename="aquastat.parquet",
            cache="global",
        ),
        "url": "https://storage.googleapis.com/810c63d8-3fde-4ecd-9882-14d62e3058be/static/sites/aquastat/bulk/bulk_eng(in).csv",
        "source": {
            "name": "AQUASTAT",
            "author": "FAO",
            "url": "https://data.apps.fao.org/aquastat",
            "license": "CC BY-NC- SA 3.0 IGO",
        },
    },
    "global_exposure_model": {
        "adapter": GlobalExposureModel(
            folder="global_exposure_model",
            local_version=1,
            filename="global_exposure_model_{}.csv",
            cache="global",
        ),
        "url": "https://github.com/gem/global_exposure_model",
        "source": {
            "name": "GEM Global Exposure Model",
            "author": "Global Earthquake Model (GEM) Foundation",
            "url": "https://github.com/gem/global_exposure_model",
        },
    },
    "gadm_28": {
        "adapter": GADM28(
            folder="gadm_28",
            local_version=1,
            filename="gadm_28.parquet",
            cache="global",
        ),
        "url": "https://geodata.ucdavis.edu/gadm/gadm2.8/gadm28_levels.shp.zip",
        "source": {
            "name": "GADM version 2.8",
            "author": "GADM",
            "version": "2.8",
            "license": "https://gadm.org/license.html",
        },
    },
    "mirca2000_unit_grid": {
        "adapter": MIRCA2000(
            folder="mirca2000",
            local_version=1,
            filename="unit_code.asc",
            cache="global",
            target_member_suffix="unit_code.asc.gz",
        ),
        "url": "https://zenodo.org/records/7422506/files/unit_code_grid.zip?download=1",
        "source": {
            "name": "MIRCA2000 Unit Code Grid",
            "author": "Portmann et al. (2010)",
            "version": "1.1",
            "license": "CC BY 4.0",
            "url": "https://doi.org/10.5281/zenodo.7422506",
            "paper_doi": "10.1029/2008GB003435",
        },
    },
    "mirca2000_cropping_calendar_rainfed": {
        "adapter": MIRCA2000(
            folder="mirca2000",
            local_version=1,
            filename="cropping_calendar_rainfed.txt",
            cache="global",
            target_member_suffix="cropping_calendar_rainfed.txt.gz",
        ),
        "url": "https://zenodo.org/records/7422506/files/condensed_cropping_calendars.zip?download=1",
        "source": {
            "name": "MIRCA2000 Condensed Cropping Calendars (Rainfed)",
            "author": "Portmann et al. (2010)",
            "version": "1.1",
            "license": "CC BY 4.0",
            "url": "https://doi.org/10.5281/zenodo.7422506",
            "paper_doi": "10.1029/2008GB003435",
        },
    },
    "mirca2000_cropping_calendar_irrigated": {
        "adapter": MIRCA2000(
            folder="mirca2000",
            local_version=1,
            filename="cropping_calendar_irrigated.txt",
            cache="global",
            target_member_suffix="cropping_calendar_irrigated.txt.gz",
        ),
        "url": "https://zenodo.org/records/7422506/files/condensed_cropping_calendars.zip?download=1",
        "source": {
            "name": "MIRCA2000 Condensed Cropping Calendars (Irrigated)",
            "author": "Portmann et al. (2010)",
            "version": "1.1",
            "license": "CC BY 4.0",
            "url": "https://doi.org/10.5281/zenodo.7422506",
            "paper_doi": "10.1029/2008GB003435",
        },
    },
    "GRDC": {
        "adapter": GRDC(
            folder="grdc",
            local_version=1,
            filename="GRDC.zip",
            cache="global",
        ),
        "url": "https://portal.grdc.bafg.de/applications/public.html?publicuser=PublicUser#dataDownload/Stations",
        "source": {
            "name": "Global Runoff Data Centre",
            "author": "Global Runoff Data Centre",
            "license": "https://grdc.bafg.de/downloads/policy_guidelines.pdf",
        },
    },
    "global_irrigation_area_groundwater": {
        "adapter": GMIA(
            folder="global_irrigation_area_groundwater",
            local_version=1,
            filename="global_irrigation_area_groundwater.asc",
            cache="global",
        ),
        "url": "https://firebasestorage.googleapis.com/v0/b/fao-aquastat.appspot.com/o/GIS%2Fgmia_v5_aeigw_pct_aei_asc.zip?alt=media",
        "source": {
            "name": "Global Map of Irrigation Areas",
            "author": "Siebert et al. (2010)",
            "paper_doi": "10.5194/hess-14-1863-2010",
            "license": "CC BY 4.0",
            "url": "https://www.fao.org/aquastat/en/geospatial-information/global-maps-irrigated-areas/latest-version/",
        },
    },
    "global_irrigation_area_surface_water": {
        "adapter": GMIA(
            folder="global_irrigation_area_surface_water",
            local_version=1,
            filename="global_irrigation_area_surface_water.asc",
            cache="global",
        ),
        "url": "https://firebasestorage.googleapis.com/v0/b/fao-aquastat.appspot.com/o/GIS%2Fgmia_v5_aeisw_pct_aei_asc.zip?alt=media",
        "source": {
            "name": "Global Map of Irrigation Areas",
            "author": "Siebert et al. (2010)",
            "paper_doi": "10.5194/hess-14-1863-2010",
            "license": "CC BY 4.0",
            "url": "https://www.fao.org/aquastat/en/geospatial-information/global-maps-irrigated-areas/latest-version/",
        },
    },
    "hydraulic_conductivity_globgm": {
        "adapter": GlobGM(
            folder="hydraulic_conductivity_globgm",
            local_version=1,
            filename="hydraulic_conductivity_globgm.nc",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/k_conductivity_aquifer_filled_30sec.nc",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "faostat_prices": {
        "adapter": FAOSTAT(
            folder="faostat_prices",
            local_version=1,
            filename="faostat_prices.parquet",
            cache="local",
        ),
        "url": "https://bulks-faostat.fao.org/production/Prices_E_All_Data.zip",
        "source": {
            "name": "FAOSTAT (Producer Prices)",
            "author": "FAO",
            "url": "https://www.fao.org/faostat/en/#data/PP",
            "license": "CC BY 4.0",
        },
    },
    "gcam_electricity_rates": {
        "adapter": GCAMElectricityRates(
            folder="gcam/electricity_rates",
            local_version=1,
            filename="GCAM_Electricity_Rates.csv",
            cache="global",
        ),
        "url": "https://raw.githubusercontent.com/JGCRI/superwell/main/inputs/GCAM_Electricity_Rates.csv",
        "source": {
            "name": "GCAM Electricity Rates",
            "author": "JGCRI",
            "url": "https://github.com/JGCRI/superwell",
            "license": "MIT",
        },
    },
    "specific_yield_aquifer_globgm": {
        "adapter": GlobGM(
            folder="specific_yield_aquifer_globgm",
            local_version=1,
            filename="specific_yield_aquifer_globgm.nc",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/specific_yield_aquifer_filled_30sec.nc",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "water_table_depth_globgm": {
        "adapter": GlobGM(
            folder="water_table_depth_globgm",
            local_version=1,
            filename="water_table_depth_globgm.tif",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/output/version_1.0/steady-state/globgm-wtd-ss.tif",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/output/version_1.0/steady-state/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "head_lower_layer_globgm": {
        "adapter": GlobGM(
            folder="head_lower_layer_globgm",
            local_version=1,
            filename="head_lower_layer_globgm.tif",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/output/version_1.0/steady-state/globgm-heads-lower-layer-ss.tif",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/output/version_1.0/steady-state/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "head_upper_layer_globgm": {
        "adapter": GlobGM(
            folder="head_upper_layer_globgm",
            local_version=1,
            filename="head_upper_layer_globgm.tif",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/output/version_1.0/steady-state/globgm-heads-upper-layer-ss.tif",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/output/version_1.0/steady-state/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "recession_coefficient_globgm": {
        "adapter": GlobGM(
            folder="recession_coefficient_globgm",
            local_version=1,
            filename="recession_coefficient_globgm.nc",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/recession_coefficient_30sec.nc",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "thickness_confining_layer_globgm": {
        "adapter": GlobGM(
            folder="thickness_confining_layer_globgm",
            local_version=1,
            filename="thickness_confining_layer_globgm.nc",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/confining_layer_thickness_version_2016_remapbil_to_30sec.nc",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "total_groundwater_thickness_globgm": {
        "adapter": GlobGM(
            folder="total_groundwater_thickness_globgm",
            local_version=1,
            filename="total_groundwater_thickness_globgm.nc",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/thickness_05min_remapbil_to_30sec_filled_with_pcr_correct_lat.nc",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "dem_globgm": {
        "adapter": GlobGMDEM(
            folder="dem_globgm",
            local_version=1,
            filename="dem_globgm.nc",
            cache="global",
        ),
        "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/topography_parameters_30sec_february_2021_global_covered_with_zero.nc",
        "source": {
            "url": "https://geo.public.data.uu.nl/vault-globgm/research-globgm%5B1669042611%5D/original/input/version_1.0/",
            "author": "Verkaik et al. (2024)",
            "paper_doi": "10.5194/gmd-17-275-2024",
            "license": "CC BY 4.0",
        },
    },
    "GDL_regions_v4": {
        "adapter": GlobalDataLabShapefile(
            folder="global_data_lab",
            local_version=1,
            filename="gdl_regions_v4.parquet",
            cache="global",
        ),
        "url": "https://globaldatalab.org/mygdl/downloads/shapefiles/",
        "source": {
            "name": "Global Data Lab",
            "author": "Radboud University",
            "license": "https://globaldatalab.org/termsofuse/",
            "url": "https://globaldatalab.org/mygdl/downloads/shapefiles/",
        },
    },
    "global_preferences_survey_country": {
        "adapter": GlobalPreferencesSurvey(
            zip_filename="GPS_dataset_country_level.zip",
            zip_member_path="country.dta",
            folder="global_preferences_survey_country",
            local_version=1,
            filename="country.csv",
            cache="global",
        ),
        "url": "https://gps.econ.uni-bonn.de/downloads#dataset",
        "source": {
            "name": "Global Preferences Survey - Country Level",
            "author": "Falk et al. (2018)",
            "paper_doi": "10.1093/qje/qjy013",
            "license": "CCC BY-NC-SA 4.0",
            "url": "https://gps.econ.uni-bonn.de/downloads#dataset",
        },
    },
    "global_preferences_survey_individual": {
        "adapter": GlobalPreferencesSurvey(
            zip_filename="GPS_dataset_individual_level.zip",
            zip_member_path="individual_new.dta",
            folder="global_preferences_survey_individual",
            local_version=1,
            filename="individual_new.csv",
            cache="global",
        ),
        "url": "https://gps.econ.uni-bonn.de/downloads#dataset",
        "source": {
            "name": "Global Preferences Survey - Individual Level",
            "author": "Falk et al. (2018)",
            "paper_doi": "10.1093/qje/qjy013",
            "license": "CC BY-NC-SA 4.0",
            "url": "https://gps.econ.uni-bonn.de/downloads#dataset",
        },
    },
    "wb_inflation_rate": {
        "adapter": WorldBankData(
            folder="world_bank_inflation_rate",
            local_version=1,
            filename="wb_inflation_rate.csv",
            cache="global",
        ),
        "url": "https://api.worldbank.org/v2/en/indicator/FP.CPI.TOTL.ZG?downloadformat=csv",
        "source": {
            "name": "World Bank Inflation Data",
            "author": "The World Bank",
            "license": "CC BY 4.0",
        },
    },
    "world_bank_price_ratio": {
        "adapter": WorldBankData(
            folder="world_bank_price_ratio",
            local_version=1,
            filename="world_bank_price_ratio.csv",
            cache="global",
        ),
        "url": "https://api.worldbank.org/v2/en/indicator/PA.NUS.PPPC.RF?downloadformat=csv",
        "source": {
            "name": "Official exchange rate (LCU per US$, period average)",
            "author": "The World Bank",
            "license": "CC BY 4.0",
            "url": "https://data.worldbank.org/indicator/PA.NUS.PPPC.RF",
        },
    },
    "world_bank_LCU_per_USD": {
        "adapter": WorldBankData(
            folder="world_bank_LCU_per_USD",
            local_version=1,
            filename="world_bank_LCU_per_USD.csv",
            cache="global",
        ),
        "url": "https://api.worldbank.org/v2/en/indicator/PA.NUS.FCRF?downloadformat=csv",
        "source": {
            "name": "World Bank Local Currency Unit per US Dollar Data",
            "author": "The World Bank",
            "license": "CC BY 4.0",
            "url": "https://data.worldbank.org/indicator/PA.NUS.FCRF",
        },
    },
    "un_hdi": {
        "adapter": HumanDevelopmentIndex(
            folder="un_hdi",
            local_version=1,
            filename="un_hdi.csv",
            cache="global",
        ),
        "url": "https://ourworldindata.org/grapher/human-development-index.csv?v=1&csvType=full&useColumnShortNames=true",
        "source": {
            "name": "Human Development Index",
            "author": "UNDP / Our World In Data",
            "license": "CC BY 3.0 IGO",
            "url": "https://ourworldindata.org/grapher/human-development-index",
            "original_source_url": "https://hdr.undp.org",
        },
    },
    "oecd_idd": {
        "adapter": OECD(
            folder="oecd_idd",
            local_version=1,
            filename="oecd_idd.csv",
            cache="global",
        ),
        "url": "https://sdmx.oecd.org/public/rest/data/OECD.WISE.INE,DSD_WISE_IDD@DF_IDD,1.0/.A.INC_DISP.MEDIAN+MEAN.XDC_HH_EQ._T.METH2012.D_CUR.?startPeriod=2010&dimensionAtObservation=AllDimensions&format=csvfilewithlabels",
        "source": {
            "name": "OECD Income Distribution Database",
            "author": "OECD",
            "license": "CC BY 4.0",
            "url": "https://data-explorer.oecd.org/vis?fs[0]=Topic%2C1%7CSociety%23SOC%23%7CInequality%23SOC_INE%23&pg=0&fc=Topic&bp=true&snb=2&df[ds]=dsDisseminateFinalDMZ&df[id]=DSD_WISE_IDD%40DF_IDD&df[ag]=OECD.WISE.INE&df[vs]=1.0&pd=2010%2C&dq=.A.INC_DISP.MEDIAN%2BMEAN.XDC_HH_EQ._T.METH2012.D_CUR.&to[TIME_PERIOD]=false&vw=ov",
        },
    },
    "coast_rp": {
        "adapter": CoastRP(
            folder="coast_rp",
            local_version=1,
            filename="COAST-RP.pkl",
            cache="global",
        ),
        "url": "https://raw.githubusercontent.com/jobdullaart/HGRAPHER/refs/tags/v0.1/COAST-RP.pkl",
        "source": {
            "name": "COAST-RP",
            "author": "Dullaart et al. (2023)",
            "license": "Other (Open)",
            "url": "https://zenodo.org/records/7912730",
        },
    },
    "esa_worldcover_2021": {
        "adapter": ESAWorldCover(),
        "url": "https://services.terrascope.be/stac/collections/urn:eop:VITO:ESA_WorldCover_10m_2021_AWS_V2",
        "source": {
            "name": "ESA WorldCover",
            "author": "European Space Agency (ESA)",
            "version": "v200",
            "license": "CC BY 4.0",
        },
    },
    "hydrolakes": {
        "adapter": HydroLakes(
            folder="hydrolakes",
            local_version=1,
            filename="hydrolakes.parquet",
            cache="global",
        ),
        "url": "https://data.hydrosheds.org/file/hydrolakes/HydroLAKES_polys_v10.gdb.zip",
        "source": {
            "name": "HydroLAKES",
            "author": "Arjen Haag",
            "version": "v10.0",
            "license": "CC BY 4.0",
        },
    },
    "GADM_level0": {
        "adapter": GADM(
            level=0,
            folder="gadm_level0",
            local_version=1,
            filename="gadm_level0.parquet",
            cache="global",
        ),
        "url": "https://geodata.ucdavis.edu/gadm/gadm4.1/gadm_410-levels.zip",
        "source": {
            "name": "GADM",
            "author": "GADM",
            "version": "4.1",
            "license": "https://gadm.org/license.html",
        },
    },
    "GADM_level1": {
        "adapter": GADM(
            level=1,
            folder="gadm_level1",
            local_version=1,
            filename="gadm_level1.parquet",
            cache="global",
        ),
        "url": "https://geodata.ucdavis.edu/gadm/gadm4.1/gadm_410-levels.zip",
        "source": {
            "name": "GADM",
            "author": "GADM",
            "version": "4.1",
            "license": "https://gadm.org/license.html",
        },
    },
    "GlobalSoilRegolithSediment": {
        "adapter": GlobalSoilRegolithSediment(
            folder="global_soil_regolith_sediment",
            local_version=1,
            filename="global_soil_regolith_sediment.zarr",
            cache="global",
        ),
        "url": "https://cmr.earthdata.nasa.gov/search/concepts/C2216864025-ORNL_CLOUD.html",
        "source": {
            "name": "Global 1-km Gridded Thickness of Soil, Regolith, and Sedimentary Deposit Layers",
            "author": "Pelletier et al. (2015)",
            "version": "1",
            "license": "CC0",
            "url": "https://doi.org/10.5194/essd-13-4389-2021",
            "paper_doi": "10.1002/2015MS000526",
        },
    },
    "merit_basins_catchments": {
        "adapter": MeritBasinsCatchments(
            folder="merit_basins_catchments",
            local_version=1,
            filename="merit_basins_catchments.parquet",
            cache="global",
        ),
        "url": "https://drive.google.com/uc?export=download&id={FILE_ID}",
        "source": {
            "name": "MERIT Basins",
            "author": "Lin et al.",
            "version": "v0.7",
            "license": "CC BY-NC-SA 4.0",
        },
    },
    "merit_hydro_dir": {
        "adapter": MeritHydroDir(
            folder="merit_hydro_dir",
            local_version=1,
            filename="tiles",
            cache="global",
        ),
        "url": "https://hydro.iis.u-tokyo.ac.jp/~yamadai/MERIT_Hydro/distribute/v1.0",
        "source": {
            "name": "MERIT Hydro",
            "author": "Yamazaki et al.",
            "version": "2019",
            "license": "CC BY 4.0 or ODbL 1.0",
        },
    },
    "merit_hydro_elv": {
        "adapter": MeritHydroElv(
            folder="merit_hydro_elv",
            local_version=1,
            filename="tiles",
            cache="global",
        ),
        "url": "https://hydro.iis.u-tokyo.ac.jp/~yamadai/MERIT_Hydro/distribute/v1.0",
        "source": {
            "name": "MERIT Hydro",
            "author": "Yamazaki et al.",
            "version": "2019",
            "license": "CC BY 4.0 or ODbL 1.0",
        },
    },
    "delta_dtm": {
        "adapter": DeltaDTM(
            folder="delta_dtm",
            local_version=1,
            filename="{}.zip",
            cache="global",
        ),
        "url": "https://data.4tu.nl/datasets/1da2e70f-6c4d-4b03-86bd-b53e789cc629",
        "source": {
            "name": "Delta DTM",
            "author": "Pronk et al. (2024)",
            "version": "1-1",
            "license": "CC BY-NC-SA 4.0",
            "url": "https://data.4tu.nl/datasets/1da2e70f-6c4d-4b03-86bd-b53e789cc629",
            "paper_doi": "https://doi.org/10.1038/s41597-024-03091-9",
        },
    },
    "fabdem": {
        "adapter": Fabdem(
            folder="fabdem",
            local_version=2,
            filename="fabdem.zarr",
            cache="local",
        ),
        "url": "https://data.bris.ac.uk/datasets/s5hqmjcdj8yo2ibzi9b4ew3sn",
        "source": {
            "name": "FABDEM",
            "author": "Hawker et al. (2022)",
            "version": "1-2",
            "license": "CC BY-NC-SA 4.0",
            "url": "https://data.bris.ac.uk/data/dataset/25wfy0f9ukoge2gs7a5mqpq2j7",
            "paper_doi": "10.1088/1748-9326/ac4d4f",
        },
    },
    "global_ocean_mean_dynamic_topography": {
        "adapter": GlobalOceanMeanDynamicTopography(
            folder="global_ocean_mean_dynamic_topography",
            local_version=1,
            filename="global_ocean_mean_dynamic_topography.nc",
            cache="global",
        ),
        "url": "https://cmr.earthdata.nasa.gov/search/concepts/C2216864025-ORNL_CLOUD.html",
        "source": {
            "name": "Global Ocean Mean Dynamic Topography",
            "author": "Copernicus Marine Service",
            "version": "1",
            "license": "CC0",
            "url": "https://data.marine.copernicus.eu/product/SEALEVEL_GLO_PHY_MDT_008_063/description",
            "paper_doi": "https://doi.org/10.48670/moi-00150",
        },
    },
    "gtsm": {
        "adapter": GTSM(
            folder="gtsm",
            local_version=1,
            filename="gtsm_mean_sea_level.zip",
            cache="local",
        ),
        "url": "https://cds.climate.copernicus.eu/datasets/sis-water-level-change-timeseries-cmip6?tab=download",
        "source": {
            "name": "Global Tide and Storm Surge Model (GTSM)",
            "author": "Muis et al. (2022)",
            "license": "CC BY 4.0",
            "url": "https://doi.org/10.24381/cds.a6d42d60",
            "paper_doi": "10.5281/zenodo.8314503",
        },
    },
    "merit_basins_rivers": {
        "adapter": MeritBasinsRivers(
            folder="merit_basins_rivers",
            local_version=1,
            filename="merit_basins_rivers.parquet",
            cache="global",
        ),
        "url": "https://drive.google.com/uc?export=download&id={FILE_ID}",
        "source": {
            "name": "MERIT Basins",
            "author": "Lin et al.",
            "version": "v0.7",
            "license": "CC BY-NC-SA 4.0",
        },
    },
    "merit_sword": {
        "adapter": MeritSword(
            folder="merit_sword",
            local_version=1,
            filename="merit_sword.zarr",
            cache="global",
        ),
        "url": "https://zenodo.org/records/14675925/files/ms_translate.zip",
        "source": {
            "name": "MERIT-SWORD",
            "version": "v0.4",
            "license": "CC BY-NC-SA 4.0",
            "url": "doi.org/10.5281/zenodo.14675925",
        },
    },
    "sword": {
        "adapter": Sword(
            folder="sword",
            local_version=1,
            filename="sword.gpkg",
            cache="global",
        ),
        "url": "https://zenodo.org/records/10013982/files/SWORD_v16_gpkg.zip",
        "source": {
            "name": "SWORD",
            "version": "v16",
            "license": "CC BY 4.0",
            "url": "doi.org/10.5281/zenodo.14727521",
        },
    },
    "open_building_map": {
        "adapter": OpenBuildingMap(
            folder="open_building_map",
            local_version=2,
            filename="open_building_map.parquet",
            cache="local",
        ),
        "url": "https://datapub.gfz.de/download/10.5880.GFZ.LKUT.2025.002-Caweb/2025-002_Oostwegel-et-al_data/",
        "source": {
            "name": "OpenBuildingMap",
            "author": "Oostwegel et al. (2025)",
            "version": "1",
            "license": "CC BY-NC-SA 4.0",
            "url": "https://dataservices.gfz-potsdam.de/panmetaworks/showshort.php?id=45829b80-e892-11ef-914a-f12b0080820d",
            "paper_doi": "https://doi.org/10.5880/GFZ.LKUT.2025.002",
        },
    },
    "open_street_map": {
        "adapter": OpenStreetMap(),
        "url": "https://osm.download.movisda.io",
        "source": {
            "name": "OpenStreetMap",
            "author": "OpenStreetMap contributors",
            "license": "ODbL 1.0",
            "url": "https://www.openstreetmap.org/copyright",
        },
    },
    "open_street_map_coastlines": {
        "adapter": OpenStreetMapCoastlines(
            folder="open_street_map_coastlines",
            local_version=1,
            filename="open_street_map_coastlines.zip",
            cache="global",
        ),
        "url": "https://osmdata.openstreetmap.de/download/coastlines-split-4326.zip",
        "source": {
            "name": "OpenStreetMap Coastlines",
            "author": "OpenStreetMap contributors",
            "license": "ODbL 1.0",
            "url": "https://www.openstreetmap.org/copyright",
        },
    },
    "open_street_map_land_polygons": {
        "adapter": OpenStreetMapLandPolygons(
            folder="open_street_map_land_polygons",
            local_version=1,
            filename="open_street_map_land_polygons.zip",
            cache="global",
        ),
        "url": "https://osmdata.openstreetmap.de/download/land-polygons-split-4326.zip",
        "source": {
            "name": "OpenStreetMap Land Polygons",
            "author": "OpenStreetMap contributors",
            "license": "ODbL 1.0",
            "url": "https://www.openstreetmap.org/copyright",
        },
    },
    "glopop-sg": {
        "adapter": GLOPOP_SG(
            folder="glopop_sg",
            local_version=3,  # this is the third version of the dataset on Zenodo
            filename="placeholder",
            cache="local",
        ),
        "url": "https://zenodo.org/records/17076088/files/GLOPOP-SG(update).zip?download=1",
        "source": {
            "name": "GLOPOP-SG",
            "author": "M.J. Ton et al. (2025)",
            "license": "CC BY 4.0",
            "url": "https://doi.org/10.5281/zenodo.17076088",
            "paper_doi": "10.5281/zenodo.17076088",
        },
    },
    **{
        f"cwatm_industry_water_demand_{scenario}_year": {
            "adapter": CWATMIndustryWaterDemand(
                folder="cwatm_water_demand",
                filename=f"{scenario}_ind_year_millionm3_5min.nc",
                local_version=1,
                cache="global",
            ),
            "url": None,
            "source": {
                "name": f"CWATM Industry Water Demand {scenario}",
                "author": "Burek et al. (2016)",
                "license": "CC BY 3.0",
                "url": "https://doi.org/10.5194/gmd-9-175-2016",
            },
        }
        for scenario in ["historical", "ssp1", "ssp2", "ssp3", "ssp5"]
    },
    **{
        f"cwatm_livestock_water_demand_{scenario}_year": {
            "adapter": CWATMLivestockWaterDemand(
                folder="cwatm_water_demand",
                filename=f"{scenario}_liv_year_millionm3_5min.nc",
                local_version=1,
                cache="global",
            ),
            "url": None,
            "source": {
                "name": f"CWATM Livestock Water Demand {scenario}",
                "author": "Burek et al. (2016)",
                "license": "CC BY 3.0",
                "url": "https://doi.org/10.5194/gmd-9-175-2016",
            },
        }
        for scenario in ["historical", "ssp1", "ssp2", "ssp3", "ssp5"]
    },
    **{
        f"mirca_os_cropping_area_{year}_{resolution}_{crop}_{irrigation}": {
            "adapter": MIRCAOS(
                folder="mirca_os",
                filename=f"Annual Harvested Area Grids/{year}/{resolution}/MIRCA-OS_{crop}_{year}_{irrigation}.tif",
                local_version=1,
                cache="global",
            ),
            "url": "https://www.hydroshare.org/resource/60a890eb841c460192c03bb590687145/data/contents/Annual%20Harvested%20Area%20Grids/Annual_Harvested_Area_Grids.rar",
            "source": {
                "name": "MIRCA-OS",
                "author": "Kebede et al. (2024)",
                "license": "CC BY 4.0",
                "url": "https://doi.org/10.4211/hs.60a890eb841c460192c03bb590687145",
            },
        }
        for year in ["2000", "2005", "2010", "2015"]
        for resolution in ["5-arcminute", "30-arcminute"]
        for crop in [
            "Wheat",
            "Maize",
            "Rice",
            "Barley",
            "Rye",
            "Millet",
            "Sorghum",
            "Soybeans",
            "Sunflower",
            "Potatoes",
            "Cassava",
            "Sugar_cane",
            "Sugar_beet",
            "Oil_palm",
            "Rapeseed",
            "Groundnuts",
            "Others_perennial",
            "Fodder",
            "Others_annual",
            "Cocoa",
            "Coffee",
            "Cotton",
            "Pulses",
        ]
        for irrigation in ["ir", "rf"]
    },
}


class NewDataCatalog:
    """The GEB data catalog for accessing predefined datasets."""

    def __init__(self) -> None:
        """Initialize the data catalog with predefined entries."""
        self.catalog = data_catalog

    def fetch(self, name: str, *args: Any, **kwargs: Any) -> Adapter:
        """Get a data catalog entry by name.

        Args:
            name: The name of the data entry to retrieve.
            *args: Additional positional arguments to pass to the fetcher.
            **kwargs: Additional keyword arguments to pass to the fetcher.

        Returns:
            The data catalog entry as a dictionary.
        """
        return self.catalog[name]["adapter"].fetch(
            url=self.catalog[name]["url"],
            *args,
            **kwargs,
        )

    def size(self, name: str | None = None, format: str | None = "GB") -> int | str:
        """Calculate the total size on disk for specified data entries.

        Args:
            name: Name of the data entry to check. If None, calculates for all entries.
            format: Optional unit to format the size ('KB', 'MB', 'GB', 'TB'). If None, returns size in bytes as int.

        Returns:
            Total size in bytes as int if format is None, otherwise a formatted string with the specified unit.

        Raises:
            ValueError: If format is not one of 'KB', 'MB', 'GB', 'TB'.
        """
        if name is None:
            names: list[str] = list(self.catalog.keys())
        else:
            names: list[str] = [name]

        total_size: int = 0
        for name in names:
            adapter = self.catalog[name]["adapter"]
            if adapter.cache is not None and adapter.path.exists():
                total_size += adapter.path.stat().st_size

        if format is None:
            return total_size

        # Validate format
        valid_formats = {"KB": 1024, "MB": 1024**2, "GB": 1024**3, "TB": 1024**4}
        if format not in valid_formats:
            raise ValueError(
                f"Invalid format '{format}'. Must be one of {list(valid_formats.keys())}."
            )

        # Convert and format
        divisor = valid_formats[format]
        formatted_size = total_size / divisor
        return f"{formatted_size:.2f} {format}"

    def print_licenses(self, name: str | None = None) -> None:
        """Print the licence information for specified data entries.

        Args:
            name: Name of the data entry to check. If None, prints for all entries.
        """
        if name is None:
            names: list[str] = list(self.catalog.keys())
        else:
            names: list[str] = [name]

        # Collect license data for table formatting
        license_data = []
        for name in names:
            source = self.catalog[name].get("source", {})
            name = source.get("name", name)
            license_info = source.get("license", "N/A")
            license_data.append((name, license_info))

        # Print table header
        print(f"{'Name':<50} {'License'}")
        print("-" * 80)

        # Print each row
        for name, license_info in license_data:
            print(f"{name:<50} {license_info}")

    def fetch_global(self) -> None:
        """Fetch all data entries with global cache setting."""
        for name, entry in self.catalog.items():
            adapter = entry["adapter"]
            if adapter.cache == "global":
                if not adapter.is_ready:
                    print(f"Fetching {name}...")
                    adapter.fetch(url=entry["url"])
                    print(f"Fetched {name} to {adapter.path}")

        print("All global data fetched, catalog size:", self.size(format="GB"))
