PlotMixin¶
-
class
cait.mixins.PlotMixin[source]¶ Bases:
objectMixin Class for the DataHandler to make essential plots for the analysis
-
show_efficiency(channel=0, cut_flag=None, which_quantity='true_ph', bins=100, title=None, xlabel=None, ylabel=None, show=True, plot=True, xran=None, yran=None, block=False, save_path=None, dpi=150, range=None, xscale='linear')[source]¶ Calculate the cut efficiency for a given cut flag and plot it.
- Parameters
channel (int) – The cut efficiency is calculated and plotted for this channel.
cut_flag (list of bools) – The cut values that are used for the cut efficiency calculation.
which_quantity (string) – Either ‘true_ph’, ‘ph’, ‘of’, ‘sef’ or ‘recoil_energy’. The method that is used for the pulse height estimation.
bins (int) – The number of bins in which we calculate the efficiency.
title (string) – A title for the plot.
xlabel (string) – A label for the x axis.
ylabel (string) – A label for the y axis.
show (bool) – If set, the plots are shown.
plot (bool) – Do a plot of the cut efficiency. Otherwise, only the values are returned.
xran (tuple of two floats) – The range of the x axis.
yran (tuple of two floats) – The range of the y axis.
block (bool) – If False the matplotlib generated figure window does not block the futher code execution.
save_path (string) – If set, the plots are save to this directory.
dpi (int) – The dots per inch of the plot.
range (tuple of two floats) – The range in which the histogram is calculated. This should be maximally as large as the interval in which the pulses are simulated.
xscale (string) – Either ‘linear’ or ‘log’. The binning of the x axis.
- Returns
The efficiency within the bins, the number of counts within the bins, the bin edges.
- Return type
tuple of (array of length bins, array of length bins, array of length bins+1)
-
show_exceptional_sev(naming, title=None, show_fit=True, block=True, sample_length=None, show=True, save_path=None, dpi=150)[source]¶ Plot an exceptional standardevent.
- Parameters
naming (string) – The naming of the event, must match the group in the h5 data set, e.g. “carrier” –> group name “stdevent_carrier”
title (string) – A title for the plot.
show_fit (bool) – If True then also plot the parametric fit.
block (bool) – If False the matplotlib generated figure window does not block the futher code execution
sample_length (float) – The length of a sample in milliseconds. If None, it is calcualted from the sample frequency.
show (bool) – If set, the plots are shown.
save_path (string) – If set, the plots are save to this directory.
dpi (int) – The dots per inch of the plot.
-
show_hist(title=None, which_mp='pulse_height', only_idx=None, which_channel=0, type='events', which_labels=None, which_predictions=None, pred_model=None, bins=100, block=False, ran=None, show=True, save_path=None, dpi=150)[source]¶ Show a histogram of main parameter values
Attention! This method is depricated! Use show_values instead!
-
show_ly(title=None, xlabel=None, ylabel=None, which_method='ph', x_channel=0, y_channel=1, xlim=None, ylim=None, only_idx=None, type='events', which_labels=None, good_y_classes=None, which_predictions=None, pred_model=None, block=False, marker='.', alpha=0.8, s=10, show=True, save_path=None, dpi=150, name_appendix='')[source]¶ Make a Light Yield Plot out of specific Labels or Predictions.
The Light Yield Parameter was described in “CRESST Collaboration, First results from the CRESST-III low-mass dark matter program” (10.1103/PhysRevD.100.102002).
- Parameters
title (string) – A title for the plot.
xlabel (string) – A label for the x axis.
ylabel (string) – A label for the y axis.
which_method (string) – Either ph, sef or of. The pulse height estimation method that is used for the plot.
x_channel (int) – The number of the channel that PHs are on the x axis.
y_channel (int) – The number of the channel that PHs are on the y axis.
xlim (tuple of two floats) – The range of the x axis.
ylim (tuple of two floats) – The range of the y axis.
only_idx (list of ints or None) – If set only these indices are used.
type (string) – Either events or testpulses.
which_labels (list of ints) – The labels that are used in the plot.
good_y_classes (list of ints or None) – If set events with y class other than in that list are not used in the plot.
which_predictions (list of ints or None) – The predictions that are used in the plot.
pred_model (string) – The naming of the model from that the predictions are.
block (bool) – If the plot blocks the code when executed in cmd.
marker (string) – The marker type from pyplots scatter plot.
alpha (float) – The transparency factor of the scatter objects. Between 0 and 1.
s (int) – The size parameter of the scatter objects.
show (bool) – If set, the plots are shown.
save_path (string) – If set, the plots are save to this directory.
dpi (int) – The dots per inch of the plot.
name_appendix (string) – A string that is appended to the dataset of the pulse height estimation method. This is typically _downX if pulse height estimations were calculated with downsampling.
-
show_nps(channel=None, title=None, block=True, show=True, save_path=None, xran=None, yran=None, dpi=150)[source]¶ Plot the Noise Power Spectrum.
- Parameters
channel (int) – If chosen, only this channel is plotted.
title (string) – A title for the plot.
block (bool) – If False the matplotlib generated figure window does not block the futher code execution.
show (bool) – If set, the plots are shown.
save_path (string) – If set, the plots are save to this directory.
xran (tuple of two floats) – The range of the x axis.
yran (tuple of two floats) – The range of the y axis.
dpi (int) – The dots per inch of the plot.
-
show_of(channel=None, title=None, block=True, show=True, group_name_appendix='', save_path=None, down=None, xran=None, yran=None, dpi=150)[source]¶ Plot the Optimum Filter.
- Parameters
channel (int) – If chosen, only this channel is plotted.
title (string) – A title for the plot.
block (bool) – If False the matplotlib generated figure window does not block the futher code execution.
show (bool) – If set, the plots are shown.
group_name_appendix (string) – A string that is appended to the group name optimumfilter. Typically this is _tp in case we want to plot a test pulse standardevent.
save_path (string) – If set, the plots are save to this directory.
down (int) – The downsample factor of the optimum filter. This is appended to the name of the data sets in the Hdf5 set.
xran (tuple of two floats) – The range of the x axis.
yran (tuple of two floats) – The range of the y axis.
dpi (int) – The dots per inch of the plot.
-
show_saturation(show_fit=True, channel=0, marker='.', s=1, alpha=1, only_idx=None, title=None, block=False, show=True, save_path=None, dpi=150, method: str = 'ph', name_appendix_tp: str = '')[source]¶ Plot the testpulse amplitudes vs their pulse heights and the fitted logistic curve.
This method was used to describe the detector saturation in “M. Stahlberg, Probing low-mass dark matter with CRESST-III : data analysis and first results”, available via https://doi.org/10.34726/hss.2021.45935 (accessed on the 9.7.2021).
- Parameters
show_fit (bool) – If true show the fitted logistics curve.
channel – The channel for that we want to plot the saturation curve.
channel – int
marker (string) – The marker type from pyplots scatter plot.
s (int) – The size parameter of the scatter objects.
alpha (float) – The transparency factor of the scatter objects. Between 0 and 1.
only_idx (list of ints) – Only these indices are used in the fit of the saturation.
title (string) – A title for the plot.
block (bool) – If the plot blocks the code when executed in cmd.
show (bool) – If set, the plots are shown.
save_path (string) – If set, the plots are save to this directory.
dpi (int) – The dots per inch of the plot.
method (string) – Either ‘ph’ (main parameter pulse height), ‘of’ (optimum filter) or ‘sef’ (standard event fit). Test pulse heights and event heights are then estimated with this method.
name_appendix_tp (string) – This is appended to the test pulse height estimation method, e.g. ‘_down16’.
-
show_scatter(groups, keys, title=None, xlabel=None, ylabel=None, cut_flag=None, idx0s=[None, None], idx1s=[None, None], idx2s=[None, None], block=False, marker='.', xran=None, yran=None, show=True, save_path=None, dpi=150)[source]¶ Shows a scatter plot of some values from the HDF5 file
- Parameters
groups (list of string) – The group index that is used in the hdf5 file, typically either events, testpulses or noise; first list element applies to data on x, second to data on y axis.
keys (list of string) – The key index of the hdf5 file, typically mainpar, fit_rms, …; first list element applies to data on x, second to data on y axis.
title (string) – A title for the plot.
xlabel (string) – A label for the x axis.
ylabel (string) – A label for the y axis.
cut_flag (list of bools) – A booled array that decides which values are included in the histogram.
idx0s (list of int) – The first index of the array; first list element applies to data on x, second to data on y axis.
idx1s (list of int or None) – The second index of the array; first list element applies to data on x, second to data on y axis.
idx2s (list of int or None) – The third index of the array; first list element applies to data on x, second to data on y axis.
block (bool) – If the plot blocks the code when executed in cmd.
marker (string) – The marker type from pyplots scatter plot.
xran (tuple of two floats) – The range of the x axis.
yran (tuple of two floats) – The range of the y axis.
show (bool) – If set, the plots are shown.
save_path (string) – If set, the plots are save to this directory.
dpi (int) – The dots per inch of the plot.
-
show_sev(type='stdevent', channel=None, title=None, show_fit=True, block=True, sample_length=None, show=True, save_path=None, name_appendix='', dpi=150)[source]¶ Plot the standardevent of all channels.
- Parameters
type (string) – Either stdevent for events or stdevent_tp for testpulses.
channel (int) – If chosen, only this channel is plotted.
title (string) – A title for the plot.
show_fit (bool) – If True then also plot the parametric fit.
block (bool) – If False the matplotlib generated figure window does not block the futher code execution.
sample_length (float) – The length of a sample in milliseconds. If None, it is calcualted from the sample frequency.
show (bool) – If set, the plots are shown.
save_path (string) – If set, the plots are save to this directory.
name_appendix (string) – A string that is appended to the group name standardevent. Typically this is _tp in case we want to plot a test pulse standardevent.
dpi (int) – The dots per inch of the plot.
-
show_values(group, key, title=None, xlabel=None, ylabel=None, cut_flag=None, idx0=None, idx1=None, idx2=None, block=False, bins=100, range=None, show=True, xran=None, yran=None, save_path=None, dpi=150, scale='linear')[source]¶ Shows a histogram of some values from the HDF5 file
- Parameters
group (string) – The group index that is used in the hdf5 file, typically either events, testpulses or noise.
key (string) – The key index of the hdf5 file, typically mainpar, fit_rms, …; There are a few exceptional properties that are calculated from the main parameters and can be plotted: ‘pulse_height’, ‘onset’, ‘rise_time’, ‘decay_time’, ‘slope’.
title (string) – A title for the plot.
xlabel (string) – A label for the x axis.
ylabel (string) – A label for the y axis.
cut_flag (list of bools) – A booled array that decides which values are included in the histogram.
idx0 (int) – The first index of the array.
idx1 (int or None) – The second index of the array.
idx2 (int or None) – The third index of the array.
block (bool) – If the plot blocks the code when executed in cmd.
bins (int) – The number of bins for the histogram.
range (2D tuple of floats) – The interval that is shown in the histogram.
show (bool) – If set, the plots are shown.
xran (tuple of two floats) – The range of the x axis.
yran (tuple of two floats) – The range of the y axis.
save_path (string) – If set, the plots are save to this directory.
dpi (int) – The dots per inch of the plot.
scale (string) – Put ‘linear’ for non-log plot and ‘log’ for log plot.
-