def sel_time(ds, tslice, mean_time=True):
    """
    Get a time slice `tslice` from xarray data object `ds`.
    If `mean_time` is True, result will be averaged over the time dimension after slicing
    """
    ds_sliced = ds.sel({"time": tslice})
    if mean_time is True:
        return ds_sliced.mean(dim="time")
    else:
        return ds_sliced