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

Fix spectrum plots for different states #403

Merged
merged 7 commits into from Apr 5, 2024

Conversation

iaraota
Copy link
Collaborator

@iaraota iaraota commented Apr 3, 2024

This PR addresses a bug related to computing the spectrum for different states. Previously, the same spectrogram was being plotted for different states despite having different segments, due to a global variable storing spectrum data with identical keys for all states. This issue has been resolved by introducing the state argument to the get_spectrum and get_spectrum_range functions, using the state name as a key to differentiate spectrum data.

The original intention behind the removed snippet below

if isinstance(segments, DataQualityFlag):	
    name = ','.join([channel.ndsname, segments.name])
    segments = segments.active
else:
    name = channel.ndsname

was to incorporate the state into the name variable. However, this condition always failed because of the decorator use_segmentlist, which was already reseting segments = segments.active, therefore making it impossible to insert the state in the name variable. With the introduction of the state variable, this redundant condition has been removed.

Additionally, the range spectrogram also required fixing as it failed to change with the state. The code introduced mirrors that used in _get_spectrogram to ensure the correct data is returned.

Example:

@iaraota iaraota added the bug-fix label Apr 3, 2024
@iaraota iaraota requested a review from eagoetz April 3, 2024 21:24
@iaraota iaraota self-assigned this Apr 3, 2024
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 15.38462% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 49.56%. Comparing base (720bd0c) to head (8f6113b).
Report is 3 commits behind head on master.

Files Patch % Lines
gwsumm/data/range.py 0.00% 18 Missing ⚠️
gwsumm/data/spectral.py 66.67% 2 Missing ⚠️
gwsumm/plot/builtin.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #403      +/-   ##
==========================================
- Coverage   49.64%   49.56%   -0.08%     
==========================================
  Files          60       60              
  Lines        8823     8828       +5     
==========================================
- Hits         4380     4375       -5     
- Misses       4443     4453      +10     
Flag Coverage Δ
Linux 49.56% <15.38%> (-0.08%) ⬇️
macOS 49.56% <15.38%> (?)
python3.10 49.56% <15.38%> (-0.08%) ⬇️
python3.11 49.56% <15.38%> (-0.08%) ⬇️
python3.9 49.56% <15.38%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eagoetz eagoetz added this to the 2.2.4 milestone Apr 3, 2024
gwsumm/data/range.py Outdated Show resolved Hide resolved
gwsumm/data/range.py Outdated Show resolved Hide resolved
gwsumm/data/spectral.py Outdated Show resolved Hide resolved
gwsumm/data/spectral.py Outdated Show resolved Hide resolved
gwsumm/data/spectral.py Outdated Show resolved Hide resolved
@eagoetz
Copy link
Collaborator

eagoetz commented Apr 4, 2024

@iaraota Thanks for finding the source of this bug! I think that we also need to fix the spectrograms, correct? For example, check out quiet and noisy state spectrograms here: https://ldas-jobs.ligo.caltech.edu/~detchar/summary/day/20240101/sei/bs/

Co-authored-by: Evan Goetz <32753745+eagoetz@users.noreply.github.com>
@iaraota
Copy link
Collaborator Author

iaraota commented Apr 4, 2024

@iaraota Thanks for finding the source of this bug! I think that we also need to fix the spectrograms, correct? For example, check out quiet and noisy state spectrograms here: https://ldas-jobs.ligo.caltech.edu/~detchar/summary/day/20240101/sei/bs/

I didn't realize that, as the spectrogram for the strain works fine. I will have a look, thank you!

@iaraota
Copy link
Collaborator Author

iaraota commented Apr 5, 2024

@eagoetz I was looking into the problem of quiet and noise spectrograms and it seem to me that the problem is having a different definition for H1 and L1, in the configuration file we have:

[state-Quiet]
key = Quiet
name = SEI Quiet

[state-H1-Quiet]
name = SEI Quiet
key = H1-quiet
hours = 1-5,H1

[state-L1-Quiet]
name = SEI Quiet
key = L1-quiet
hours = 2-6,L1

And this page uses the state Quiet and intersect the options for L1 and H1, and that is causing the problem. For example, when using the state H1-quiet/noisy, the issue doesn't arise: https://ldas-jobs.ligo.caltech.edu/~iara.ota/summary/day/20240404/sei/bs

Thus, the issue does not lie within the get_spectrogram function, but rather in how the states are generated, considering the discrepancies between the two sites. In my view, this problem falls outside the scope of this PR and should be addressed separately in another PR.

@eagoetz
Copy link
Collaborator

eagoetz commented Apr 5, 2024

@iaraota Yeah, I had a feeling it was more complicated, but at least we have some fixes for the spectra. Let's go ahead with this PR and continue working on the spectrogram issue in another PR

Copy link
Collaborator

@eagoetz eagoetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @iaraota! LGTM

@eagoetz eagoetz merged commit 5f9110e into gwpy:master Apr 5, 2024
9 of 10 checks passed
@iaraota iaraota deleted the fix_spectrum_states branch April 23, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants