credit.preblock.regrid
======================

.. py:module:: credit.preblock.regrid


Classes
-------

.. autoapisummary::

   credit.preblock.regrid.Regridder


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

.. py:class:: Regridder(weight_file, variables: list[str], data_types: list[str] = None, reshape_to_xy=True, flip_axis=None)

   Bases: :py:obj:`credit.preblock.base.BasePreblock`


   Regridding layer using weights file provided by the ESMF library.
   :param weight_file: path to weights file
   :param variables: list of variable keys to regrid (e.g. ['era5/prognostic/3d/T'])
   :param data_types: list of data types to process (default: ['input', 'target'])
   :param reshape_to_xy: whether to reshape the flattened array back to xy coordinates
   :param flip_axis: axes to flip before regridding (e.g. [-1, -2])
   :type flip_axis: list, tuple, or None


   .. py:attribute:: variables


   .. py:attribute:: data_types
      :value: ['input', 'target']



   .. py:attribute:: reshape_to_xy
      :value: True



   .. py:attribute:: flip_axis
      :value: None



   .. py:attribute:: n_a


   .. py:attribute:: n_b


   .. py:attribute:: dst_shape


   .. py:attribute:: _W
      :value: None



   .. py:attribute:: _W_device
      :value: None



   .. py:method:: _get_W(device)


   .. py:method:: _regrid(x: torch.Tensor) -> torch.Tensor


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


