credit.postblock.scaler
=======================

.. py:module:: credit.postblock.scaler


Classes
-------

.. autoapisummary::

   credit.postblock.scaler.BridgeScalerTransformer


Module Contents
---------------

.. py:class:: BridgeScalerTransformer(scaler_path: str, variables: list[str], method: str, key: str = 'y_processed')

   Bases: :py:obj:`credit.postblock.base.BasePostblock`


   Scaling postblock using a fitted bridgescaler dict.

   Applies per-variable scaling (or its inverse) to the nested prediction dict
   at ``batch_dict[key]``, which has the form
   ``batch_dict[key][source][var_key]`` where ``var_key`` is
   ``"source/field_type/dim/varname"`` (e.g. ``"era5/prognostic/3d/T"``).

   Defaults to operating on ``"y_processed"`` — the nested dict written by
   ``Reconstruct``. Use ``method="inverse_transform"`` to convert normalized
   predictions back to physical units before physics fixers.

   The scaler dict must have been fit with ``bridgescaler.scale_var_dict``
   using the same nested structure and saved with ``bridgescaler.save_scaler_dict``.

   Example config::

       type: "bridgescaler_transform"
       args:
           scaler_path: "/path/to/scaler.json"
           variables:
               - "era5/prognostic/3d/T"
               - "era5/prognostic/3d/U"
           method: "inverse_transform"


   .. py:attribute:: variables


   .. py:attribute:: method


   .. py:attribute:: scaler_path


   .. py:attribute:: key
      :value: 'y_processed'



   .. py:attribute:: scaler


   .. py:method:: forward(batch_dict: dict) -> dict


