credit.transforms
=================

.. py:module:: credit.transforms

.. autoapi-nested-parse::

   transforms/__init__.py
   ----------------------
   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
----------

.. toctree::
   :maxdepth: 1

   /autoapi/credit/transforms/transforms_global/index
   /autoapi/credit/transforms/transforms_les/index
   /autoapi/credit/transforms/transforms_quantile/index
   /autoapi/credit/transforms/transforms_wrf/index


Attributes
----------

.. autoapisummary::

   credit.transforms.logger
   credit.transforms._TRANSFORM_REGISTRY
   credit.transforms._LAZY_EXPORTS


Functions
---------

.. autoapisummary::

   credit.transforms.__getattr__
   credit.transforms.load_transforms


Package Contents
----------------

.. py:data:: logger

.. py:data:: _TRANSFORM_REGISTRY
   :type:  dict[str, dict[str, Any]]

.. py:data:: _LAZY_EXPORTS
   :type:  dict[str, tuple[str, str]]

.. py:function:: __getattr__(name: str)

   Lazily resolve package-level names listed in ``_LAZY_EXPORTS``.


.. py:function:: load_transforms(conf: dict, scaler_only: bool = False)

   Load and compose transform objects from a CREDIT config.

   :param conf: Full training/inference config dict.  Reads
                ``conf["data"]["scaler_type"]`` to select the transform pair.
   :param 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).
   :rtype: When ``scaler_only=True``

   :raises ValueError: If ``scaler_type`` is not registered in
       ``_TRANSFORM_REGISTRY``.


