cait.features

class cait.features.MainParameters(pulse_height=0, t_zero=0, t_rise=0, t_max=0, t_decaystart=0, t_half=0, t_end=0, offset=0, linear_drift=0, quadratic_drift=0)[source]

Bases: object

Class to contain the main parameters.

Parameters
  • pulse_height – float, the height of the event

  • t_zero – int, the sample index where the rise starts

  • t_rise – int, the sample index where the rise reaches 80%

  • t_max – int, the sample index of the max event

  • t_decaystart – int, the sample index where the peak falls down to 90%

  • t_half – int, the sample index where the peak falls down to 73%

  • t_end – int, the sample index where the peak falls down to 36%

  • offset – float, the mean of the first 1/8 of the record length

  • linear_drift – float, the linear slope of the event baseline

  • quadratic_drift – float, the quadratic slope of the event baseline

compare(other)[source]

Method to compare the main parameters with those of another instance.

Parameters

other – the other instance of main parameters

Returns

bool, states if the main parameters are the same

getArray()[source]

Returns an array with the main parameters that are stored

Returns

1D array length 10, the main parameters

get_differences()[source]

Return the differences in the samples times

Returns

1D array with length 2: (length_rise, length_peak, length_decay)

plotParameters(down=1, offset_in_samples=0, color='r', zorder=10, fig=None)[source]

Plots the main parameters on overlaid to an event

Parameters
  • down – int, the downsample rate of the event that should be overlaid

  • offset_in_samples – int, set if the x axis does not start at zero

  • color – string, the color of the main parameters in the scatter plot

  • zorder – int, the plot with the highest zorder is plot on top of the others this should be choosen high, such that the main parameters are visible

  • fig – object, the pyplot figure to which we want to plot the parameters

print_all()[source]

Method to print all the stored main parameters

cait.features.calc_additional_parameters(event, optimal_transfer_function, down=1)[source]

Calculate parameters additionally to the main parameters

Parameters
  • event – array, the event of which we want to calculate the additional main parameters

  • optimal_transfer_function – array, the optimum filter transfer function; if None, the of values are filled with zeros instead

  • down – int, if we want to downsample the event by a factor, this can be done here

Returns

List of float values parameters (maximum of array, minimum of array, variance of first 1/8 or array, mean of first 1/8 or array, variance of last 1/8 or array, mean of last 1/8 or array, variance of whole array, mean of whole array, skewness of whole array, maximum of the derivative of the array, index of maximum of the derivative of the array, minimum of the derivative of the array, index of minimum of the derivative of the array, maximum of the filtered array, index of the maximum of the filtered array, distribution skewness of the filtered samples around the max of filtered array)

cait.features.calc_correlated_ph(events, dominant_channel=0, offset_to_dominant_channel=None, max_search_range=50)[source]

Calculate the correlated pulse heights of the channels.

Parameters
  • events (2D array of shape (nmbr_channels, record_length)) – The events of all channels.

  • dominant_channel (int) – Which channel is the one for the primary max search.

  • offset_to_dominant_channel (list of ints) – The expected offsets of the peaks of pulses to the pesk of the dominant channel.

  • max_search_range (int) – The number of samples that are included in the search range of the maximum search in the non-dominant channels.

Returns

The evaluated pulse heights.

Return type

numpy array of shape (nmbr_channels)

cait.features.calc_main_parameters(event, down=1, max_bounds=None, quad_drift=False)[source]

Calculates the Main Parameters for an Event. Optional, the event can be downsampled by a given factor befor the calculation

Parameters
  • event – 1D array, the event

  • down – integer, power of 2, the factor for downsampling

  • max_bounds – tuple, the lower and upper index of the interval within which the maximum is searched

  • quad_drift – bool, include quadratic drift in the calculation

Returns

instance of MainParameters, see MainParameters

cait.features.distribution_skewness(density)[source]

Calculate the skewness of a distribution, given the density as array

Parameters

density – 1D array, the density of the distribution we want the skewness from

Returns

float, the skewness of the given distribution

cait.features.expectation(x, dist)[source]

Calculate the expectation value of a random value function

Parameters
  • x – 1D array, the function of the random vaiable, applied to the x value array

  • dist – 1D array of same length as the other array, the values of the distribution

cait.features.get_elements(this_event, std_thres, verb=False)[source]

Calculate the projection to S1 with algorithm for automatic refinement, depending on given standard deviation threshold.

Parameters
  • this_event – The event to project on S1.

  • this_event – 1D array

  • std_thres – The threshold for the standard deviation of the deviation proj-true.

  • std_thres – float

  • verb – If true give verbal feedback about the progress.

  • verb – bool

Returns

The elements of the grid of the S1 projection.

Returns

list of 2-tuples of lists

cait.features.plot_S1(this_event, elements, color='r', xlim=None, offset=0)[source]

Plot the function projected to S1 elements, i.e. piecewise affine.

Parameters
  • this_event (1D array) – The event that we project on S1.

  • elements (List of 2-tuples or lists) – The elements of the grid.

  • color – The color in which we plot the refinement.

  • color – string