Closed floehopper closed 3 years ago
I've now investigated the failing test which highlights a discrepancy with the data in the Hunt & Pointer book appendix...
I looks as if there was a transcription error in the u
& v
values copied from the book to the commit note. The commit note gives them as 0.3721, 0.3751 respectively, but I think those are the values for x
& y
. I think the u
& v
values should be 0.2202, 0.3331. See the screenshot below.
When I correct those u
& v
values, I get a colour temperature of 4224.994. While this still doesn't exactly match the value in the book, it does exactly match the value returned from the Python colour-science package:
# python3 -m venv env
# source env/bin/activate
# pip install colour-science
import numpy as np
import colour
uv = np.array([0.2202, 0.3331])
result = colour.temperature.uv_to_CCT_Robertson1968(uv)
print(result) # => [ 4.22499406e+03 1.92254317e-03]
Given that @chrislo wrote the following in the original commit note, I'm happy that it's OK to go with the fixed implementation in this branch, although I will of course update and thus fix the failing test.
I spent some time trying to track down the source of this error, including using a different implementation of the Robertson method in the R colorscience package[4]. This gave a different value again of 4223.8.
In the end, after discussion with Manuel, we decided to take into account the note in CIE015:2018 (p 39):
The computed correlated colour temperature is highly dependent on specifications of the computing process though the variations are insignificant in most practical applications... An agreement about details of the computing method is necessary to avoid undesirable discrepancies between computed correlated colour temperatures
And on page 71
Different rounding or calculation methods can produce a difference of 2 K in the CCT and a difference of 1 in the colour rendering indices and colour fidelity index.
We're confident that our implementation of Robertson's method agrees to within 2K of other implementations we could find.
There were a couple of mistakes in the port from this Python code.
for i in range(1, 31)
in Python is equivalent tofor (let i = 1; i <= 30; i += 1)
in JavaScript notfor (let i = 1; i <= 31; i += 1)
The keys in
robertson.json
should start at 0 not 1 to match theISOTEMPERATURE_LINES_ROBERTSON1968
array in the Python code. I've also updated therobertson-csv-to-json.rb
script which is used to generate the JSON file from a CSV source file.In JavaScript we need to give
wrRuvtPrevious
a default value, so that accessing properties on it will not raise aTypeError
.I've added a test to ensure a TypeError exception is not raised in a bit if an edge case that Manuel discovered. This test is now passing.
I've added a test to see whether the discrepancy mentioned in this commit is now fixed, but the test is failing and something seems way off, so I'm probably missing something. /cc @chrislo
This latter point is why I haven't yet merged these fixes.