def get_safe(dat, start_idx=None, end_idx=None):
    """
    Returns a filtered window between the two specified indices, with all
    unknown values (-1) removed.
    """
    if start_idx is None:
        start_idx = 0
    if end_idx is None:
        end_idx = 0 if dat.shape[0] == 0 else dat.shape[0] - 1
    # Extract the window.
    dat_win = dat[start_idx:end_idx + 1]
    # Eliminate values that are -1 (unknown).
    return dat_win[dat_win != -1]