NVIDIA Modulus Core v0.1.0
Core v0.1.0

Modulus Metrics

modulus.metrics.climate.acc.acc(pred: Tensor, target: Tensor, climatology: Tensor, lat: Tensor) → Tensor[source]

Calculates the Anomaly Correlation Coefficient

Parameters
  • pred (Tensor) – […, H, W] Predicted tensor on a lat/long grid

  • target (Tensor) – […, H, W] Target tensor on a lat/long grid

  • climatology (Tensor) – […, H, W] climatology tensor

  • lat (Tensor) – [H] latitude tensor

Returns

ACC values for each field

Return type

Tensor

modulus.metrics.climate.efi.efi(pred_cdf: Tensor, bin_edges: Tensor, climatology_mean: Tensor, climatology_std: Tensor) → Tensor[source]

Calculates the Extreme Forecast Index (EFI) for an ensemble forecast against a climatological distribution.

Parameters
  • pred_cdf (Tensor) – Cumulative distribution function of predictions of shape [N, …] where N is the number of bins. This cdf must be defined over the passed bin_edges.

  • bin_edges (Tensor) – Tensor of bin edges with shape [N+1, …] where N is the number of bins.

  • climatology_mean (Tensor) – Tensor of climatological mean with shape […]

  • climatology_std (Tensor) – Tensor of climatological std with shape […]

Returns

EFI values of each of the batched dimensions.

Return type

Tensor

modulus.metrics.climate.efi.normalized_entropy(pred_pdf: Tensor, bin_edges: Tensor, climatology_mean: Tensor, climatology_std: Tensor) → Tensor[source]

Calculates the relative entropy, or surprise, of using the prediction distribution as opposed to the climatology distribution.

Parameters
  • pred_cdf (Tensor) – Cumulative distribution function of predictions of shape [N, …] where N is the number of bins. This cdf must be defined over the passed bin_edges.

  • bin_edges (Tensor) – Tensor of bin edges with shape [N+1, …] where N is the number of bins.

  • climatology_mean (Tensor) – Tensor of climatological mean with shape […]

  • climatology_std (Tensor) – Tensor of climatological std with shape […]

Returns

Relative Entropy values of each of the batched dimensions.

Return type

Tensor

modulus.metrics.climate.reduction.global_mean(x: Tensor, lat: Tensor, keepdims: bool = False) → Tensor[source]

Computes global mean

This function computs the global mean of a lat/lon grid by weighting over the latitude direction and then averaging over longitude

Parameters
  • x (Tensor) – The lat/lon tensor […, H, W] over which the mean will be computed

  • lat (Tensor) – A one-dimension tensor [H] representing the latitudes at which the function will return weights for

  • keepdims (bool, optional) – Keep aggregated dimension, by default False

Returns

Global mean tensor

Return type

Tensor

modulus.metrics.climate.reduction.global_var(x: Tensor, lat: Tensor, std: bool = False, keepdims: bool = False) → Tensor[source]

Computes global variance

This function computs the global variance of a lat/lon grid by weighting over the latitude direction and then averaging over longitude

Parameters
  • x (Tensor) – The lat/lon tensor […, H, W] over which the variance will be computed

  • lat (Tensor) – A one-dimension tensor [H] representing the latitudes at which the function will return weights for

  • std (bool, optional) – Return global standard deviation, by default False

  • keepdims (bool, optional) – Keep aggregated dimension, by default False

Returns

Global variance tensor

Return type

Tensor

modulus.metrics.climate.reduction.zonal_mean(x: Tensor, lat: Tensor, dim: int = -2, keepdims: bool = False) → Tensor[source]

Computes zonal mean, weighting over the latitude direction that is specified by dim

Parameters
  • x (Tensor) – The tensor […, H, W] over which the mean will be computed

  • lat (Tensor) – A one-dimension tensor representing the latitudes at which the function will return weights for

  • dim (int, optional) – The int specifying which dimension of x the reduction will occur, by default -2

  • keepdims (bool, optional) – Keep aggregated dimension, by default False

Returns

Zonal mean tensor of x over the latitude dimension

Return type

Tensor

modulus.metrics.climate.reduction.zonal_var(x: Tensor, lat: Tensor, std: bool = False, dim: int = -2, keepdims: bool = False) → Tensor[source]

Computes zonal variance, weighting over the latitude direction

Parameters
  • x (Tensor) – The tensor […, H, W] over which the variance will be computed

  • lat (Tensor) – A one-dimension tensor [H] representing the latitudes at which the function will return weights for

  • std (bool, optional) – Return zonal standard deviation, by default False

  • dim (int, optional) – The int specifying which dimension of x the reduction will occur, by default -2

  • keepdims (bool, optional) – Keep aggregated dimension, by default False

Returns

The variance (or standard deviation) of x over the latitude dimension

Return type

Tensor

© Copyright 2023, NVIDIA Modulus Team. Last updated on Aug 8, 2023.