Colour Science

Question about "colour.sd_to_XYZ" definition usage

Hi, I am new to this package. I am working on a project to do spectral measurements with a cheap CCD camera . I am currently working on relative power calibration. For this , I want to plot colour points obtained from an sd into a CIE1931 diagram. Up to now without succes. As an intermediate step I decided to obtain the numerical value from my sd. I get an error that might also be the cause of failure of the plotting routine. My data have been casted into a SpectralDistribution object. These are data obtained from pixel values and I convert those against an assumed power spectrum of the source. The pixels are about 0.25 nm apart. Not necesarilly exactly equally spaced. With the data I get the following message when using sd_to_XYZ: #ValueError: Tristimulus values conversion …should be …1,5, 10 or 20 nm! I supposed that the package would deal with getting the proper equally spaced data as the sd object contains the interpolator-extrapolator methods. My code uses simply: colour_point = colour.sd_toXYZ(mysd). Do I have to convert mysd myself? Thanks, Fred

1 Like

Hi @Fredckx,

Sorry for having missed your message, my notification settings were incorrect!

Typically, for irregularly spaced data and when using the default ASTME308, the practise do enforce the 1, 5, 10 or 20nm measurement intervals. If you wanted to integrate at sub-nanometer, currently, you would still need to re-sample your data to a regular interval. This could be done as follows:

my_sd = my_sd.align(colour.SpectralShape(my_sd.shape.start, my_sd.shape.end, 0.25))



Thanks Thomas, I probably also have to do something with my notification settings. In the meantime I have solved my issue. I was able to convert my about 0.25 nm spaced data to exactly 1 nm spaced data. I will shortly post another question about zooming into part of a (CIE1931) chromaticity diagram.


1 Like

Glad you solved your issue! I think that Discourse has been plagued lately with notification emails not being sent! has experienced similar problems lately for example!

OK, thanks. It was “by accident” that I hit upon your reply to my initial question. In the past month I have been involved in bringing further the user interface of my application. Now I am focusing again on data acquisition and analysis.

Thanks for your support.