Skip to content
Snippets Groups Projects
Verified Commit dab9d1e8 authored by Tobias Hangleiter's avatar Tobias Hangleiter
Browse files

Add MonochromaticNoise

Useful for comparing window functions
parent 5c895236
Branches
Tags
1 merge request!66Extend simulator module
......@@ -47,6 +47,24 @@ except ImportError as e:
"'pip install qopt.'") from e
class MonochromaticNoise(DAQ):
def acquire(self, *, n_avg: int, fs: float, n_pts: int, delay: bool | float = False,
A: float = 1, f_0: float = 50, **settings) -> AcquisitionGenerator[DAQ.DTYPE]:
if delay is True:
delay = 1 / settings['df']
t = np.arange(0, n_pts / fs, 1 / fs)
rng = np.random.default_rng()
for _ in range(n_avg):
tic = time.perf_counter()
data = np.sin(2 * np.pi * (t * f_0 + rng.random()))
if delay:
time.sleep(delay - (time.perf_counter() - tic))
yield data
@dataclasses.dataclass
class QoptColoredNoise(DAQ):
"""Simulates noise using :mod:`qopt:qopt`.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment