summaryrefslogtreecommitdiff
path: root/viewpmt.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 /viewpmt.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 'viewpmt.py')
-rw-r--r--viewpmt.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/viewpmt.py b/viewpmt.py
new file mode 100644
index 0000000..474b6d8
--- /dev/null
+++ b/viewpmt.py
@@ -0,0 +1,30 @@
+import numpy as np
+from solid import Solid
+from mesh import mesh_from_stl
+from geometry import Geometry
+from view import view
+import models
+
+pmt_inner_mesh = \
+ mesh_from_stl(models.dir + '/hamamatsu_12inch_inner.stl')
+pmt_outer_mesh = \
+ mesh_from_stl(models.dir + '/hamamatsu_12inch_outer.stl')
+
+pmt_outer_mesh.triangles = \
+ pmt_outer_mesh.triangles[np.mean(pmt_outer_mesh[:], axis=1)[:,0] > 0]
+
+photocathode_triangles = np.mean(pmt_inner_mesh[:], axis=1)[:,1] > 0
+
+inner_color = np.empty(len(pmt_inner_mesh.triangles), np.uint32)
+inner_color[photocathode_triangles] = 0xff0000
+inner_color[~photocathode_triangles] = 0x00ff00
+
+outer_color = np.empty(len(pmt_outer_mesh.triangles), np.uint32)
+outer_color[:] = 0xffffff
+
+geometry = Geometry([Solid(0, pmt_inner_mesh, color=inner_color),
+ Solid(1, pmt_outer_mesh, color=outer_color)])
+
+geometry.build(bits=8)
+
+view(geometry)