def index_doy_means(da, time_index):
    """Index a DataArray of day-of-year means to match time_index

    Parameters
    ----------
    da : DataArray
        data to index
    time_index : pandas.DatetimeIndex
        where to index at

    Returns
    -------
    DataArray
        indexed data
    """
    if not len(da.time) == 366:
        raise ValueError(
            f'Expecting dataset with 366 time steps. Got {da.time}.'
        )
    dasel = da.isel(time=time_index.dayofyear)
    dasel['time'].values = time_index
    return dasel