def get_metric(mod, obs, fun, dim='time', verbose=False):
    """Calculate a metric along a dimension.

    Metrics implemented:           name
    * correlation                  > corr
    * mse                          > mse
    * rmse                         > rmse
    * mean percentage error        > mpe
    * standard deviation ratio     > stdratio
    * bias                         > bias
    * bias squared                 > bias2
    * phaseerr                     > phaseerr
    * varerr                       > varerr
    * robust modeling effficiency  > nse_rob
    * modeling effficiency         > nse

    Only values present in both datasets are used to calculate metrics.

    Parameters
    ----------
    data: xarray.Dataset
        Dataset with data variables 'mod' (modelled) and 'obs' (observed).
    fun: Callable
        A function that takes three arguments: Modelled (xarray.DataArray), observed (xarray.DataArray)
        and the dimension along which the metric is calculated.
    dim: str
        The dimension name along which the metri is calculated, default is `time`.

    Returns
    ----------
    xarray.Dataset

    """

    return fun(mod, obs, dim)