Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-spectrometer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
qutech
python-spectrometer
Commits
766a7ffd
Verified
Commit
766a7ffd
authored
2 months ago
by
Tobias Hangleiter
Browse files
Options
Downloads
Patches
Plain Diff
Add DemodulatorQoptColoredNoise
parent
cfa2bfa9
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!66
Extend simulator module
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python_spectrometer/daq/simulator.py
+76
-1
76 additions, 1 deletion
src/python_spectrometer/daq/simulator.py
with
76 additions
and
1 deletion
src/python_spectrometer/daq/simulator.py
+
76
−
1
View file @
766a7ffd
...
...
@@ -17,13 +17,17 @@ Add an artificial time delay to mimick finite data acquisition time:
"""
from
__future__
import
annotations
import
copy
import
dataclasses
import
sys
import
time
from
typing
import
Callable
from
collections.abc
import
Callable
from
typing
import
Literal
import
numpy
as
np
from
qutil.functools
import
partial
from
qutil.math
import
cexp
from
qutil.signal_processing
import
real_space
from
.base
import
DAQ
,
AcquisitionGenerator
...
...
@@ -103,6 +107,77 @@ class QoptColoredNoise(DAQ):
return
{
'
qopt version
'
:
qopt
.
__version__
}
class
DemodulatorQoptColoredNoise
(
QoptColoredNoise
):
DTYPE
=
np
.
complexfloating
@staticmethod
def
demodulate
(
signal
:
np
.
ndarray
,
IQ
:
np
.
ndarray
,
**
settings
):
# Don't highpass filter
settings
=
copy
.
deepcopy
(
settings
)
settings
.
pop
(
'
f_min
'
,
None
)
return
real_space
.
RC_filter
(
signal
*
IQ
,
**
settings
)
def
acquire
(
self
,
*
,
n_avg
:
int
,
freq
:
float
=
0
,
filter_order
:
int
=
1
,
delay
:
bool
|
float
=
False
,
modulate_signal
:
bool
=
False
,
filter_method
:
Literal
[
'
forward
'
,
'
forward-backward
'
]
=
'
forward
'
,
**
settings
)
->
AcquisitionGenerator
[
DTYPE
]:
r
"""
Simulate demodulated noisy data.
See Ref. [1]_ for an introduction to Lock-in amplification.
Parameters
----------
n_avg : int
Number of outer averages.
freq : float, optional
Modulation frequency.
filter_order : int, optional
RC filter order used to filter the demodulated signal.
delay : bool | float, optional
Simulate a realistic data acquisition duration.
modulate_signal : bool, optional
Add the simulated noise to the modulation signal to mimic
noise picked up by a Lock-In signal travelling through some
DUT. Otherwise, mimics the noise at the input of the
amplifier.
In other words, simulate a Lock-In output connected to an
input, or just simulate the input.
Note that if True, noise is assumed to be additive, that
is,
.. math::
x(t) = s(t) + \delta(t)
with $s(t)$ the output signal and $\delta(t)$ the noise.
filter_method :
See :func:`~qutil:qutil.signal_processing.real_space.RC_filter`.
Yields
------
data :
Demodulated data in complex IQ-representation.
References
----------
.. [1]: https://www.zhinst.com/europe/en/resources/principles-of-lock-in-detection
"""
t
=
np
.
arange
(
0
,
settings
[
'
n_pts
'
]
/
settings
[
'
fs
'
],
1
/
settings
[
'
fs
'
])
# demodulation by √2 exp(-iωt) (ZI convention)
IQ
=
np
.
sqrt
(
2
)
*
cexp
(
-
2
*
np
.
pi
*
freq
*
t
)
yield
from
(
self
.
demodulate
(
IQ
.
real
+
data
if
modulate_signal
else
data
,
IQ
,
order
=
filter_order
,
method
=
filter_method
,
**
settings
)
for
data
in
super
().
acquire
(
n_avg
=
n_avg
,
delay
=
delay
,
**
settings
)
)
return
{
'
qopt version
'
:
qopt
.
__version__
}
@deprecated
(
"
Use QoptColoredNoise instead
"
)
class
qopt_colored_noise
(
QoptColoredNoise
):
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment