straxen.analyses package

Submodules

straxen.analyses.bokeh_waveform_plot module

class straxen.analyses.bokeh_waveform_plot.DataSelectionHist(name, size=600)[source]

Bases: object

Class for an interactive data selection plot.

get_back_selected_items()[source]
histogram2d(items, xdata, ydata, bins, hist_range, x_label='X-Data', y_label='Y-Data', log_color_scale=True, cmap_steps=256, clim=(None, None), undeflow_color=None, overflow_color=None, weights=1)[source]

2d Histogram which allows to select the plotted items dynamically.

Note:

You can select the data either via a box select or Lasso select tool. The data can be returned by:

ds.get_back_selected_items()

Hold shift to select multiple regions.

Warnings:

Depending on the number of bins the Lasso selection can become relatively slow. The number of bins should not be larger than 100. The box selection performance is better.

Parameters:
  • items – numpy.structured.array of items to be selected. e.g. peaks or events.

  • xdata – numpy.array for xdata e.g. peaks[‘area’]

  • ydata – same

  • bins – Integer specifying the number of bins. Currently x and y axis must share the same binning.

  • hist_range – Tuple of x-range and y-range.

  • x_label – Label to be used for the x-axis

  • y_label – same but for y

  • log_color_scale – If true (default) use log colorscale

  • cmap_steps – Integer between 0 and 256 for stepped colorbar.

  • clim – Tuple of color limits.

  • undeflow_color – If specified colors all bins below clim with the corresponding color.

  • overflow_color – Same but per limit.

  • weights – If specified each bin entry is weighted by this value. Can be either a scalar e.g. a time or an array of weights which has the same length as the x/y data.

Returns:

bokeh figure instance.

straxen.analyses.bokeh_waveform_plot.bokeh_set_x_range(plot, x_range, debug=False)[source]

Function which adjust java script call back for x_range of a bokeh plot. Required to link bokeh and holoviews x_range.

Note:

This is somewhat voodoo + some black magic, but it works….

straxen.analyses.bokeh_waveform_plot.plot_detail_plot_s1_s2(signal, s1_keys, s2_keys, labels, colors, yscale=('linear', 'linear'))[source]

Function to plot the main/alt S1/S2 peak details.

Parameters:
  • signal – Dictionary containing the peak information.

  • s1_keys – S1 keys to be plotted e.g. with and without alt S1

  • s2_keys – Same but for S2

  • labels – Labels to be used for Peaks

  • colors – Colors to be used

  • yscale – Tuple with axis scale type.

Returns:

S1 and S2 bokeh figure.

straxen.analyses.bokeh_waveform_plot.plot_event(peaks, signal, labels, event, colors, yscale='linear')[source]

Wrapper for plot peaks to highlight main/alt. S1/S2.

Parameters:
  • peaks – Peaks in event

  • signal – Dictionary containing main/alt. S1/S2

  • labels – dict with labels to be used

  • event – Event to set correctly x-ranges.

  • colors – Colors to be used for unknown, s1 and s2 signals.

  • yscale – string of yscale type.

Returns:

bokeh.plotting.figure instance

straxen.analyses.bokeh_waveform_plot.plot_peak_detail(peak, time_scalar=1, label='', unit='ns', colors=('gray', 'blue', 'green'), fig=None)[source]

Function which makes a detailed plot for the given peak. As in the main/alt S1/S2 plots of the event display.

Parameters:
  • peak – Peak to be plotted.

  • time_scalar – Factor to rescale the time from ns to other scale. E.g. =1000 scales to µs.

  • label – Label to be used in the plot legend.

  • unit – Time unit of the plotted peak.

  • colors – Colors to be used for unknown, s1 and s2 peaks.

  • fig – Instance of bokeh.plotting.figure if None one will be created via straxen.bokeh.utils.default_figure().

Returns:

Instance of bokeh.plotting.figure

straxen.analyses.bokeh_waveform_plot.plot_peaks(peaks, time_scalar=1, fig=None, colors=('gray', 'blue', 'green'), yscale='linear')[source]

Function which plots a list/array of peaks relative to the first one.

Parameters:
  • peaks – Peaks to be plotted.

  • time_scalar – Factor to rescale the time from ns to other scale. E.g. =1000 scales to µs.

  • colors – Colors to be used for unknown, s1 and s2 signals

  • yscale – yscale type can be “linear” or “log”

  • fig – Instance of bokeh.plotting.figure if None one will be created via straxen.bokeh.utils.default_figure().

Returns:

bokeh.plotting.figure instance.

straxen.analyses.bokeh_waveform_plot.plot_pmt_array(peak, array_type, to_pe, plot_all_pmts=False, log=False, xenon1t=False, fig=None, label='')[source]

Plots top or bottom PMT array for given peak.

