diff options
| author | J08nY | 2018-12-11 21:24:35 +0100 |
|---|---|---|
| committer | J08nY | 2019-03-21 11:00:14 +0100 |
| commit | 0c740f412626f33f08d6bb9857f0c5619b9ea79c (patch) | |
| tree | c2313faaf8bc878d3d72acf2fd7c830b9512a529 /pyecsca/sampling.py | |
| parent | cbeca585d5787e8cab35fb5207339e7b22eab382 (diff) | |
| download | pyecsca-0c740f412626f33f08d6bb9857f0c5619b9ea79c.tar.gz pyecsca-0c740f412626f33f08d6bb9857f0c5619b9ea79c.tar.zst pyecsca-0c740f412626f33f08d6bb9857f0c5619b9ea79c.zip | |
Diffstat (limited to 'pyecsca/sampling.py')
| -rw-r--r-- | pyecsca/sampling.py | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/pyecsca/sampling.py b/pyecsca/sampling.py deleted file mode 100644 index 29dc251..0000000 --- a/pyecsca/sampling.py +++ /dev/null @@ -1,48 +0,0 @@ -import numpy as np -from copy import copy -from public import public -from scipy.signal import decimate - -from .trace import Trace - - -@public -def downsample_average(trace: Trace, factor: int = 2) -> Trace: - """ - Downsample samples of `trace` by `factor` by averaging `factor` consecutive samples in - non-intersecting windows. - - :param trace: - :param factor: - :return: - """ - resized = np.resize(trace.samples, len(trace.samples) - (len(trace.samples) % factor)) - result_samples = resized.reshape(-1, factor).mean(axis=1).astype(trace.samples.dtype) - return Trace(copy(trace.title), copy(trace.data), result_samples) - - -@public -def downsample_pick(trace: Trace, factor: int = 2, offset: int = 0) -> Trace: - """ - Downsample samples of `trace` by `factor` by picking each `factor`-th sample, starting at `offset`. - - :param trace: - :param factor: - :param offset: - :return: - """ - result_samples = trace.samples[offset::factor].copy() - return Trace(copy(trace.title), copy(trace.data), result_samples) - - -@public -def downsample_decimate(trace: Trace, factor: int = 2) -> Trace: - """ - Downsample samples of `trace` by `factor` by decimating. - - :param trace: - :param factor: - :return: - """ - result_samples = decimate(trace.samples, factor) - return Trace(copy(trace.title), copy(trace.data), result_samples) |
