bart.common.signal module

Signals

  • Definition

    A signal is a string representation of a TRAPpy event and the column in the same event. The signal can be of two types:

    • Pivoted Signal

      A pivoted signal has a pivot specified in its event class. This means that the signal in the event is a concatenation of different signals which belong to different pivot nodes. The analysis for pivoted signals must be done by decomposing them into pivoted signals for each node.

      For example, an even that represents the load of the CPU can be pivoted on "cpu" which should be a column in the event’s DataFrame

    • Non-Pivoted Signal

      A non pivoted signal has an event that has no pivot value associated with it. This probably means that signal has one component and can be analysed without decomposing it into smaller signals.

  • Representation

    The following are valid representations of a signal

    • "event_name:event_column"
    • "trappy.event.class:event_column"
class bart.common.signal.SignalCompare(data, sig_a, sig_b, **kwargs)[source]

Bases: object

Parameters:
  • data (trappy.ftrace.FTrace) – TRAPpy FTrace Object
  • sig_a (str) – The first signal
  • sig_b (str) – The first signal
  • config (dict) – A dictionary of variables, classes and functions that can be used in the statements
  • method (str) – The method to be used for reindexing data This can be one of the standard pandas.DataFrame methods (eg. pad, bfill, nearest). The default is pad or use the last valid observation.
  • limit (int) – The number of indices a value will be propagated when reindexing. The default is None
  • fill (bool) – Whether to fill the NaNs in the data. The default value is True.

Note

Both the signals must have the same pivots. For example:

  • Signal A has a pivot as "cpu" which means that the trappy event (trappy.base.Base) has a pivot parameter which is equal to "cpu". Then the signal B should also have "cpu" as it’s pivot.
  • Signal A and B can both have undefined or None as their pivots
conditional_compare(condition, **kwargs)[source]

Conditionally compare two signals

The conditional comparison of signals has two components:

  • Value Coefficient \(\alpha_{v}\) which measures the difference in values of of the two signals when the condition is true:

    \[\begin{split}\alpha_{v} = \frac{area\_under\_curve(S_A\ |\ C(t)\ is\ true)} {area\_under\_curve(S_B\ |\ C(t)\ is\ true)} \\\end{split}\]\[\alpha_{v} = \frac{\int S_A(\{t\ |\ C(t)\})dt}{\int S_B(\{t\ |\ C(t)\})dt}\]
  • Time Coefficient \(\alpha_{t}\) which measures the time during which the condition holds true.

    \[\alpha_{t} = \frac{T_{valid}}{T_{total}}\]
Parameters:
  • condition (str) –

    A condition that returns a truth value and obeys the grammar syntax

    "event_x:sig_a > event_x:sig_b"
    
  • method – The method for area calculation. This can be any of the integration methods supported in numpy or rect
  • step (str) – The step behaviour for area and time summation calculation

Consider the two signals A and B as follows:

A = [0, 0, 0, 3, 3, 0, 0, 0]
B = [0, 0, 2, 2, 2, 2, 1, 1]
                                     A = xxxx
3                 *xxxx*xxxx+        B = ----
                  |         |
2            *----*----*----+
             |    |         |
1            |    |         *----*----+
             |    |         |
0  *x-x-*x-x-+xxxx+         +xxxx*xxxx+
   0    1    2    3    4    5    6    7

The condition:

\[\begin{split}A > B\end{split}\]

is valid between T=3 and T=5. Therefore,

\[\begin{split}\alpha_v=1.5 \\ \alpha_t=\frac{2}{7}\end{split}\]
Returns:There are two cases:
  • Pivoted Signals
    {
        "pivot_name" : {
                "pval_1" : (v1,t1),
                "pval_2" : (v2, t2)
        }
    }
    
  • Non Pivoted Signals

    The tuple of \((\alpha_v, \alpha_t)\)

get_overshoot(**kwargs)[source]

Special case for conditional_compare() where the condition is:

"sig_a > sig_b"
Parameters:
  • method – The method for area calculation. This can be any of the integration methods supported in numpy or rect
  • step (str) – The step behaviour for calculation of area and time summation
get_undershoot(**kwargs)[source]

Special case for conditional_compare() where the condition is:

"sig_a < sig_b"
Parameters:
  • method – The method for area calculation. This can be any of the integration methods supported in numpy or rect
  • step (str) – The step behaviour for calculation of area and time summation