credit.ocean.samudra_data#

Classes#

Functions#

extract_wet_mask(data, outputs, hist)

get_inference_steps(time_config[, time_delta, hist])

Get the number of inference/rollout steps for the given time configuration.

convert_tensor_out_to_dict(→ Dict[str, torch.Tensor])

get_norm_unnorm_dicts(data[, input_type, ...])

compute_anomalies(→ xarray.Dataset)

Compute the anomalies of a data variable.

rename_vars(→ xarray.Dataset)

Rename variables if required.

validate_data(→ Tuple[xarray.Dataset, xarray.Dataset, ...)

Validate the data such that we have the correct format for training/evaluation.

Module Contents#

credit.ocean.samudra_data.extract_wet_mask(data, outputs, hist)#
credit.ocean.samudra_data.get_inference_steps(time_config, time_delta=5, hist=1)#

Get the number of inference/rollout steps for the given time configuration.

Parameters:
  • time_config – Time configuration

  • time_delta – Time delta in days

  • hist – Number of rollout steps

Returns:

Number of rollout steps

Return type:

num_steps

credit.ocean.samudra_data.convert_tensor_out_to_dict(tensor_out: torch.Tensor) Dict[str, torch.Tensor]#
credit.ocean.samudra_data.get_norm_unnorm_dicts(data: torch.Tensor, input_type: str = 'target', prognostic_channels: int = 0, hist: int = 1)#
credit.ocean.samudra_data.compute_anomalies(data: xarray.Dataset, var: str) xarray.Dataset#

Compute the anomalies of a data variable.

credit.ocean.samudra_data.rename_vars(data: xarray.Dataset) xarray.Dataset#

Rename variables if required.

credit.ocean.samudra_data.validate_data(data: xarray.Dataset, data_mean: xarray.Dataset, data_std: xarray.Dataset) Tuple[xarray.Dataset, xarray.Dataset, xarray.Dataset]#

Validate the data such that we have the correct format for training/evaluation.

class credit.ocean.samudra_data.Normalize#
_instance: Normalize | None = None#
classmethod get_instance() Normalize#
classmethod init_instance(data_mean: xarray.Dataset, data_std: xarray.Dataset, prognostic_vars: str, boundary_vars: str, wet_mask: torch.Tensor) Normalize#

Initialize the singleton instance with normalization parameters.

_initialize(data_mean: xarray.Dataset, data_std: xarray.Dataset, prognostic_vars: str, boundary_vars: str, wet_mask: torch.Tensor) None#

Store normalization parameters and pre-compute numpy arrays.

_to_tensor(array: numpy.ndarray, device: torch.device) torch.Tensor#

Convert numpy array to tensor on specified device.

normalize_prognostics(data: xarray.Dataset, fill_nan=True, fill_value=0.0) xarray.Dataset#

Normalize input dataset.

normalize_boundary(data: xarray.Dataset, fill_nan=True, fill_value=0.0) xarray.Dataset#

Normalize boundary conditions.

unnormalize_prognostics(data: xarray.Dataset) xarray.Dataset#

Unnormalize output dataset.

normalize_tensor_prognostics(data: torch.Tensor, fill_nan=True, fill_value=0.0) torch.Tensor#

Normalize output tensor.

unnormalize_tensor_prognostics(data: torch.Tensor) torch.Tensor#

Unnormalize output tensor.

normalize_numpy_prognostics(data: numpy.ndarray, fill_nan=True, fill_value=0.0) numpy.ndarray#

Normalize output numpy array.

unnormalize_numpy_prognostics(data: numpy.ndarray) numpy.ndarray#

Unnormalize output numpy array.