def __normalize(variable):
    """
    Scale a variable to mean zero and standard deviation 1

    Parameters
    ----------
    variable : xarray.DataArray or np.ndarray

    Returns
    -------
    xarray.DataArray or np.ndarray
    """
    mean = variable.mean()
    std = variable.std()
    if std != 0:
        result = (variable - mean) / std
    else:
        result = variable - mean
    return result