Parameters:
  • peak – Peak for which the hit pattern should be plotted.

  • array_type – String which specifies if “top” or “bottom” PMT array should be plotted

  • to_pe – PMT gains.

  • log – If true use a log-scale for the color scale.

  • plot_all_pmts – If True colors all PMTs instead of showing swtiched off PMTs as gray dots.

  • xenon1t – If True plots 1T array.

  • fig – Instance of bokeh.plotting.figure if None one will be created via straxen.bokeh.utils.default_figure().

  • label – Label of the peak which should be used for the plot legend

Returns:

Tuple containing a bokeh figure, glyph and transform instance.

straxen.analyses.bokeh_waveform_plot.plot_pmt_arrays_and_positions(top_array_keys, bottom_array_keys, signal, to_pe, labels, plot_all_pmts, xenon1t=False, log=True)[source]

Function which plots the Top and Bottom PMT array.

Returns:

fig_top, fig_bottom

straxen.analyses.bokeh_waveform_plot.plot_posS2s(peaks, label='', fig=None, s2_type_style_id=0)[source]

Plots xy-positions of specified peaks.

Parameters:
  • peaks – Peaks for which the position should be plotted.

  • label – Legend label and plot name (name serves as idenitfier).

  • fig – bokeh.plotting.figure instance the plot should be plotted into. If None creates new instance.

  • s2_type_style_id – 0 plots main S2 style, 1 for alt S2 and 2 for other S2s (e.g. single electrons).

straxen.analyses.daq_waveforms module

straxen.analyses.daq_waveforms.group_by_daq(run_id, group_by: str)[source]

From the channel map, get the mapping of channel number -> group by.

straxen.analyses.event_display module

straxen.analyses.event_display.plot_single_event(context: Context, run_id, events, event_number=None, **kwargs)[source]

Wrapper for event_display.

Parameters:
  • context – strax.context

  • run_id – run id

  • events – dataframe / numpy array of events. Should either be length 1 or the event_number argument should be provided

  • event_number – (optional) int, if provided, only show this event number

  • kwargs – kwargs for events_display

Returns:

see events_display

straxen.analyses.holoviews_waveform_display module

Dynamic holoviews-based waveform display Note imports are inside function, to keep ‘import straxen’ free of holoviews.

straxen.analyses.holoviews_waveform_display.get_records_matrix_in_window(polys, x_range, time_slice=10)[source]

Helper function which returns polygons for rendering when x_range is below the specified value.

This function has to be applied to polygons e.g.:

poly.apply(get_records_matrix_in_window, streams=[time_stream])

Parameters:
  • polys – Holoviews Polygons

  • x_range – x_range of the RangeX object.

  • time_slice – Size of the time slice in [µs] when records should be drawn.

straxen.analyses.holoviews_waveform_display.hook(plot, x_range, debug=False)[source]

Hook to set the same RangeX stream for event display and records matrix, voodoo….

Note:

Works only in the following order:

  1. Create holoviews

  2. hv.render plot

  3. set bokeh x_range as holoviews x_range

Does not work first with bokeh and then with holoviews. Why? I have no clue….

straxen.analyses.holoviews_waveform_display.plot_record_polygons(record_points, center_time=True, scaling=0.001)[source]

Plots record hv.Points as polygons for record matrix.

Parameters:
  • record_points – Holoviews Points generated with _records_to_points.

  • center_time – If true treats specified times as center times.

  • scaling – Scale times scale by this factor. E.g. if times should be in µs use 10**-3.

Returns:

hv.Polygons

straxen.analyses.holoviews_waveform_display.seconds_from(t, t_reference, unit_conversion=1000000000)[source]

Helper function which concerts times into relative times in specified unit.

Parameters:
  • t – Time

  • t_reference – Reference time e.g. start of an event or first peak in event.

  • unit_conversion – Conversion factor for time units e.g. 10**3 for micro seconds.

straxen.analyses.holoviews_waveform_display.x_zoom_wheel()[source]

straxen.analyses.posrec_comparison module

straxen.analyses.pulse_plots module

straxen.analyses.pulse_plots.plot_pulses(context, raw_records, run_id, time_range, plot_hits=False, plot_median=False, max_plots=20, store_pdf=False, path='', detector_ending='')[source]

Plots nveto pulses for a list of records.

Parameters:
  • context – Context to be used.

  • plot_hits – If True plot hit boundaries including the left and right extension as orange shaded regions.

  • plot_median – If true plots pulses sample median as dotted line.

  • max_plots – Limits the number of figures. If you would like to plot more pulses you should put the plots in a PDF.

  • store_pdf – If true figures are put to a PDF instead of plotting them to your notebook. The file name is automatically generated including the time range and run_id.

  • path – Relative path where the PDF should be stored. By default it is the directory of the notebook.

  • detector_ending – Ending of the corresponding detector. Empty string for TPC ‘_nv’ for neutron-veto and ‘_mv’ muon-veto.

straxen.analyses.quick_checks module

straxen.analyses.records_matrix module

straxen.analyses.waveform_plot module

Module contents