diff options
author | Anthony LaTorre <tlatorre9@gmail.com> | 2011-08-03 14:32:49 -0400 |
---|---|---|
committer | Anthony LaTorre <tlatorre9@gmail.com> | 2011-08-03 14:32:49 -0400 |
commit | 4bf95f452e3275c12026b16b51dc646846598f19 (patch) | |
tree | 0e0da940d7513518ce14fa49d46e2dc425cee60c /color/colormap.py | |
parent | 42d2241948e04953788ce82bbeef25d0cba584fb (diff) | |
download | chroma-4bf95f452e3275c12026b16b51dc646846598f19.tar.gz chroma-4bf95f452e3275c12026b16b51dc646846598f19.tar.bz2 chroma-4bf95f452e3275c12026b16b51dc646846598f19.zip |
add a GPU class to handle both the gpu context and module; since the geometry requires global device pointers, there should be a one to one correspondence between modules and contexts. the current plan is to perform all gpu operations within this class. also add a simple color map to display hit pmt charge and timing information.
Diffstat (limited to 'color/colormap.py')
-rw-r--r-- | color/colormap.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/color/colormap.py b/color/colormap.py new file mode 100644 index 0000000..b3761ae --- /dev/null +++ b/color/colormap.py @@ -0,0 +1,27 @@ +import numpy as np + +import matplotlib.pyplot as plt + +def map_to_color(a, range=None): + a = np.asarray(a) + if range is None: + range = (a.min(), a.max()) + + x = np.linspace(0, np.pi, 100) + + yr = np.cos(x)**2 + yr[x > np.pi/2] = 0.0 + yg = np.sin(x)**2 + yb = np.cos(x)**2 + yb[x < np.pi/2] = 0.0 + + #plt.plot(x, yr, 'r-', x, yb, 'b-', x, yg, 'g-') + #plt.show() + + ax = np.pi*(a - range[0])/(range[1]-range[0]) + + r = (np.interp(ax, x, yr)*255).astype(np.uint32) + g = (np.interp(ax, x, yg)*255).astype(np.uint32) + b = (np.interp(ax, x, yb)*255).astype(np.uint32) + + return r << 16 | g << 8 | b |