File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
docs/examples_tutorial/e00_intro_set
quantum_inferno/utilities Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 94
94
time_spect_s = time_spect_s - time_spect_s [0 ]
95
95
96
96
# Compute the spectrogram with the stft option
97
- frequency_stft_hz , time_stft_s , stft_complex = stft .stft_tukey (
98
- timeseries = mic_sig ,
97
+ stft_obj = stft .get_stft_object_tukey (
99
98
sample_rate_hz = frequency_sample_rate_hz ,
100
99
tukey_alpha = alpha ,
101
100
segment_length = time_fft_nd ,
102
101
overlap_length = time_fft_nd // 2 , # 50% overlap
103
102
scaling = "magnitude" ,
104
- padding = "zeros" ,
105
103
)
104
+ stft_complex = stft_obj .stft (mic_sig , padding = "zeros" )
105
+
106
+ stft_magnitude = np .abs (stft_obj .stft_detrend (x = mic_sig , detr = "constant" , padding = "zeros" ))
107
+ # calculate the time and frequency bins
108
+ time_stft_s = np .arange (start = 0 , stop = stft_obj .delta_t * np .shape (stft_magnitude )[1 ], step = stft_obj .delta_t )
109
+ frequency_stft_hz = stft_obj .f
110
+
111
+ # frequency_stft_hz, time_stft_s, stft_complex = stft.stft_tukey(
112
+ # timeseries=mic_sig,
113
+ # padding="zeros",
114
+ # )
106
115
# Since one-sided, multiply by 2 to get the full power
107
116
stft_power = 2 * np .abs (stft_complex ) ** 2
108
117
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ def get_stft_object_tukey(
60
60
return stft_obj
61
61
62
62
63
+ #todo: check for ways to return the stft object instead of the magnitude and rewrite calls to the function
63
64
def stft_tukey (
64
65
timeseries : np .ndarray ,
65
66
sample_rate_hz : Union [float , int ],
@@ -72,6 +73,7 @@ def stft_tukey(
72
73
"""
73
74
Calculate the Short-Time Fourier Transform (STFT) of a signal with a Tukey window using ShortTimeFFT class
74
75
Returns the frequency, time bins, and magnitude of the STFT similar to legacy scipy.signal.stft
76
+ NOTE: the stft_detrend method used to get the magnitude makes it unable to be inverted using istft_tukey
75
77
76
78
:param timeseries: input signal
77
79
:param sample_rate_hz: sample rate of the signal
You can’t perform that action at this time.
0 commit comments