def XYZtoCIELab(X, Y, Z, obs):  # XYZ - Lab
    """ convert XYZ to CIE-L*ab color
    :param X: X value
    :param Y: Y value (luminance)
    :param Z: Z value
    :param obs: Observer (CIEObs class or class inheriting from it)
    :return: CIE-L*ab tuple """
    xyz = [X / obs.ref_X, Y / obs.ref_Y, Z / obs.ref_Z]

    for i in range(len(xyz)):
        if xyz[i] > 0.008856:
            xyz[i] = pow(xyz[i], (1.0 / 3.0))
        else:
            xyz[i] = (7.787 * xyz[i]) + (16.0 / 116.0)

    CL = (116.0 * xyz[1]) - 16.0
    Ca = 500.0 * (xyz[0] - xyz[1])
    Cb = 200.0 * (xyz[1] - xyz[2])

    return CL, Ca, Cb