mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 10:03:32 +01:00
30 lines
656 B
Python
30 lines
656 B
Python
|
|
||
|
import numpy as np
|
||
|
|
||
|
from . import sampling as smp
|
||
|
|
||
|
class Sampler():
|
||
|
"""
|
||
|
A mechanism to sample signals.
|
||
|
"""
|
||
|
|
||
|
def __init__(self, sampling_frequency=None):
|
||
|
"""
|
||
|
Parameters
|
||
|
##########
|
||
|
sampling_frequency - float
|
||
|
Frequency the signals will be sampled at
|
||
|
"""
|
||
|
|
||
|
self.sampling_frequency = sampling_frequency
|
||
|
|
||
|
def sample(self, signal, signal_fs=None):
|
||
|
"""
|
||
|
Sample signal
|
||
|
"""
|
||
|
# Null operation
|
||
|
if signal_fs is None or self.sampling_frequency is None:
|
||
|
return signal
|
||
|
|
||
|
return smp.resample(signal, signal_fs, self.sampling_frequency)
|