def accumulate_time(data, t_acc):
    """Generates a dataset of time-accumulated values.

    Parameters
    ----------
        data: xarray.Dataset
        t_acc: list
    """
    data_accum = data.copy()
    for var in data_accum.var():
        try:
            if data_accum[var].units == 'kg m-2 s-1':
                data_accum[var] = data_accum[var].rolling(time=t_acc).sum()
            else:
                data_accum[var] = data_accum[var].rolling(time=t_acc).mean()
        except AttributeError:
            data_accum[var] = data_accum[var].rolling(time=t_acc).sum()
        except KeyError:
            data_accum = data_accum.drop(var)
    for old_name in data_accum.var():
        new_name = old_name + '_tacc' + str(t_acc)
        data_accum[new_name] = data_accum[old_name].rename(new_name)
        data_accum = data_accum.drop(old_name)
    return data_accum
