Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: signal: add an example cross-spectrogram application #20622

Open
sancholp opened this issue May 1, 2024 · 4 comments · May be fixed by #20610
Open

DOC: signal: add an example cross-spectrogram application #20622

sancholp opened this issue May 1, 2024 · 4 comments · May be fixed by #20610
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.signal

Comments

@sancholp
Copy link

sancholp commented May 1, 2024

Is your feature request related to a problem? Please describe.

There is functionality for calculating the stft or the spectrogram (Sxx=Zxx**2) of a signal, but there is no functionality to do a similar process to analyze the temporal correlations of two signals. A function plotting some kind of "csd spectrogram" Zxy would be useful. Similarly, a "coherence spectrogram" Sxy analogous to the spectrogram function.

Describe the solution you'd like.

The function scipy.stats.stft calls _spectral_helper(x, x, ...). In other words, it calculates the spectral density of x(f)x*(f). To get the csd one would need to call _spectral_helper(x, y, ...) and calculate x(f)y*(f). (See wikipedia).

Describe alternatives you've considered.

The package GWpy, designed for data analysis in gravitational wave astronomy, already has such functionality. See docs of csd_spectrogram and coherence_spectrogram.

Additional context (e.g. screenshots, GIFs)

No response

@sancholp sancholp added the enhancement A new feature or improvement label May 1, 2024
@lucascolley
Copy link
Member

cc @DietBru

@DietBru
Copy link
Contributor

DietBru commented May 1, 2024

SciPy 1.12 introduced a new ShortTimeFFT.spectrogram() method, which also provides cross-spectrogram functionality.

@sancholp, do you happen to know of an application for a cross-spectrogram, which would easy to explain in a few words? It would be nice to have a cross-spectrogram example in the ShortTimeFFT.spectrogram() documentation.

@sancholp
Copy link
Author

sancholp commented May 2, 2024

Two signals x and y might be correlated (coherent) only in certain times and certain frequencies. With such a spectrogram it is easy to see where and when these signals are correlated.

@lucascolley lucascolley changed the title ENH: Add csd/coherence spectrogram functionality DOC: signal: add an example cross-spectrogram application May 2, 2024
@lucascolley lucascolley added enhancement A new feature or improvement Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org and removed enhancement A new feature or improvement labels May 2, 2024
@DietBru
Copy link
Contributor

DietBru commented May 5, 2024

Added an appropriate example in PR #20610­ -- reviews and comments are always welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.signal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants