def calculate_tmean_from_tmin_tmax(
    ds, tmin_name="tmin", tmax_name="tmax", tmean_name="tmean"
):
    """
    Estimate tmean as the average of tmin and tmax

    Parameters
    ----------
    ds : xarray Dataset
        Dataset containing tmin and tmax variables
    tmin_name : str
        The name of the tmin variable
    tmax_name : str
        The name of the tmax variable
    tmean_name : str
        The name of the output tmean variable
    """
    tmean = ((ds[tmin_name] + ds[tmax_name]) / 2).to_dataset(name=tmean_name)
    tmean[tmean_name].attrs["long_name"] = "Daily mean air temperature"
    return tmean