credit.transforms#

Factory and lazy-import registry for CREDIT transform classes.

Callers that only need the factory:

from credit.transforms import load_transforms
transform = load_transforms(conf)

Callers that import a class directly (backward-compatible):

from credit.transforms import Normalize_ERA5_and_Forcing

Modules are imported on first use so optional heavy dependencies (numba, BridgeScaler, …) are never loaded unless that transform type is actually requested. Add a new entry to _TRANSFORM_REGISTRY to register a new scaler type without touching load_transforms itself.

Submodules#

Attributes#

Functions#

__getattr__(name)

Lazily resolve package-level names listed in _LAZY_EXPORTS.

load_transforms(conf[, scaler_only])

Load and compose transform objects from a CREDIT config.

Package Contents#

credit.transforms.logger#
credit.transforms._TRANSFORM_REGISTRY: dict[str, dict[str, Any]]#
credit.transforms._LAZY_EXPORTS: dict[str, tuple[str, str]]#
credit.transforms.__getattr__(name: str)#

Lazily resolve package-level names listed in _LAZY_EXPORTS.

credit.transforms.load_transforms(conf: dict, scaler_only: bool = False)#

Load and compose transform objects from a CREDIT config.

Parameters:
  • conf – Full training/inference config dict. Reads conf["data"]["scaler_type"] to select the transform pair.

  • scaler_only – When True, return only the normalisation/scaler instance without the ToTensor step. Used by postblocks that apply the inverse transform at inference time.

Returns:

a single scaler instance (or None for std_cached). Otherwise a torchvision.transforms.Compose of [scaler, to_tensor] (scaler omitted when it is None).

Return type:

When scaler_only=True

Raises:

ValueError – If scaler_type is not registered in _TRANSFORM_REGISTRY.