-
Notifications
You must be signed in to change notification settings - Fork 385
Adding Audification code #5340
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
Open
Inorinnnnnn
wants to merge
13
commits into
gwastro:master
Choose a base branch
from
Inorinnnnnn:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+65
−0
Open
Adding Audification code #5340
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
99275a9
Adding Audification code
Inorinnnnnn 3a216a3
Update bin/plotting/pycbc_page_audio
GarethCabournDavies 22db059
Update bin/plotting/pycbc_page_audio
GarethCabournDavies 31ad30c
Update bin/plotting/pycbc_page_audio
GarethCabournDavies a992064
Update bin/plotting/pycbc_page_audio
GarethCabournDavies 007f04e
Update bin/plotting/pycbc_page_audio
GarethCabournDavies 167d4ce
Update bin/plotting/pycbc_page_audio
GarethCabournDavies 12ec0c3
Update bin/plotting/pycbc_page_audio
GarethCabournDavies 32569e5
Update bin/plotting/pycbc_page_audio
GarethCabournDavies 7675de6
Update bin/plotting/pycbc_page_audio
GarethCabournDavies d392537
Update bin/plotting/pycbc_page_audio
GarethCabournDavies b3a9627
Fix mixed use of args and opts
GarethCabournDavies c5ee689
Ruff Formatting
GarethCabournDavies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Copyright (C) 2026 Syazwan Yusuf | ||
| """ | ||
| Convert single-detector gravitational-wave strain data to an audio file | ||
| """ | ||
|
|
||
| import argparse | ||
| import logging | ||
|
|
||
| import pycbc.strain | ||
|
|
||
|
|
||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| pycbc.add_common_pycbc_options(parser) | ||
| parser.add_argument("--output-file", required=True, help="Output plot") | ||
| parser.add_argument( | ||
| "--center-time", | ||
| type=float, | ||
| help="Center plot on the given GPS time. If omitted, use " | ||
| "center of interval set via --gps-start-time and " | ||
| "--gps-end-time", | ||
| ) | ||
| parser.add_argument( | ||
| "--time-window", | ||
| required=True, | ||
| metavar="START,END", | ||
| help="Use these set of times for time window. Should " | ||
| "be provided as start,end " | ||
| "where start/end time is relative to --center-time; " | ||
| "both are positive", | ||
| ) | ||
| pycbc.strain.insert_strain_option_group(parser) | ||
| args = parser.parse_args() | ||
|
|
||
| pycbc.init_logging(args.verbose, default_level=1) | ||
|
|
||
| if args.center_time is None: | ||
| center_time = (args.gps_start_time + args.gps_end_time) / 2.0 | ||
| else: | ||
| center_time = args.center_time | ||
| # Set up the time window to be audified | ||
| try: | ||
| split = args.time_window.split(",") | ||
| win_start = float(args.time_window.split(",")[0]) | ||
| win_end = float(args.time_window.split(",")[1]) | ||
| if win_start <= 0 or win_end <= 0: | ||
| raise RuntimeError | ||
| except (RuntimeError, IndexError, ValueError): | ||
| parser.error(f"--time-window input error. Got {args.time_window}. See help.") | ||
|
|
||
| logging.info("Loading Strain") | ||
| strain = pycbc.strain.from_cli(args, pycbc.DYN_RANGE_FAC) | ||
|
|
||
| rem_corrupted = True | ||
| if (center_time - strain.start_time) < 2 or (strain.end_time - center_time) < 2: | ||
| rem_corrupted = False | ||
|
|
||
| logging.info("Whitening") | ||
| strain = strain.whiten(4, 4, remove_corrupted=rem_corrupted) | ||
|
|
||
| logging.info("Slicing to specified region") | ||
| strain_zoom = strain.time_slice( | ||
| args.center_time - win_start, args.center_time + win_end | ||
| ) | ||
| logging.info("Saving audio to %s", args.output_file) | ||
| strain_zoom.save_to_wav(args.output_file) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.