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
8dd22fab
Verified
Commit
8dd22fab
authored
2 months ago
by
Tobias Hangleiter
Browse files
Options
Downloads
Patches
Plain Diff
Add some doc courtesy of Claude
parent
dab9d1e8
No related branches found
No related tags found
1 merge request
!66
Extend simulator module
Pipeline
#1639640
waiting for manual action
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python_spectrometer/daq/simulator.py
+51
-2
51 additions, 2 deletions
src/python_spectrometer/daq/simulator.py
with
51 additions
and
2 deletions
src/python_spectrometer/daq/simulator.py
+
51
−
2
View file @
8dd22fab
...
...
@@ -48,8 +48,17 @@ except ImportError as e:
class
MonochromaticNoise
(
DAQ
):
"""
Generate monochromatic sinusoidal noise with random phase.
This DAQ implementation produces sinusoidal data with a fixed frequency
but random phase for each acquisition, simulating a simple signal with noise.
Inherits from the base DAQ class and implements the required acquire method.
"""
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
]:
"""
Generate sinusoidal data with random phase.
"""
if
delay
is
True
:
delay
=
1
/
settings
[
'
df
'
]
...
...
@@ -74,11 +83,16 @@ class QoptColoredNoise(DAQ):
:class:`~python_spectrometer.daq.settings.DAQSettings`
for more information on setup parameters.
Attributes
----------
spectral_density : Callable[[NDArray, ...], NDArray]
A function that generates the power spectral density for given frequencies.
Defaults to white noise with scale parameter ``S_0``.
See Also
--------
:func:`qopt:qopt.noise.fast_colored_noise`
For information on the simulation.
"""
spectral_density
:
Callable
[[
NDArray
,
...],
NDArray
]
=
dataclasses
.
field
(
default_factory
=
lambda
:
QoptColoredNoise
.
white_noise
...
...
@@ -126,10 +140,41 @@ class QoptColoredNoise(DAQ):
class
DemodulatorQoptColoredNoise
(
QoptColoredNoise
):
"""
Simulates demodulated noisy data for lock-in measurements.
Extends QoptColoredNoise to demodulate the simulated signal using complex
IQ-demodulation, similar to a lock-in amplifier. This provides a realistic
simulation of demodulated signals as would be measured in experiments
using lock-in amplification techniques.
Attributes
----------
DTYPE : numpy.dtype
Specifies complex floating-point type for returned data
"""
DTYPE
=
np
.
complexfloating
@staticmethod
def
demodulate
(
signal
:
np
.
ndarray
,
IQ
:
np
.
ndarray
,
**
settings
):
def
demodulate
(
signal
:
np
.
ndarray
,
IQ
:
np
.
ndarray
,
**
settings
)
->
np
.
ndarray
:
"""
Demodulate signal using the provided IQ reference.
Performs complex demodulation by multiplying the signal with the IQ reference
and applying an RC filter. Removes high-pass filtering by ignoring f_min.
Parameters
----------
signal : numpy.ndarray
Input signal to demodulate
IQ : numpy.ndarray
Complex IQ reference for demodulation
**settings : dict
Settings for RC filter, including filter parameters
Returns
-------
numpy.ndarray
Filtered, demodulated signal
"""
# Don't highpass filter
settings
=
copy
.
deepcopy
(
settings
)
settings
.
pop
(
'
f_min
'
,
None
)
...
...
@@ -141,6 +186,10 @@ class DemodulatorQoptColoredNoise(QoptColoredNoise):
**
settings
)
->
AcquisitionGenerator
[
DTYPE
]:
r
"""
Simulate demodulated noisy data.
Generates simulated data and performs IQ demodulation, mimicking
the behavior of a lock-in amplifier. Can simulate either just input noise
or noise in the full signal path.
See Ref. [1]_ for an introduction to Lock-in amplification.
Parameters
...
...
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