Пример #1
0
    def test_substrate_concentration_MichaelisMenten_Michaelis1913(self):
        """
        Test :func:`colour.biochemistry.michaelis_menten.\
substrate_concentration_MichaelisMenten_Michaelis1913` definition.
        """

        self.assertAlmostEqual(
            substrate_concentration_MichaelisMenten_Michaelis1913(
                0.25, 0.5, 0.25),
            0.250000000000000,
            places=7,
        )

        self.assertAlmostEqual(
            substrate_concentration_MichaelisMenten_Michaelis1913(
                1 / 3, 0.5, 0.25),
            0.500000000000000,
            places=7,
        )

        self.assertAlmostEqual(
            substrate_concentration_MichaelisMenten_Michaelis1913(
                0.4875, 0.75, 0.35),
            0.650000000000000,
            places=7,
        )
Пример #2
0
    def test_nan_substrate_concentration_MichaelisMenten_Michaelis1913(self):
        """
        Test :func:`colour.biochemistry.michaelis_menten.\
substrate_concentration_MichaelisMenten_Michaelis1913` 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:
            s = np.array(case)
            V_max = np.array(case)
            K_m = np.array(case)
            substrate_concentration_MichaelisMenten_Michaelis1913(
                s, V_max, K_m)
Пример #3
0
    def test_n_dimensional_substrate_concentration_MichaelisMenten_Michaelis1913(  # noqa
            self, ):
        """
        Test :func:`colour.biochemistry.michaelis_menten.\
substrate_concentration_MichaelisMenten_Michaelis1913` definition n-dimensional
        arrays support.
        """

        S = 1 / 3
        V_max = 0.5
        K_m = 0.25
        v = substrate_concentration_MichaelisMenten_Michaelis1913(
            S, V_max, K_m)

        S = np.tile(S, (6, 1))
        v = np.tile(v, (6, 1))
        np.testing.assert_almost_equal(
            substrate_concentration_MichaelisMenten_Michaelis1913(
                S, V_max, K_m),
            v,
            decimal=7,
        )

        V_max = np.tile(V_max, (6, 1))
        K_m = np.tile(K_m, (6, 1))
        np.testing.assert_almost_equal(
            substrate_concentration_MichaelisMenten_Michaelis1913(
                S, V_max, K_m),
            v,
            decimal=7,
        )

        S = np.reshape(S, (2, 3, 1))
        V_max = np.reshape(V_max, (2, 3, 1))
        K_m = np.reshape(K_m, (2, 3, 1))
        v = np.reshape(v, (2, 3, 1))
        np.testing.assert_almost_equal(
            substrate_concentration_MichaelisMenten_Michaelis1913(
                S, V_max, K_m),
            v,
            decimal=7,
        )
Пример #4
0
def luminance_Fairchild2010(
        L_hdr: FloatingOrArrayLike,
        epsilon: FloatingOrArrayLike = 1.836) -> FloatingOrNDArray:
    """
    Compute *luminance* :math:`Y` of given *Lightness* :math:`L_{hdr}` using
    *Fairchild and Wyble (2010)* method according to *Michaelis-Menten*
    kinetics.

    Parameters
    ----------
    L_hdr
        *Lightness* :math:`L_{hdr}`.
    epsilon
        :math:`\\epsilon` exponent.

    Returns
    -------
    :class:`numpy.floating` or :class:`numpy.ndarray`
        *Luminance* :math:`Y`.

    Notes
    -----
    +------------+-----------------------+---------------+
    | **Domain** | **Scale - Reference** | **Scale - 1** |
    +============+=======================+===============+
    | ``L_hdr``  | [0, 100]              | [0, 1]        |
    +------------+-----------------------+---------------+

    +------------+-----------------------+---------------+
    | **Range**  | **Scale - Reference** | **Scale - 1** |
    +============+=======================+===============+
    | ``Y``      | [0, 1]                | [0, 1]        |
    +------------+-----------------------+---------------+

    References
    ----------
    :cite:`Fairchild2010`

    Examples
    --------
    >>> luminance_Fairchild2010(31.996390226262736, 1.836)
    ... # doctest: +ELLIPSIS
    0.1219722...
    """

    L_hdr = to_domain_100(L_hdr)

    Y = np.exp(
        np.log(
            substrate_concentration_MichaelisMenten_Michaelis1913(
                L_hdr - 0.02, 100, spow(0.184, epsilon))) / epsilon)

    return as_float(from_range_1(Y))
Пример #5
0
def luminance_Fairchild2011(
    L_hdr: FloatingOrArrayLike,
    epsilon: FloatingOrArrayLike = 0.474,
    method: Union[Literal["hdr-CIELAB", "hdr-IPT"], str] = "hdr-CIELAB",
) -> FloatingOrNDArray:
    """
    Compute *luminance* :math:`Y` of given *Lightness* :math:`L_{hdr}` using
    *Fairchild and Chen (2011)* method according to *Michaelis-Menten*
    kinetics.

    Parameters
    ----------
    L_hdr
        *Lightness* :math:`L_{hdr}`.
    epsilon
        :math:`\\epsilon` exponent.
    method
        *Lightness* :math:`L_{hdr}` computation method.

    Returns
    -------
    :class:`numpy.floating` or :class:`numpy.ndarray`
        *Luminance* :math:`Y`.

    Notes
    -----
    +------------+-----------------------+---------------+
    | **Domain** | **Scale - Reference** | **Scale - 1** |
    +============+=======================+===============+
    | ``L_hdr``  | [0, 100]              | [0, 1]        |
    +------------+-----------------------+---------------+

    +------------+-----------------------+---------------+
    | **Range**  | **Scale - Reference** | **Scale - 1** |
    +============+=======================+===============+
    | ``Y``      | [0, 1]                | [0, 1]        |
    +------------+-----------------------+---------------+

    References
    ----------
    :cite:`Fairchild2011`

    Examples
    --------
    >>> luminance_Fairchild2011(51.852958445912506)  # doctest: +ELLIPSIS
    0.1219722...
    >>> luminance_Fairchild2011(51.643108411718522, method='hdr-IPT')
    ... # doctest: +ELLIPSIS
    0.1219722...
    """

    L_hdr = to_domain_100(L_hdr)
    method = validate_method(method, ["hdr-CIELAB", "hdr-IPT"])

    if method == "hdr-cielab":
        maximum_perception = 247
    else:
        maximum_perception = 246

    Y = np.exp(
        np.log(
            substrate_concentration_MichaelisMenten_Michaelis1913(
                L_hdr - 0.02, maximum_perception, spow(2, epsilon))) / epsilon)

    return as_float(from_range_1(Y))