or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-features.mdchromatic-adaptation.mdcolorimetry.mdcolour-appearance.mdcolour-difference.mdcolour-models.mdconstants.mdgeometry.mdindex.mdinput-output.mdmath-utilities.mdnotation.mdplotting.mdquality-assessment.mdtemperature.md

constants.mddocs/

0

# Constants and Physical Values

1

2

Fundamental physical constants, CIE standards, computational tolerances, and data type definitions used throughout the colour-science package for accurate colorimetric calculations.

3

4

## Capabilities

5

6

### CIE Constants

7

8

Standard CIE constants for photometric and colorimetric calculations.

9

10

```python { .api }

11

# Maximum luminous efficacy constants

12

CONSTANT_K_M: float # 683 lm/W - Maximum photopic luminous efficacy

13

CONSTANT_KP_M: float # 1700 lm/W - Maximum scotopic luminous efficacy

14

```

15

16

### CODATA Physical Constants

17

18

Fundamental physical constants from the Committee on Data for Science and Technology (CODATA).

19

20

```python { .api }

21

# Fundamental constants

22

CONSTANT_AVOGADRO: float # 6.02214179e23 mol⁻¹ - Avogadro constant

23

CONSTANT_BOLTZMANN: float # 1.38065e-23 J/K - Boltzmann constant

24

CONSTANT_LIGHT_SPEED: float # 299792458 m/s - Speed of light in vacuum

25

CONSTANT_PLANCK: float # 6.62607e-34 J⋅s - Planck constant

26

```

27

28

### Computational Constants

29

30

Precision control and computational tolerances for numerical stability.

31

32

```python { .api }

33

# Floating point precision

34

EPSILON: float # Machine epsilon for floating point comparisons

35

THRESHOLD_INTEGER: float # 1e-3 - Threshold for integer detection

36

37

# Regular expression patterns

38

PATTERN_FLOATING_POINT_NUMBER: str # Regex pattern for floating point numbers

39

```

40

41

### Data Types

42

43

Default data types for arrays and computational operations.

44

45

```python { .api }

46

# Default data types

47

DTYPE_INT_DEFAULT: Type # Default integer data type

48

DTYPE_FLOAT_DEFAULT: DTypeFloat # Default floating point data type

49

```

50

51

### Tolerance Values

52

53

Tolerance thresholds for numerical comparisons and testing.

54

55

```python { .api }

56

# Default tolerance values

57

TOLERANCE_ABSOLUTE_DEFAULT: float # Default absolute tolerance

58

TOLERANCE_RELATIVE_DEFAULT: float # Default relative tolerance

59

60

# Test-specific tolerances

61

TOLERANCE_ABSOLUTE_TESTS: float # Absolute tolerance for tests

62

TOLERANCE_RELATIVE_TESTS: float # Relative tolerance for tests

63

```

64

65

## Usage Examples

66

67

### Using Physical Constants

68

69

```python

70

from colour.constants import CONSTANT_PLANCK, CONSTANT_LIGHT_SPEED, CONSTANT_K_M

71

72

# Calculate photon energy

73

wavelength = 555e-9 # 555 nm in meters

74

frequency = CONSTANT_LIGHT_SPEED / wavelength

75

photon_energy = CONSTANT_PLANCK * frequency

76

77

# Use maximum luminous efficacy

78

luminous_flux = radiant_flux * CONSTANT_K_M * luminous_efficiency

79

```

80

81

### Precision Control

82

83

```python

84

from colour.constants import EPSILON, TOLERANCE_ABSOLUTE_DEFAULT

85

import numpy as np

86

87

# Safe floating point comparison

88

def is_equal(a, b, tolerance=TOLERANCE_ABSOLUTE_DEFAULT):

89

return abs(a - b) < tolerance

90

91

# Machine epsilon usage

92

if abs(value) < EPSILON:

93

value = 0.0 # Treat as zero

94

```

95

96

### Data Type Management

97

98

```python

99

from colour.constants import DTYPE_FLOAT_DEFAULT, DTYPE_INT_DEFAULT

100

import numpy as np

101

102

# Create arrays with default types

103

float_array = np.array([1.0, 2.0, 3.0], dtype=DTYPE_FLOAT_DEFAULT)

104

int_array = np.array([1, 2, 3], dtype=DTYPE_INT_DEFAULT)

105

```

106

107

## Types

108

109

```python { .api }

110

from colour.hints import DTypeFloat, Type, Union

111

from typing import Pattern

112

113

# Type aliases used in constants

114

DTypeFloat = Union[Type[np.float16], Type[np.float32], Type[np.float64]]

115

```

116

117

## Imports

118

119

```python

120

# Core constants

121

from colour.constants import (

122

CONSTANT_K_M, CONSTANT_KP_M,

123

CONSTANT_AVOGADRO, CONSTANT_BOLTZMANN,

124

CONSTANT_LIGHT_SPEED, CONSTANT_PLANCK

125

)

126

127

# Computational constants

128

from colour.constants import (

129

EPSILON, THRESHOLD_INTEGER,

130

TOLERANCE_ABSOLUTE_DEFAULT, TOLERANCE_RELATIVE_DEFAULT,

131

DTYPE_INT_DEFAULT, DTYPE_FLOAT_DEFAULT

132

)

133

134

# Pattern matching

135

from colour.constants import PATTERN_FLOATING_POINT_NUMBER

136

```