def eotf_clamping_validation()

in src/open_vp_cal/framework/validation.py [0:0]


    def eotf_clamping_validation(calibration_results: Dict) -> ValidationResult:
        """ This validation checks that the EOTF is not being clamped by checking that the last few samples of the eotf
            are not all close to each other. If they are it suggests there is clamping happening

        Args:
            calibration_results: The calibration results

        Returns: The result of the validation check

        """
        result = ValidationResult()
        result.name = "EOTF Clamping Validation"

        eotf_ramps = np.array(calibration_results[Results.PRE_EOTF_RAMPS])
        eotf_sample_selection = 4
        last_samples = eotf_ramps[-eotf_sample_selection:]

        message = ""

        def check_too_close(samples, tolerance=0.01):
            for i in range(samples.size):
                for j in range(i + 1, samples.size):
                    if np.isclose(samples[i], samples[j], atol=tolerance):
                        return True
            return False

        # Check for each color channel if any of the values are close to each other
        for i, color in enumerate(['red', 'green', 'blue']):
            channel_samples = last_samples[:, i]
            if check_too_close(channel_samples):
                result.status = ValidationStatus.FAIL
                message += (
                    f"The last {eotf_sample_selection} of the eotf in the {color} channel have values "
                    f"which all seem to be the same, which suggests they are being clamped\n"
                )

        result.message = message
        return result