dctools.metrics.metrics.MetricComputer

class dctools.metrics.metrics.MetricComputer(eval_variables=None, oceanbench_eval_variables=None, is_class4=False, class4_kwargs=None, **kwargs)

Computes metrics between prediction and reference datasets.

Extends OceanbenchMetrics to handle variable mapping and optional noise addition.

Parameters:
  • eval_variables (List[str] | None)

  • oceanbench_eval_variables (List[str] | None)

  • is_class4 (bool)

  • class4_kwargs (Dict[str, Any] | None)

__init__(eval_variables=None, oceanbench_eval_variables=None, is_class4=False, class4_kwargs=None, **kwargs)

Initialize the MetricComputer.

Parameters:
  • eval_variables (Optional[List[str]]) – List of variable names to evaluate in the prediction/reference datasets.

  • oceanbench_eval_variables (Optional[List[str]]) – List of variable names corresponding to OceanBench standards. If None, tries to map eval_variables automatically.

  • is_class4 (bool) – Whether to use Class 4 metrics (Lagrangian/in-situ comparisons). Defaults to False.

  • class4_kwargs (Optional[Dict[str, Any]]) – Additional arguments for Class 4 evaluation.

  • **kwargs – Additional arguments, e.g., add_noise=True.

Methods

__init__([eval_variables, ...])

Initialize the MetricComputer.

compute(pred_data[, ref_data, pred_coords, ...])

Compute the metrics.

compute_metric(pred_data[, ref_data, ...])

Compute a given metric.

get_metric_name()

Return the name of the metric.

compute(pred_data, ref_data=None, pred_coords=None, ref_coords=None, **kwargs)

Compute the metrics.

Parameters:
  • pred_data (xr.Dataset) – Prediction dataset.

  • ref_data (xr.Dataset, optional) – Reference dataset.

  • pred_coords (CoordinateSystem, optional) – Coordinate system of the prediction data.

  • ref_coords (CoordinateSystem, optional) – Coordinate system of the reference data.

  • kwargs (Any)

Returns:

The computed metric result, or None if an error occurs.

Return type:

Any