def test_nan_chromatic_adaptation_CIE1994(self): """ Tests :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition nan support. """ cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=3)) for case in cases: XYZ_1 = np.array(case) xy_o1 = np.array(case[0:2]) xy_o2 = np.array(case[0:2]) Y_o = case[0] E_o1 = case[0] E_o2 = case[0] chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2)
def corresponding_chromaticities_prediction_CIE1994(experiment=1): """ Returns the corresponding chromaticities prediction for CIE 1994 chromatic adaptation model. Parameters ---------- experiment : integer, optional {1, 2, 3, 4, 6, 8, 9, 11, 12} Breneman (1987) experiment number. Returns ------- tuple Corresponding chromaticities prediction. Examples -------- >>> from pprint import pprint >>> pr = corresponding_chromaticities_prediction_CIE1994(2) >>> pr = [(p.uvp_m, p.uvp_p) for p in pr] >>> pprint(pr) # doctest: +SKIP [((0.207, 0.486), (0.2133909..., 0.4939794...)), ((0.449, 0.511), (0.4450345..., 0.5120939...)), ((0.263, 0.505), (0.2693262..., 0.5083212...)), ((0.322, 0.545), (0.3308593..., 0.5443940...)), ((0.316, 0.537), (0.3225195..., 0.5377826...)), ((0.265, 0.553), (0.2709737..., 0.5513666...)), ((0.221, 0.538), (0.2280786..., 0.5351592...)), ((0.135, 0.532), (0.1439436..., 0.5303576...)), ((0.145, 0.472), (0.1500743..., 0.4842895...)), ((0.163, 0.331), (0.1559955..., 0.3772379...)), ((0.176, 0.431), (0.1806318..., 0.4518475...)), ((0.244, 0.349), (0.2454445..., 0.4018004...))] """ experiment_results = list(BRENEMAN_EXPERIMENTS.get(experiment)) illuminants = experiment_results.pop(0) xy_o1 = Luv_uv_to_xy(illuminants.uvp_t) xy_o2 = Luv_uv_to_xy(illuminants.uvp_m) # :math:`Y_o` is set to an arbitrary value in domain [18, 100]. Y_o = 18 E_o1 = E_o2 = BRENEMAN_EXPERIMENTS_PRIMARIES_CHROMATICITIES.get( experiment).Y prediction = [] for result in experiment_results: XYZ_1 = xy_to_XYZ(Luv_uv_to_xy(result.uvp_t)) * 100 XYZ_2 = chromatic_adaptation_CIE1994( XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2) uvp = Luv_to_uv(XYZ_to_Luv(XYZ_2, xy_o2), xy_o2) prediction.append(CorrespondingChromaticitiesPrediction( result.name, result.uvp_t, result.uvp_m, uvp)) return tuple(prediction)
def test_n_dimensional_chromatic_adaptation_CIE1994(self): """ Tests :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition n-dimensional arrays support. """ XYZ_1 = np.array([28.00, 21.26, 5.27]) xy_o1 = np.array([0.4476, 0.4074]) xy_o2 = np.array([0.3127, 0.3290]) Y_o = 20 E_o1 = 1000 E_o2 = 1000 XYZ_2 = np.array([24.03379521, 21.15621214, 17.64301199]) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) XYZ_1 = np.tile(XYZ_1, (6, 1)) XYZ_2 = np.tile(XYZ_2, (6, 1)) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) xy_o1 = np.tile(xy_o1, (6, 1)) xy_o2 = np.tile(xy_o2, (6, 1)) Y_o = np.tile(Y_o, 6) E_o1 = np.tile(E_o1, 6) E_o2 = np.tile(E_o2, 6) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) XYZ_1 = np.reshape(XYZ_1, (2, 3, 3)) xy_o1 = np.reshape(xy_o1, (2, 3, 2)) xy_o2 = np.reshape(xy_o2, (2, 3, 2)) Y_o = np.reshape(Y_o, (2, 3)) E_o1 = np.reshape(E_o1, (2, 3)) E_o2 = np.reshape(E_o2, (2, 3)) XYZ_2 = np.reshape(XYZ_2, (2, 3, 3)) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7)
def test_n_dimensional_chromatic_adaptation_CIE1994(self): """ Tests :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition n-dimensional arrays support. """ XYZ_1 = np.array([28.00, 21.26, 5.27]) xy_o1 = np.array([0.44760, 0.40740]) xy_o2 = np.array([0.31270, 0.32900]) Y_o = 20 E_o1 = 1000 E_o2 = 1000 XYZ_2 = np.array([24.03379521, 21.15621214, 17.64301199]) np.testing.assert_almost_equal(chromatic_adaptation_CIE1994( XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) XYZ_1 = np.tile(XYZ_1, (6, 1)) XYZ_2 = np.tile(XYZ_2, (6, 1)) np.testing.assert_almost_equal(chromatic_adaptation_CIE1994( XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) xy_o1 = np.tile(xy_o1, (6, 1)) xy_o2 = np.tile(xy_o2, (6, 1)) Y_o = np.tile(Y_o, 6) E_o1 = np.tile(E_o1, 6) E_o2 = np.tile(E_o2, 6) np.testing.assert_almost_equal(chromatic_adaptation_CIE1994( XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7) XYZ_1 = np.reshape(XYZ_1, (2, 3, 3)) xy_o1 = np.reshape(xy_o1, (2, 3, 2)) xy_o2 = np.reshape(xy_o2, (2, 3, 2)) Y_o = np.reshape(Y_o, (2, 3)) E_o1 = np.reshape(E_o1, (2, 3)) E_o2 = np.reshape(E_o2, (2, 3)) XYZ_2 = np.reshape(XYZ_2, (2, 3, 3)) np.testing.assert_almost_equal(chromatic_adaptation_CIE1994( XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2), XYZ_2, decimal=7)
def corresponding_chromaticities_prediction_CIE1994(experiment=1): """ Returns the corresponding chromaticities prediction for CIE 1994 chromatic adaptation model. Parameters ---------- experiment : integer, optional {1, 2, 3, 4, 6, 8, 9, 11, 12} Breneman (1987) experiment number. Returns ------- tuple Corresponding chromaticities prediction. Examples -------- >>> from pprint import pprint >>> pr = corresponding_chromaticities_prediction_CIE1994(2) >>> pr = [(p.uvp_m, p.uvp_p) for p in pr] >>> pprint(pr) # doctest: +SKIP [((0.207, 0.486), (0.2133909..., 0.4939794...)), ((0.449, 0.511), (0.4450345..., 0.5120939...)), ((0.263, 0.505), (0.2693262..., 0.5083212...)), ((0.322, 0.545), (0.3308593..., 0.5443940...)), ((0.316, 0.537), (0.3225195..., 0.5377826...)), ((0.265, 0.553), (0.2709737..., 0.5513666...)), ((0.221, 0.538), (0.2280786..., 0.5351592...)), ((0.135, 0.532), (0.1439436..., 0.5303576...)), ((0.145, 0.472), (0.1500743..., 0.4842895...)), ((0.163, 0.331), (0.1559955..., 0.3772379...)), ((0.176, 0.431), (0.1806318..., 0.4518475...)), ((0.244, 0.349), (0.2454445..., 0.4018004...))] """ experiment_results = list(BRENEMAN_EXPERIMENTS.get(experiment)) illuminants = experiment_results.pop(0) xy_o1 = Luv_uv_to_xy(illuminants.uvp_t) xy_o2 = Luv_uv_to_xy(illuminants.uvp_m) # :math:`Y_o` is set to an arbitrary value in domain [18, 100]. Y_o = 18 E_o1 = E_o2 = BRENEMAN_EXPERIMENTS_PRIMARIES_CHROMATICITIES.get( experiment).Y prediction = [] for result in experiment_results: XYZ_1 = xy_to_XYZ(Luv_uv_to_xy(result.uvp_t)) * 100 XYZ_2 = chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2) uvp = Luv_to_uv(XYZ_to_Luv(XYZ_2, xy_o2), xy_o2) prediction.append( CorrespondingChromaticitiesPrediction(result.name, result.uvp_t, result.uvp_m, uvp)) return tuple(prediction)
def test_chromatic_adaptation_CIE1994(self): """ Test :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition. """ np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([28.00, 21.26, 5.27]), xy_o1=np.array([0.44760, 0.40740]), xy_o2=np.array([0.31270, 0.32900]), Y_o=20, E_o1=1000, E_o2=1000, ), np.array([24.03379521, 21.15621214, 17.64301199]), decimal=7, ) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([21.77, 19.18, 16.73]), xy_o1=np.array([0.31270, 0.32900]), xy_o2=np.array([0.31270, 0.32900]), Y_o=50, E_o1=100, E_o2=1000, ), np.array([21.12891746, 19.42980532, 19.49577765]), decimal=7, ) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([0.07818780, 0.06157201, 0.28099326]) * 100, xy_o1=np.array([0.31270, 0.32900]), xy_o2=np.array([0.37208, 0.37529]), Y_o=20, E_o1=100, E_o2=1000, ), np.array([9.14287406, 9.35843355, 15.95753504]), decimal=7, )
def test_domain_range_scale_chromatic_adaptation_CIE1994(self): """ Tests :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition domain and range scale support. """ XYZ_1 = np.array([28.00, 21.26, 5.27]) xy_o1 = np.array([0.44760, 0.40740]) xy_o2 = np.array([0.31270, 0.32900]) Y_o = 20 E_o1 = 1000 E_o2 = 1000 XYZ_2 = chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2) d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_almost_equal(chromatic_adaptation_CIE1994( XYZ_1 * factor, xy_o1, xy_o2, Y_o * factor, E_o1, E_o2), XYZ_2 * factor, decimal=7)
def test_chromatic_adaptation_CIE1994(self): """ Tests :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition. """ np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([28.00, 21.26, 5.27]), xy_o1=np.array([0.4476, 0.4074]), xy_o2=np.array([0.3127, 0.3290]), Y_o=20, E_o1=1000, E_o2=1000), np.array([24.03379521, 21.15621214, 17.64301199]), decimal=7) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([21.77, 19.18, 16.73]), xy_o1=np.array([0.3127, 0.3290]), xy_o2=np.array([0.3127, 0.3290]), Y_o=50, E_o1=100, E_o2=1000), np.array([21.12891746, 19.42980532, 19.49577765]), decimal=7) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([0.47097710, 0.34950000, 0.11301649]) * 100, xy_o1=np.array([0.3127, 0.3290]), xy_o2=np.array([0.4476, 0.4074]), Y_o=20, E_o1=100, E_o2=1000), np.array([40.55293261, 28.95161939, 4.09480293]), decimal=7)
def test_chromatic_adaptation_CIE1994(self): """ Tests :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition. """ np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([28.00, 21.26, 5.27]), xy_o1=np.array([0.44760, 0.40740]), xy_o2=np.array([0.31270, 0.32900]), Y_o=20, E_o1=1000, E_o2=1000), np.array([24.03379521, 21.15621214, 17.64301199]), decimal=7) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([21.77, 19.18, 16.73]), xy_o1=np.array([0.31270, 0.32900]), xy_o2=np.array([0.31270, 0.32900]), Y_o=50, E_o1=100, E_o2=1000), np.array([21.12891746, 19.42980532, 19.49577765]), decimal=7) np.testing.assert_almost_equal( chromatic_adaptation_CIE1994( XYZ_1=np.array([0.07818780, 0.06157201, 0.28099326]) * 100, xy_o1=np.array([0.31270, 0.32900]), xy_o2=np.array([0.37208, 0.37529]), Y_o=20, E_o1=100, E_o2=1000), np.array([9.14287406, 9.35843355, 15.95753504]), decimal=7)
def test_domain_range_scale_chromatic_adaptation_CIE1994(self): """ Tests :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition domain and range scale support. """ XYZ_1 = np.array([28.00, 21.26, 5.27]) xy_o1 = np.array([0.44760, 0.40740]) xy_o2 = np.array([0.31270, 0.32900]) Y_o = 20 E_o1 = 1000 E_o2 = 1000 XYZ_2 = chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2) d_r = (('reference', 1), (1, 0.01), (100, 1)) for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_almost_equal( chromatic_adaptation_CIE1994(XYZ_1 * factor, xy_o1, xy_o2, Y_o * factor, E_o1, E_o2), XYZ_2 * factor, decimal=7)
def corresponding_chromaticities_prediction_CIE1994(experiment=1): """ Returns the corresponding chromaticities prediction for *CIE 1994* chromatic adaptation model. Parameters ---------- experiment : integer or CorrespondingColourDataset, optional {1, 2, 3, 4, 6, 8, 9, 11, 12} *Breneman (1987)* experiment number or :class:`colour.CorrespondingColourDataset` class instance. Returns ------- tuple Corresponding chromaticities prediction. References ---------- :cite:`Breneman1987b`, :cite:`CIETC1-321994b` Examples -------- >>> from pprint import pprint >>> pr = corresponding_chromaticities_prediction_CIE1994(2) >>> pr = [(p.uv_m, p.uv_p) for p in pr] >>> pprint(pr) # doctest: +ELLIPSIS [(array([ 0.207, 0.486]), array([ 0.2273130..., 0.5267609...])), (array([ 0.449, 0.511]), array([ 0.4612181..., 0.5191849...])), (array([ 0.263, 0.505]), array([ 0.2872404..., 0.5306938...])), (array([ 0.322, 0.545]), array([ 0.3489822..., 0.5454398...])), (array([ 0.316, 0.537]), array([ 0.3371612..., 0.5421567...])), (array([ 0.265, 0.553]), array([ 0.2889416..., 0.5534074...])), (array([ 0.221, 0.538]), array([ 0.2412195..., 0.5464301...])), (array([ 0.135, 0.532]), array([ 0.1530344..., 0.5488239...])), (array([ 0.145, 0.472]), array([ 0.1568709..., 0.5258835...])), (array([ 0.163, 0.331]), array([ 0.1499762..., 0.4401747...])), (array([ 0.176, 0.431]), array([ 0.1876711..., 0.5039627...])), (array([ 0.244, 0.349]), array([ 0.2560012..., 0.4546263...]))] """ experiment_results = (convert_experiment_results_Breneman1987(experiment) if is_numeric(experiment) else experiment) with domain_range_scale(1): XYZ_t, XYZ_r = experiment_results.XYZ_t, experiment_results.XYZ_r xy_o1, xy_o2 = XYZ_to_xy([XYZ_t, XYZ_r]) uv_t = Luv_to_uv(XYZ_to_Luv(experiment_results.XYZ_ct, xy_o1), xy_o1) uv_m = Luv_to_uv(XYZ_to_Luv(experiment_results.XYZ_cr, xy_o2), xy_o2) Y_r = experiment_results.B_r E_o1, E_o2 = experiment_results.Y_t, experiment_results.Y_r XYZ_1 = experiment_results.XYZ_ct XYZ_2 = chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_r, E_o1, E_o2) uv_p = Luv_to_uv(XYZ_to_Luv(XYZ_2, xy_o2), xy_o2) return tuple([ CorrespondingChromaticitiesPrediction(experiment_results.name, uv_t[i], uv_m[i], uv_p[i]) for i in range(len(uv_t)) ])
def corresponding_chromaticities_prediction_CIE1994(experiment=1, **kwargs): """ Returns the corresponding chromaticities prediction for CIE 1994 chromatic adaptation model. Parameters ---------- experiment : integer, optional {1, 2, 3, 4, 6, 8, 9, 11, 12} Breneman (1987) experiment number. \**kwargs : dict, optional Keywords arguments. Returns ------- tuple Corresponding chromaticities prediction. Examples -------- >>> from pprint import pprint >>> pr = corresponding_chromaticities_prediction_CIE1994(2) >>> pr = [(p.uvp_m, p.uvp_p) for p in pr] >>> pprint(pr) # doctest: +SKIP [((0.207, 0.486), (0.21339093279517196, 0.49397945742298016)), ((0.449, 0.511), (0.4450345313098153, 0.5120939085633327)), ((0.263, 0.505), (0.26932620724691858, 0.50832124608390727)), ((0.322, 0.545), (0.33085939370840811, 0.54439408389253441)), ((0.316, 0.537), (0.3225195584183046, 0.53778269440789594)), ((0.265, 0.553), (0.2709737181087471, 0.5513666373694861)), ((0.221, 0.538), (0.22807869730753863, 0.53515923458385406)), ((0.135, 0.532), (0.14394366662060523, 0.53035769204585748)), ((0.145, 0.472), (0.15007438031976222, 0.48428958620888679)), ((0.163, 0.331), (0.15599555781959967, 0.37723798698131394)), ((0.176, 0.431), (0.18063180902005657, 0.45184759430042898)), ((0.244, 0.349), (0.24544456656434688, 0.40180048388092021))] """ experiment_results = list(BRENEMAN_EXPERIMENTS.get(experiment)) illuminants = experiment_results.pop(0) xy_o1 = Luv_uv_to_xy(illuminants.uvp_t) xy_o2 = Luv_uv_to_xy(illuminants.uvp_m) # :math:`Y_o` is set to an arbitrary value in domain [18, 100]. Y_o = 18 E_o1 = E_o2 = BRENEMAN_EXPERIMENTS_PRIMARIES_CHROMATICITIES.get( experiment).Y prediction = [] for result in experiment_results: XYZ_1 = xy_to_XYZ(Luv_uv_to_xy(result.uvp_t)) * 100 XYZ_2 = chromatic_adaptation_CIE1994( XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2) uvp = Luv_to_uv(XYZ_to_Luv(XYZ_2, xy_o2), xy_o2) prediction.append(CorrespondingChromaticitiesPrediction( result.name, result.uvp_t, result.uvp_m, uvp)) return tuple(prediction)
def corresponding_chromaticities_prediction_CIE1994(experiment=1, **kwargs): """ Returns the corresponding chromaticities prediction for CIE 1994 chromatic adaptation model. Parameters ---------- experiment : integer, optional {1, 2, 3, 4, 6, 8, 9, 11, 12} Breneman (1987) experiment number. \*\*kwargs : \*\* Keywords arguments. Returns ------- tuple Corresponding chromaticities prediction. Examples -------- >>> from pprint import pprint >>> pr = corresponding_chromaticities_prediction_CIE1994(2) >>> pr = [(p.uvp_m, p.uvp_p) for p in pr] >>> pprint(pr) # doctest: +SKIP [((0.207, 0.486), (0.21339093279517196, 0.49397945742298016)), ((0.449, 0.511), (0.4450345313098153, 0.5120939085633327)), ((0.263, 0.505), (0.26932620724691858, 0.50832124608390727)), ((0.322, 0.545), (0.33085939370840811, 0.54439408389253441)), ((0.316, 0.537), (0.3225195584183046, 0.53778269440789594)), ((0.265, 0.553), (0.2709737181087471, 0.5513666373694861)), ((0.221, 0.538), (0.22807869730753863, 0.53515923458385406)), ((0.135, 0.532), (0.14394366662060523, 0.53035769204585748)), ((0.145, 0.472), (0.15007438031976222, 0.48428958620888679)), ((0.163, 0.331), (0.15599555781959967, 0.37723798698131394)), ((0.176, 0.431), (0.18063180902005657, 0.45184759430042898)), ((0.244, 0.349), (0.24544456656434688, 0.40180048388092021))] """ experiment_results = list(BRENEMAN_EXPERIMENTS.get(experiment)) illuminants = experiment_results.pop(0) xy_o1 = Luv_uv_to_xy(illuminants.uvp_t) xy_o2 = Luv_uv_to_xy(illuminants.uvp_m) # :math:`Y_o` is set to an arbitrary value in domain [18, 100]. Y_o = 18 E_o1 = E_o2 = BRENEMAN_EXPERIMENTS_PRIMARIES_CHROMATICITIES.get( experiment).Y prediction = [] for result in experiment_results: XYZ_1 = xy_to_XYZ(Luv_uv_to_xy(result.uvp_t)) * 100 XYZ_2 = chromatic_adaptation_CIE1994( XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2) uvp = Luv_to_uv(XYZ_to_Luv(XYZ_2, xy_o2), xy_o2) prediction.append(CorrespondingChromaticitiesPrediction( result.name, result.uvp_t, result.uvp_m, uvp)) return tuple(prediction)