credit.boundary_padding#

Classes#

Module Contents#

class credit.boundary_padding.TensorPadding(mode='earth', pad_lat=(40, 40), pad_lon=(40, 40), **kwargs)#
mode = 'earth'#
pad_NS = (40, 40)#
pad_WE = (40, 40)#
pad(x)#

Apply padding to the tensor based on the specified mode.

Parameters:

x (torch.Tensor) – Input tensor of shape (batch, var, time, lat, lon).

Returns:

The padded tensor.

Return type:

torch.Tensor

unpad(x)#

Remove padding from the tensor based on the specified mode.

Parameters:

x (torch.Tensor) – Padded tensor of shape (batch, var, time, lat, lon).

Returns:

The unpadded tensor.

Return type:

torch.Tensor

_earth_padding(x)#

Apply earth padding to the tensor (poles and circular padding).

Parameters:

x (torch.Tensor) – Input tensor.

Returns:

The padded tensor.

Return type:

torch.Tensor

_earth_unpad(x)#

Remove earth padding to restore the original tensor size.

Parameters:

x (torch.Tensor) – Padded tensor.

Returns:

The unpadded tensor.

Return type:

torch.Tensor

_mirror_padding(x)#

Apply mirror padding to the tensor.

Parameters:

x (torch.Tensor) – Input tensor.

Returns:

The padded tensor.

Return type:

torch.Tensor

_mirror_unpad(x)#

Remove mirror padding to restore the original tensor size.

Parameters:

x (torch.Tensor) – Padded tensor.

Returns:

The unpadded tensor.

Return type:

torch.Tensor