def spectra_apply_wavelength_mask(spectra, mask):
    """ Applies a wavelength mask to a spectra ((wavelengths, values) tuple).
    All values in the spectra that are not in the mask will be removed in the
    returned values. The input spectra is not modified.

    Args:
        spectra (tuple): the (wavelengths, values) spectra tuple.
        mask (array-like): The wavelength values that should be retained.

    Returns:
        The masked tuple of (wavelengths, values).
    """
    boolean_mask = (spectra[0] >= mask.min()) & (spectra[0] <= mask.max())
    return spectra[0][boolean_mask], spectra[1][boolean_mask]
