def test_n_dimensional_reaction_rate_MichealisMenten(self): """ Tests :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichealisMenten` definition n-dimensional arrays support. """ v = 0.5 V_max = 0.5 K_m = 0.25 S = reaction_rate_MichealisMenten(v, V_max, K_m) v = np.tile(v, (6, 1)) S = np.tile(S, (6, 1)) np.testing.assert_almost_equal(reaction_rate_MichealisMenten( v, V_max, K_m), S, decimal=7) V_max = np.tile(V_max, (6, 1)) K_m = np.tile(K_m, (6, 1)) np.testing.assert_almost_equal(reaction_rate_MichealisMenten( v, V_max, K_m), S, decimal=7) v = np.reshape(v, (2, 3, 1)) V_max = np.reshape(V_max, (2, 3, 1)) K_m = np.reshape(K_m, (2, 3, 1)) S = np.reshape(S, (2, 3, 1)) np.testing.assert_almost_equal(reaction_rate_MichealisMenten( v, V_max, K_m), S, decimal=7)
def test_n_dimensional_reaction_rate_MichealisMenten(self): """ Tests :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichealisMenten` definition n-dimensional arrays support. """ v = 0.5 V_max = 0.5 K_m = 0.25 S = reaction_rate_MichealisMenten(v, V_max, K_m) v = np.tile(v, (6, 1)) S = np.tile(S, (6, 1)) np.testing.assert_almost_equal( reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) V_max = np.tile(V_max, (6, 1)) K_m = np.tile(K_m, (6, 1)) np.testing.assert_almost_equal( reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7) v = np.reshape(v, (2, 3, 1)) V_max = np.reshape(V_max, (2, 3, 1)) K_m = np.reshape(K_m, (2, 3, 1)) S = np.reshape(S, (2, 3, 1)) np.testing.assert_almost_equal( reaction_rate_MichealisMenten(v, V_max, K_m), S, decimal=7)
def test_nan_reaction_rate_MichealisMenten(self): """ Tests :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichealisMenten` 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: v = np.array(case) V_max = np.array(case) K_m = np.array(case) reaction_rate_MichealisMenten(v, V_max, K_m)
def test_nan_reaction_rate_MichealisMenten(self): """ Tests :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichealisMenten` 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: v = np.array(case) V_max = np.array(case) K_m = np.array(case) reaction_rate_MichealisMenten(v, V_max, K_m)
def lightness_Fairchild2011(Y, epsilon=0.474, method='hdr-CIELAB'): """ Computes *Lightness* :math:`L_{hdr}` of given *luminance* :math:`Y` using *Fairchild and Chen (2011)* method according to *Michealis-Menten* kinetics. Parameters ---------- Y : array_like *luminance* :math:`Y`. epsilon : numeric or array_like, optional :math:`\\epsilon` exponent. method : unicode, optional **{'hdr-CIELAB', 'hdr-IPT'}**, *Lightness* :math:`L_{hdr}` computation method. Returns ------- array_like *Lightness* :math:`L_{hdr}`. Notes ----- +------------+-----------------------+---------------+ | **Domain** | **Scale - Reference** | **Scale - 1** | +============+=======================+===============+ | ``Y`` | [0, 1] | [0, 1] | +------------+-----------------------+---------------+ +------------+-----------------------+---------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +============+=======================+===============+ | ``L_hdr`` | [0, 100] | [0, 1] | +------------+-----------------------+---------------+ References ---------- :cite:`Fairchild2011` Examples -------- >>> lightness_Fairchild2011(12.19722535 / 100) # doctest: +ELLIPSIS 51.8529584... >>> lightness_Fairchild2011(12.19722535 / 100, method='hdr-IPT') ... # doctest: +ELLIPSIS 51.6431084... """ Y = to_domain_1(Y) if method.lower() == 'hdr-cielab': maximum_perception = 247 else: maximum_perception = 246 L_hdr = reaction_rate_MichealisMenten( spow(Y, epsilon), maximum_perception, 2 ** epsilon) + 0.02 return from_range_100(L_hdr)
def lightness_Fairchild2011(Y, epsilon=0.474, method='hdr-CIELAB'): """ Computes *Lightness* :math:`L_{hdr}` of given *luminance* :math:`Y` using *Fairchild and Chen (2011)* method according to *Michealis-Menten* kinetics. Parameters ---------- Y : array_like *luminance* :math:`Y`. epsilon : numeric or array_like, optional :math:`\\epsilon` exponent. method : unicode, optional **{'hdr-CIELAB', 'hdr-IPT'}**, *Lightness* :math:`L_{hdr}` computation method. Returns ------- array_like *Lightness* :math:`L_{hdr}`. Notes ----- +------------+-----------------------+---------------+ | **Domain** | **Scale - Reference** | **Scale - 1** | +============+=======================+===============+ | ``Y`` | [0, 1] | [0, 1] | +------------+-----------------------+---------------+ +------------+-----------------------+---------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +============+=======================+===============+ | ``L_hdr`` | [0, 100] | [0, 1] | +------------+-----------------------+---------------+ References ---------- :cite:`Fairchild2011` Examples -------- >>> lightness_Fairchild2011(12.19722535 / 100) # doctest: +ELLIPSIS 51.8529584... >>> lightness_Fairchild2011(12.19722535 / 100, method='hdr-IPT') ... # doctest: +ELLIPSIS 51.6431084... """ Y = to_domain_1(Y) if method.lower() == 'hdr-cielab': maximum_perception = 247 else: maximum_perception = 246 L_hdr = reaction_rate_MichealisMenten( spow(Y, epsilon), maximum_perception, 2 ** epsilon) + 0.02 return from_range_100(L_hdr)
def test_reaction_rate_MichealisMenten(self): """ Tests :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichealisMenten` definition. """ self.assertAlmostEqual(reaction_rate_MichealisMenten(0.25, 0.5, 0.25), 0.250000000000000, places=7) self.assertAlmostEqual(reaction_rate_MichealisMenten(0.5, 0.5, 0.25), 0.333333333333333, places=7) self.assertAlmostEqual(reaction_rate_MichealisMenten(0.65, 0.75, 0.35), 0.487500000000000, places=7)
def lightness_Fairchild2010(Y, epsilon=1.836): """ Computes *Lightness* :math:`L_{hdr}` of given *luminance* :math:`Y` using *Fairchild and Wyble (2010)* method according to *Michealis-Menten* kinetics. Parameters ---------- Y : array_like *luminance* :math:`Y`. epsilon : numeric or array_like, optional :math:`\\epsilon` exponent. Returns ------- array_like *Lightness* :math:`L_{hdr}`. Warning ------- The input domain of that definition is non standard! Notes ----- +------------+-----------------------+---------------+ | **Domain** | **Scale - Reference** | **Scale - 1** | +============+=======================+===============+ | ``Y`` | [0, 1] | [0, 1] | +------------+-----------------------+---------------+ +------------+-----------------------+---------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +============+=======================+===============+ | ``L_hdr`` | [0, 100] | [0, 1] | +------------+-----------------------+---------------+ References ---------- :cite:`Fairchild2010` Examples -------- >>> lightness_Fairchild2010(12.19722535 / 100) # doctest: +ELLIPSIS 31.9963902... """ Y = to_domain_1(Y) maximum_perception = 100 L_hdr = reaction_rate_MichealisMenten( spow(Y, epsilon), maximum_perception, 0.184 ** epsilon) + 0.02 return from_range_100(L_hdr)
def lightness_Fairchild2010(Y, epsilon=1.836): """ Computes *Lightness* :math:`L_{hdr}` of given *luminance* :math:`Y` using *Fairchild and Wyble (2010)* method according to *Michealis-Menten* kinetics. Parameters ---------- Y : array_like *luminance* :math:`Y`. epsilon : numeric or array_like, optional :math:`\\epsilon` exponent. Returns ------- array_like *Lightness* :math:`L_{hdr}`. Warning ------- The input domain of that definition is non standard! Notes ----- +------------+-----------------------+---------------+ | **Domain** | **Scale - Reference** | **Scale - 1** | +============+=======================+===============+ | ``Y`` | [0, 1] | [0, 1] | +------------+-----------------------+---------------+ +------------+-----------------------+---------------+ | **Range** | **Scale - Reference** | **Scale - 1** | +============+=======================+===============+ | ``L_hdr`` | [0, 100] | [0, 1] | +------------+-----------------------+---------------+ References ---------- :cite:`Fairchild2010` Examples -------- >>> lightness_Fairchild2010(12.19722535 / 100) # doctest: +ELLIPSIS 31.9963902... """ Y = to_domain_1(Y) maximum_perception = 100 L_hdr = reaction_rate_MichealisMenten( spow(Y, epsilon), maximum_perception, 0.184 ** epsilon) + 0.02 return from_range_100(L_hdr)
def test_reaction_rate_MichealisMenten(self): """ Tests :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichealisMenten` definition. """ self.assertAlmostEqual( reaction_rate_MichealisMenten(0.25, 0.5, 0.25), 0.250000000000000, places=7) self.assertAlmostEqual( reaction_rate_MichealisMenten(0.5, 0.5, 0.25), 0.333333333333333, places=7) self.assertAlmostEqual( reaction_rate_MichealisMenten(0.65, 0.75, 0.35), 0.487500000000000, places=7)
def lightness_Fairchild2011(Y, epsilon=0.710, method='hdr-CIELAB'): """ Computes *Lightness* :math:`L_{hdr}` of given *luminance* :math:`Y` using *Fairchild and Chen (2011)* method accordingly to *Michealis-Menten* kinetics. Parameters ---------- Y : array_like *luminance* :math:`Y`. epsilon : numeric or array_like, optional :math:`\epsilon` exponent. method : unicode, optional **{'hdr-CIELAB', 'hdr-IPT'}**, *Lightness* :math:`L_{hdr}` computation method. Returns ------- array_like *Lightness* :math:`L_{hdr}`. Warning ------- The input domain of that definition is non standard! Notes ----- - Input *luminance* :math:`Y` is in domain [0, :math:`\infty`]. References ---------- - :cite:`Fairchild2011` Examples -------- >>> lightness_Fairchild2011(10.08 / 100) # doctest: +ELLIPSIS 26.45950981... >>> lightness_Fairchild2011(10.08 / 100, method='hdr-IPT') ... # doctest: +ELLIPSIS 26.3524672... """ Y = np.asarray(Y) if method.lower() == 'hdr-cielab': maximum_perception = 247 else: maximum_perception = 246 L_hdr = reaction_rate_MichealisMenten(Y**epsilon, maximum_perception, 2** epsilon) + 0.02 return L_hdr
def lightness_Fairchild2010(Y, epsilon=2): """ Computes *Lightness* :math:`L_{hdr}` of given *luminance* :math:`Y` using *Fairchild and Wyble (2010)* method accordingly to *Michealis-Menten* kinetics. Parameters ---------- Y : array_like *luminance* :math:`Y`. epsilon : numeric or array_like, optional :math:`\epsilon` exponent. Returns ------- array_like *Lightness* :math:`L_{hdr}`. Warning ------- The input domain of that definition is non standard! Notes ----- - Input *luminance* :math:`Y` is in domain [0, :math:`\infty`]. References ---------- .. [6] Fairchild, M. D., & Wyble, D. R. (2010). hdr-CIELAB and hdr-IPT: Simple Models for Describing the Color of High-Dynamic-Range and Wide-Color-Gamut Images. In Proc. of Color and Imaging Conference (pp. 322–326). ISBN:9781629932156 Examples -------- >>> lightness_Fairchild2010(10.08 / 100, 1.836) # doctest: +ELLIPSIS 24.9022902... """ Y = np.asarray(Y) L_hdr = reaction_rate_MichealisMenten(Y ** epsilon, 100, 0.184 ** epsilon) + 0.02 return L_hdr
def lightness_Fairchild2010(Y, epsilon=1.836): """ Computes *Lightness* :math:`L_{hdr}` of given *luminance* :math:`Y` using *Fairchild and Wyble (2010)* method according to *Michealis-Menten* kinetics. Parameters ---------- Y : array_like *luminance* :math:`Y`. epsilon : numeric or array_like, optional :math:`\epsilon` exponent. Returns ------- array_like *Lightness* :math:`L_{hdr}`. Warning ------- The input domain of that definition is non standard! Notes ----- - Input *luminance* :math:`Y` is in domain [0, :math:`\infty`]. References ---------- - :cite:`Fairchild2010` Examples -------- >>> lightness_Fairchild2010(10.08 / 100) # doctest: +ELLIPSIS 24.9022902... """ maximum_perception = 100 Y = np.asarray(Y) L_hdr = reaction_rate_MichealisMenten(Y**epsilon, maximum_perception, 0.184 **epsilon) + 0.02 return L_hdr