mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2025-05-17 21:39:23 +02:00
Simu: Antenna encapsulate a Digitizer
This commit is contained in:
parent
aa959f4b3d
commit
ab20db4ffe
2 changed files with 65 additions and 13 deletions
|
@ -1,4 +1,5 @@
|
|||
import numpy as np
|
||||
from functools import wraps
|
||||
|
||||
from . import sampling as smp
|
||||
from .sampler import Sampler
|
||||
|
@ -8,7 +9,7 @@ class Digitizer(Sampler):
|
|||
Digitizer that takes in a signal and resamples and quantises the signal.
|
||||
"""
|
||||
|
||||
def __init__(self, resolution=0.1, sampling_frequency=None):
|
||||
def __init__(self, resolution=0.1, bias=0, sampling_frequency=None):
|
||||
"""
|
||||
|
||||
Parameters
|
||||
|
@ -21,6 +22,7 @@ class Digitizer(Sampler):
|
|||
super().__init__(sampling_frequency)
|
||||
|
||||
self.resolution = resolution
|
||||
self.bias = bias
|
||||
|
||||
def digitise(self, signal, signal_sample_frequency=None):
|
||||
"""
|
||||
|
@ -28,9 +30,23 @@ class Digitizer(Sampler):
|
|||
|
||||
Effectively resamples signal
|
||||
"""
|
||||
signal = np.asarray(signal)
|
||||
|
||||
return smp.quantise(
|
||||
self.sample(signal, signal_sample_frequency),
|
||||
self.resolution
|
||||
)
|
||||
if callable(signal):
|
||||
@wraps(signal)
|
||||
def func(*args, **kwargs):
|
||||
return smp.quantise(
|
||||
self.sample(signal(*args, **kwargs), signal_sample_frequency),
|
||||
self.resolution,
|
||||
self.bias
|
||||
)
|
||||
|
||||
return func
|
||||
|
||||
else:
|
||||
signal = np.asarray(signal)
|
||||
|
||||
return smp.quantise(
|
||||
self.sample(signal, signal_sample_frequency),
|
||||
self.resolution,
|
||||
self.bias
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue