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

Sonification plugin tweaks #3377

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

james-trayford
Copy link

Description

This pull request develops the Sonification functionality further

  • flux_viewer.update_listener_wls now takes a sequence of ranges rather than a min and max, to allow for composite selections with appropriate @observe keyword for spectral subselection
  • Handle composite regions appropriately - this is now treated as a single patched-together spectrum over the wavelenth range, enabling more sound frequency resolution over disconnected spectral regions.
  • Update some of the Sonify plug-in hints etc in the .vue file.
  • Default Equal Loudness Normalisation to True
  • Default maximum audio frequency to 1000 Hz
  • hide sample rate options from users
  • continuum subtraction fix for sonification

Fixes #

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@github-actions github-actions bot added cubeviz plugin Label for plugins common to multiple configurations labels Jan 1, 2025
Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

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

I don't grok the algorithms but I left a general review. Hope this helps. Thanks.

@@ -3,7 +3,6 @@
import sys
import os
import time

Copy link
Contributor

Choose a reason for hiding this comment

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

No need to remove this blank line.

@@ -43,7 +42,7 @@ def sonify_spectrum(spec, duration, overlap=0.05, system='mono', srate=44100, fm
data = {'spectrum': [spec], 'pitch': [1]}

# again, use maximal range for the mapped parameters
lims = {'spectrum': ('0', '100')}
lims = {'spectrum': (0, '100')}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we mixing number and string in this tuple?

Copy link
Author

Choose a reason for hiding this comment

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

This is strauss syntax where strings are used for percentiles while numeric represents absolute values. In this case the maximum of the spectrum is the 100th %ile (i.e. max) in flux but using 0 flux for the minimum, rather than the 0th %ile in flux (min). I'll add a comment to clarify this

Copy link
Contributor

Choose a reason for hiding this comment

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

That is kinda confusing. Why not be more explicit in the string specs like '100%' or '100pct'?

Copy link
Author

Choose a reason for hiding this comment

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

I agree that could be an improvement - I will add accepting 'XX%' as a percentile format in the next batch of strauss changes - though would this be ok for now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Given the limitation, sure. The comment is helpful enough for now. Thanks!

jdaviz/configs/cubeviz/plugins/viewers.py Outdated Show resolved Hide resolved
jdaviz/configs/cubeviz/plugins/viewers.py Outdated Show resolved Hide resolved
@pllim pllim added this to the 4.2 milestone Jan 2, 2025
@pllim
Copy link
Contributor

pllim commented Jan 2, 2025

> flake8 jdaviz --count
jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py:42:24: E261 at least two spaces before inline comment
jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py:42:25: E262 inline comment should start with '# '
jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py:43:23: E261 at least two spaces before inline comment
jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py:43:24: E262 inline comment should start with '# '
jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py:78:1: W293 blank line contains whitespace
jdaviz/configs/cubeviz/plugins/viewers.py:145:13: F841 local variable 'wl_unit' is assigned to but never used
jdaviz/configs/cubeviz/plugins/viewers.py:[15](https://github.com/spacetelescope/jdaviz/actions/runs/12572669438/job/35083516394?pr=3377#step:5:16)0:38: E127 continuation line over-indented for visual indent
jdaviz/configs/cubeviz/plugins/viewers.py:151:38: E128 continuation line under-indented for visual indent
8

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 40.74074% with 16 lines in your changes missing coverage. Please review.

Project coverage is 88.10%. Comparing base (982bebb) to head (ff220be).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
jdaviz/configs/cubeviz/plugins/viewers.py 20.00% 8 Missing ⚠️
...configs/cubeviz/plugins/sonify_data/sonify_data.py 56.25% 7 Missing ⚠️
jdaviz/configs/cubeviz/plugins/cube_listener.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3377      +/-   ##
==========================================
- Coverage   88.13%   88.10%   -0.03%     
==========================================
  Files         127      127              
  Lines       19695    19738      +43     
==========================================
+ Hits        17358    17390      +32     
- Misses       2337     2348      +11     

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

CHANGES.rst Outdated Show resolved Hide resolved
Co-authored-by: P. L. Lim <[email protected]>
CHANGES.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@javerbukh javerbukh left a comment

Choose a reason for hiding this comment

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

I tried using a composite spectral subset and it seemed to work, although I will trust that you've tested that and confirmed it also. If that is the case then this is good to be merged! My only request (for either this PR or a follow up) is to use more descriptive variable names. The following names could be changed for clarities sake: lims, wl_unit, wl_bounds, wlens, eln, assidx, ssvidx, and pccut. Thanks again for getting composite subsets working!

Co-authored-by: Jesse Averbukh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubeviz plugin Label for plugins common to multiple configurations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants