Diagnostic provider for ILAMB
This module provides a diagnostics provider for ILAMB, a tool for evaluating
climate models against observations.
ILAMBProvider
Bases: DiagnosticProvider
Provider for ILAMB diagnostics.
Source code in packages/climate-ref-ilamb/src/climate_ref_ilamb/__init__.py
| class ILAMBProvider(DiagnosticProvider):
"""Provider for ILAMB diagnostics."""
def fetch_data(self, config: Config) -> None:
"""Fetch ILAMB reference data from all registries."""
for name in _REGISTRY_NAMES:
registry = dataset_registry_manager[name]
fetch_all_files(registry, name, output_dir=None)
def validate_setup(self, config: Config) -> bool:
"""Validate that all ILAMB data is cached with correct checksums."""
all_errors: list[str] = []
for name in _REGISTRY_NAMES:
registry = dataset_registry_manager[name]
errors = validate_registry_cache(registry, name)
all_errors.extend(errors)
if all_errors:
for error in all_errors:
logger.error(f"ILAMB validation failed: {error}")
logger.error(
f"Data for {self.slug} is missing or corrupted. "
f"Please run `ref providers setup --provider {self.slug}` to fetch data."
)
return False
return True
def get_data_path(self) -> Path | None:
"""Get the path where ILAMB data is cached."""
# All ILAMB registries use the same cache
# TODO: There are more than one registry
return resolve_cache_dir("ilamb")
|
fetch_data(config)
Fetch ILAMB reference data from all registries.
Source code in packages/climate-ref-ilamb/src/climate_ref_ilamb/__init__.py
| def fetch_data(self, config: Config) -> None:
"""Fetch ILAMB reference data from all registries."""
for name in _REGISTRY_NAMES:
registry = dataset_registry_manager[name]
fetch_all_files(registry, name, output_dir=None)
|
get_data_path()
Get the path where ILAMB data is cached.
Source code in packages/climate-ref-ilamb/src/climate_ref_ilamb/__init__.py
| def get_data_path(self) -> Path | None:
"""Get the path where ILAMB data is cached."""
# All ILAMB registries use the same cache
# TODO: There are more than one registry
return resolve_cache_dir("ilamb")
|
validate_setup(config)
Validate that all ILAMB data is cached with correct checksums.
Source code in packages/climate-ref-ilamb/src/climate_ref_ilamb/__init__.py
| def validate_setup(self, config: Config) -> bool:
"""Validate that all ILAMB data is cached with correct checksums."""
all_errors: list[str] = []
for name in _REGISTRY_NAMES:
registry = dataset_registry_manager[name]
errors = validate_registry_cache(registry, name)
all_errors.extend(errors)
if all_errors:
for error in all_errors:
logger.error(f"ILAMB validation failed: {error}")
logger.error(
f"Data for {self.slug} is missing or corrupted. "
f"Please run `ref providers setup --provider {self.slug}` to fetch data."
)
return False
return True
|