pyecsca.sca.trace.match module

Provides functions for matching a pattern within a trace to it.

match_pattern(trace, pattern, threshold=0.8)[source]

Match a pattern to a trace.

Return the indices where the pattern matches, e.g. those where correlation of the two traces has peaks larger than threshold. Uses the scipy.signal.find_peaks() function.

Parameters:
  • trace (Trace) – The trace to match into.

  • pattern (Trace) – The pattern to match.

  • threshold (float) – The threshold passed to scipy.signal.find_peaks() as a prominence value.

Return type:

List[int]

Returns:

Indices where the pattern matches.

match_part(trace, offset, length, threshold=0.8)[source]

Match a part of a trace starting at offset of length to the trace.

Returns indices where the pattern matches, e.g. those where correlation of the two traces has peaks larger than threshold. Uses the scipy.signal.find_peaks() function.

Parameters:
  • trace (Trace) – The trace to match into.

  • offset (int) – The start of the pattern in the trace to match.

  • length (int) – The length of the pattern in the trace to match.

  • threshold (float) – The threshold passed to scipy.signal.find_peaks() as a prominence value.

Return type:

List[int]

Returns:

Indices where the part of the trace matches matches.