def trim_age_offset_arrays(res_df, age_arr, off_arr=None):
    """
    Trims age and offset arrays based on retained values from the results_df.
    """
    good_inds = res_df.index.values

    age_arr_trim = age_arr[good_inds, :]

    if off_arr is not None:
        off_arr_trim = off_arr[good_inds, :]

        return age_arr_trim, off_arr_trim

    else:
        return age_arr_trim