Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions spine/vis/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,35 @@ def optical_traces(self, meta=None, shared_legend=True, legendgroup=None,
if shared_legend and legendgroup is None:
legendgroup = 'group_' + str(time.time())

# Add a hovertext to the optical detectors
hovertexts = [f'PD ID: {i}' for i in range(len(positions))]
if color is not None and not np.isscalar(color):
hovertexts = [f'{ht}<br>PE: {c:.3f}' for ht, c in zip(hovertexts, color)]

# Draw each of the optical detectors
traces = []
for i, shape in enumerate(self.geo.optical.shape):
# Restrict the positions to those of this shape, if needed
if shape_ids is None:
pos = positions
col = color
ht = hovertexts
else:
index = np.where(np.asarray(shape_ids) == i)[0]
pos = positions[index]
if color is not None and not np.isscalar(color):
col = color[index]
else:
col = color
ht = [hovertexts[i] for i in index]

# If zero-supression is requested, only draw the optical detectors
# which record a non-zero signal
if zero_supress and color is not None and not np.isscalar(color):
index = np.where(np.asarray(col) != 0)[0]
pos = pos[index]
col = col[index]
ht = [ht[i] for i in index]

# Determine wheter to show legends or not
showlegend = not shared_legend or i == 0
Expand All @@ -202,7 +210,7 @@ def optical_traces(self, meta=None, shared_legend=True, legendgroup=None,
traces += box_traces(
lower, upper, shared_legend=shared_legend, name=name,
color=col, cmin=cmin, cmax=cmax, draw_faces=True,
legendgroup=legendgroup, showlegend=showlegend, **kwargs)
hovertext=ht, legendgroup=legendgroup, showlegend=showlegend, **kwargs)

else:
# Convert the optical detector dimensions to a covariance matrix
Expand All @@ -212,7 +220,7 @@ def optical_traces(self, meta=None, shared_legend=True, legendgroup=None,
traces += ellipsoid_traces(
pos, covmat, shared_legend=shared_legend, name=name,
color=col, cmin=cmin, cmax=cmax,
legendgroup=legendgroup, showlegend=showlegend, **kwargs)
hovertext=ht, legendgroup=legendgroup, showlegend=showlegend, **kwargs)

return traces

Expand Down
Loading