def remove_offset(data, start_idx, end_idx, set_between=False):
    """
    Remove offsets in the data.

    Parameters
    ----------
    data : `pint.Quantity`
        Date to be operated upon.
    start_idx : int
        Index that marks the start of the offset.
    end_idx : int
        Index that marks the end of the offset.
    set_between : int
        Set the data after the start point up to the end point to have the
        value of the start point. Default is `False`.

    Returns
    -------
    data : `pint.Quantity`
        Data with offset applied.
    """
    # Set the data after the offset to the data minus the offset
    offset = data[end_idx] - data[start_idx]

    # Set the intemediate data (during the offset) to be the first
    # value if so desired.
    if set_between:
        data[start_idx: end_idx] = data[start_idx]

    data[end_idx:] = data[end_idx:] - offset
    return data