Sampler
__init__(fs=128000, Rb=400, t=None, delay=0.08)
Initializes the sampler, used for sampling and quantizing the received signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fs
|
int
|
Sampling frequency. |
128000
|
delay
|
float
|
Sampling delay, in seconds. |
0.08
|
Rb
|
int
|
Bit rate. |
400
|
t
|
ndarray
|
Time vector. |
None
|
Examples:
>>> import argos3
>>> import numpy as np
>>>
>>> fs = 128000
>>> t = np.arange(10000) / fs
>>>
>>> signal1 = np.cos(2 * np.pi * 1000 * t)
>>> signal2 = np.cos(2 * np.pi * 4000 * t)
>>>
>>> signal = signal1 + signal2
>>>
>>> sampler = argos3.Sampler(t=t)
>>>
>>> signal_sampled = sampler.sample(signal)
>>> t_indexes = sampler.sample(t)
- Time Domain:
- Symbols Stream Plot Example:
calc_indexes(t)
Calculates the sampling indexes \(I[n]\) based on the time vector \(t\). The sampling indexes vector \(I[n]\) is given by the expression below.
\[
\begin{align}
I[n] = \tau + n \cdot \left( \frac{f_s}{R_b}\right) \text{ , where: } \quad I[n] < \text{len}(t)
\end{align}
\]
Where
- \(\tau\): Sampling delay.
- \(f_s\): Sampling frequency.
- \(R_b\): Bit rate.
- \(n\): Sample index.
- \(\text{len}(t)\): Length of the time vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
ndarray
|
Time vector. |
required |
Returns:
Name | Type | Description |
---|---|---|
indexes |
ndarray
|
Sampling indexes \(I[n]\). |
sample(signal)
Samples the signal \(s(t)\) based on the sampling indexes \(I[n]\).
\[
s(t) \rightarrow s([I[n]) \rightarrow s[n]
\]
Where
- \(s(t)\): Input signal \(s(t)\).
- \(s[n]\) Sampled signal \(s[n]\).
- \(I[n]\) Sampling indexes \(I[n]\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signal
|
ndarray
|
Input signal \(s(t)\) to be sampled. |
required |
Returns:
Name | Type | Description |
---|---|---|
sampled_signal |
ndarray
|
Sampled signal \(s[n]\). |
quantize(signal)
Quantizes the signal \(s[n]\) into discrete values. The quantization process is given by the expression below.
\[
\begin{align}
s'[n] = \begin{cases}
+1 & \text{if } s[n] \geq 0 \\
-1 & \text{if } s[n] < 0
\end{cases}
\end{align}
\]
Where
- \(s[n]\) Sampled signal \(s[n]\).
- \(s'[n]\) Quantized signal \(s'[n]\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signal
|
ndarray
|
Sampled signal \(s[n]\). |
required |
Returns:
Name | Type | Description |
---|---|---|
symbols |
ndarray
|
Quantized signal \(s'[n]\). |