Skip to content

Commit

Permalink
speed up time plot
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Aug 30, 2024
1 parent 7937e2a commit c985eb2
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions viewer/feminos-viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from tkinter import simpledialog
from numba import njit
from tkinter import font
from matplotlib import colors as mcolors

hep.style.use(hep.style.CMS)

Expand All @@ -41,6 +42,27 @@ def __setitem__(self, key, value):

plt.rcParams["axes.prop_cycle"] = plt.cycler(color=plt.cm.Set1.colors)

jet = plt.get_cmap("jet")


# Create a new colormap that starts with white and then transitions to 'jet'
def white_to_jet(n):
# n is the number of colors in the colormap
# Create an array of colors with the same length as n
colors = np.zeros((n, 4)) # RGBA

# Fill the first row with white
colors[0] = [1, 1, 1, 1]

# Fill the rest with the 'jet' colormap
for i in range(1, n):
colors[i] = jet(i / (n - 1))

return mcolors.ListedColormap(colors)


white_jet = white_to_jet(256)

# TODO: https://github.com/rest-for-physics/feminos-daq/issues/3
readouts = {
"IAXO-D0": {
Expand Down Expand Up @@ -2296,7 +2318,6 @@ def plot_event_time(self):
continue

values = np.asarray(values)
baseline = values[:baseline_factor]
baseline_level = np.mean(values[:baseline_factor])
baseline_sigma = np.std(values[:baseline_factor])

Expand Down Expand Up @@ -2327,15 +2348,15 @@ def plot_event_time(self):
times_x,
bins=[bins_x, bins_time],
weights=weights_x,
cmap="jet",
cmap=white_jet,
)

self.ax_right.hist2d(
position_y,
times_y,
bins=[bins_y, bins_time],
weights=weights_y,
cmap="jet",
cmap=white_jet,
)

self.figure.suptitle(f"Event {entry} - Position (X/Y) vs Time (Z)")
Expand Down

0 comments on commit c985eb2

Please sign in to comment.