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

Ignore nan spectrogram values #410

Merged
merged 7 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions gwsumm/data/coherence.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,13 @@
cxy, cxx, cyy = [_get_from_list(
globalv.COHERENCE_COMPONENTS[ck], seg) for ck in ckeys]
csg = abs(cxy)**2 / cxx / cyy
globalv.SPECTROGRAMS[key].append(csg)
globalv.SPECTROGRAMS[key].coalesce()
if not numpy.any(numpy.isnan(csg)):
globalv.SPECTROGRAMS[key].append(csg)
globalv.SPECTROGRAMS[key].coalesce()
else:
warnings.warn('NaN values found in the spectrogram.'

Check warning on line 293 in gwsumm/data/coherence.py

View check run for this annotation

Codecov / codecov/patch

gwsumm/data/coherence.py#L293

Added line #L293 was not covered by tests
' Spectrogram will not be appended to'
' global memory value')

if not return_:
return
Expand Down
17 changes: 11 additions & 6 deletions gwsumm/data/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,17 @@
def add_spectrogram(specgram, key=None, coalesce=True):
"""Add a `Spectrogram` to the global memory cache
"""
if key is None:
key = specgram.name or str(specgram.channel)
globalv.SPECTROGRAMS.setdefault(key, SpectrogramList())
globalv.SPECTROGRAMS[key].append(specgram)
if coalesce:
globalv.SPECTROGRAMS[key].coalesce()
if not numpy.any(numpy.isnan(specgram)):
if key is None:
key = specgram.name or str(specgram.channel)
globalv.SPECTROGRAMS.setdefault(key, SpectrogramList())
globalv.SPECTROGRAMS[key].append(specgram)
if coalesce:
globalv.SPECTROGRAMS[key].coalesce()
else:
warnings.warn('NaN values found in the spectrogram.'

Check warning on line 250 in gwsumm/data/spectral.py

View check run for this annotation

Codecov / codecov/patch

gwsumm/data/spectral.py#L250

Added line #L250 was not covered by tests
' Spectrogram will not be appended to'
' global memory value')


@use_segmentlist
Expand Down
Loading