summaryrefslogtreecommitdiff
path: root/chromaticity.py
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-06-17 14:51:40 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-06-17 14:51:40 -0400
commit34ff4d6c734e5adf3aa8a0e7ca89031effdb1489 (patch)
tree8e3ed0a692117b3eb38d6d89029f9cae42f2ede0 /chromaticity.py
parent870236b3c4950762a73247c68023a8dee6e14a7b (diff)
downloadchroma-34ff4d6c734e5adf3aa8a0e7ca89031effdb1489.tar.gz
chroma-34ff4d6c734e5adf3aa8a0e7ca89031effdb1489.tar.bz2
chroma-34ff4d6c734e5adf3aa8a0e7ca89031effdb1489.zip
visually tested optics code. added models of the inner and outer meshes for the 12" hamamatsu and sno pmts. ratdb.py is able to parse ratdb files. chromaticity.py provides a function to map wavelength -> rgb color. lbne detector model now includes an outer black cylinder and pmts with a glass layer and photocathode/reflective surfaces.
Diffstat (limited to 'chromaticity.py')
-rw-r--r--chromaticity.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/chromaticity.py b/chromaticity.py
index 18ec28f..4080496 100644
--- a/chromaticity.py
+++ b/chromaticity.py
@@ -1,6 +1,7 @@
import numpy as np
-f = open('ciexyz64_1.csv')
+#f = open('ciexyz64_1.csv')
+f = open('sbrgb10w.csv')
color_map = []
for line in f:
@@ -10,9 +11,25 @@ f.close()
color_map = np.array(color_map)
+# zero negative coefficients
+color_map[color_map < 0] = 0
+
+# normalize coefficients
+for i in range(len(color_map)):
+ color_map[i,1:] /= np.sum(color_map[i,1:])
+
def map_wavelength(wavelength):
r = np.interp(wavelength, color_map[:,0], color_map[:,1])
g = np.interp(wavelength, color_map[:,0], color_map[:,2])
b = np.interp(wavelength, color_map[:,0], color_map[:,3])
- return r, g, b
+ if np.iterable(wavelength):
+ rgb = np.empty((len(wavelength),3))
+
+ rgb[:,0] = r
+ rgb[:,1] = g
+ rgb[:,2] = b
+
+ return rgb
+ else:
+ return np.array([r,g,b])