spin_pulse.environment.noise.pink¶
Classes¶
Generate a pink noise time trace with a 1/f power spectral density. |
Functions¶
|
Generate a single segment of pink noise using an inverse FFT method. |
|
Generate pink noise of a given total duration by repeating segments. |
Module Contents¶
- spin_pulse.environment.noise.pink.get_pink_noise(segment_duration, seed=None, *, noise_directory=None)[source]¶
Generate a single segment of pink noise using an inverse FFT method.
The generated sequence has length
segment_durationand follows a spectral density proportional to1/freq.This implementation is adapted from the Matlab implementation of the algorithm described in [Little2007].
References
[Little2007] M. A. Little, P. E. McSharry, S. J. Roberts, D. A. E. Costello, and I. M. Moroz, “Exploiting nonlinear recurrence and fractal scaling properties for voice disorder detection”, BioMedical Engineering OnLine, 6:23 (2007).
- Parameters:
segment_duration (int) – Number of time points in the generated pink noise segment.
seed (int | None) – Optional seed for reproducible random number generation.
noise_directory (str | os.PathLike | None) – Existing directory on a disk filesystem for temporary arrays. If supplied, return a float64 memmap; otherwise return an in-memory array. Files live as long as the arrays and their views. Avoid tmpfs when the goal is to reduce RAM usage.
- Returns:
- Array of length
segment_durationcontaining a realization of pink noise.
- Array of length
- Return type:
ndarray
- Raises:
ValueError – If
segment_durationis odd.
- spin_pulse.environment.noise.pink.get_pink_noise_with_repetitions(duration, segment_duration, seed=None, *, noise_directory=None)[source]¶
Generate pink noise of a given total duration by repeating segments.
A base pink noise segment of length
segment_durationis generated repeatedly and concatenated until the total length reachesduration. A low frequency cutoff of1/segment_durationis implicitly imposed.- Parameters:
duration (int) – Total number of time points in the final noise trace.
segment_duration (int) – Length of each repeated pink noise segment.
seed (int | None) – Optional seed for reproducible random number generation.
noise_directory (str | os.PathLike | None) – Optional disk directory, as in
get_pink_noise.
- Returns:
Pink noise trace of length
duration.- Return type:
ndarray
- class spin_pulse.environment.noise.pink.PinkNoiseTimeTrace(T2S, duration, segment_duration, seed=None, *, noise_directory=None)[source]¶
Bases:
spin_pulse.environment.noise.noise_time_trace.NoiseTimeTraceGenerate a pink noise time trace with a 1/f power spectral density.
This class constructs a noise trace of length
durationwhere the spectral density follows a pink noise distribution proportional to1/f. A low-frequency cutoff is enforced at1/segment_durationby building the trace from repeated pink noise segments. The parameterT2Sdetermines the noise intensity through the scaling factorS0defined as:S0 = 1 / (4 * pi^2 * log(segment_duration) * T2S^2)
The internal array
valuescontains the generated noise samples and is used by methods such asramsey_contrastto evaluate the effect of pink noise on qubit coherence.- - segment_duration
Length of each pink noise segment.
- Type:
- - S0
Scaling factor controlling the noise intensity.
- Type:
- - T2S
Coherence time parameter determining the noise intensity.
- Type:
- - sigma
Standard deviation of the generated noise values.
- Type:
- - values
Noise values of length
duration.- Type:
ndarray
Create a pink noise time trace for spin qubit simulations.
The generated noise satisfies a spectral density proportional to
1/(f*ts)with a low frequency cutofff_min=1/segment_duration. The parameterT2Ssets the noise intensity through the relationS0 = 1 / (4 * pi^2 * log(segment_duration) * T2S^2). The internal noise trace has lengthdurationand is constructed by repeating pink noise segments.- Parameters:
T2S (float) – Coherence time parameter determining the noise intensity.
duration (int) – Total number of time steps in the noise trace.
segment_duration (int) – Length of each pink noise segment.
seed (int | None) – Optional seed for reproducible random number generation.
noise_directory (str | os.PathLike | None) – Optional disk directory for temporary trace and FFT arrays.
valuesremains a NumPy array (a memmap).
- Returns:
The time trace is stored internally in
self.values.- Return type:
None
- plot_ramsey_contrast(ramsey_duration)[source]¶
Plot analytical and numerical Ramsey contrast curves.
- This method overlays:
the analytical Gaussian contrast expected for pink noise,
a corrected analytical contrast that accounts for the frequency cutoff imposed by
segment_duration,the numerical contrast obtained from the underlying noise trace.
- Parameters:
ramsey_duration (int) – Number of time steps used in the Ramsey experiment evaluation.
- Returns:
The function produces a plot of the Ramsey contrast.
- Return type:
None