Skip to content

Add edge-safe event spectrogram workflows - #7

Merged
Spiffical merged 1 commit into
masterfrom
agent/edge-safe-event-spectrograms
Jul 15, 2026
Merged

Add edge-safe event spectrogram workflows#7
Spiffical merged 1 commit into
masterfrom
agent/edge-safe-event-spectrograms

Conversation

@Spiffical

Copy link
Copy Markdown
Owner

What changed

  • add event-centred local spectrogram generation with retained signal padding and automatic STFT computation context
  • expose the mode through Python and the command-line interface
  • document the distinction between locally generated spectrograms and ONC-generated products, including JSON workflows
  • reorganize and refresh the tutorial notebook around the common audio-to-local-spectrogram workflow while introducing both methods
  • export the public downloader API and add regression coverage

Why

Clipping exactly at an event interval can leave incomplete STFT windows at its boundaries. The new workflow reads extra computation-only context, trims back to the requested interval, and normalizes after trimming so discarded context cannot affect retained values.

User impact

Users can generate spectrograms around known signal times from Python, the CLI, or JSON with sensible defaults, clear metadata, and documented edge handling.

Validation

  • 57 passed, 2 deselected
  • mkdocs build --strict
  • all 71 notebook cells parsed with empty saved outputs
  • git diff --check

@Spiffical
Spiffical marked this pull request as ready for review July 15, 2026 15:00
Copilot AI review requested due to automatic review settings July 15, 2026 15:00
@Spiffical
Spiffical merged commit 3fa0ac3 into master Jul 15, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an “edge-safe” event-centred spectrogram workflow that retains a precise target window while reading extra STFT-only context, trims back to the requested interval, and then normalizes after trimming so discarded context can’t influence retained dB values. This is exposed via Python, CLI flags, and updated docs/tutorials, with new regression tests.

Changes:

  • Add SpectrogramGenerator.process_event() and move relative-dB normalization to occur after clip trimming.
  • Extend scripts/generate_spectrograms.py with --event-time and related event padding flags.
  • Export a public downloader API from onc_hydrophone_data.data and refresh docs/notebook/tutorial materials accordingly.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_spectrogram_generator.py Adds regression coverage for event-centred STFT context + trim-then-normalize behavior and input validation.
tests/test_hydrophone_downloader.py Updates imports to use the new public onc_hydrophone_data.data API surface.
scripts/generate_spectrograms.py Adds CLI event workflow flags and routes --event-time to process_event().
README.md Mentions the new event-centred spectrogram capability in the feature list.
onc_hydrophone_data/data/init.py Introduces a public re-export surface for downloader APIs and helpers.
onc_hydrophone_data/audio/spectrogram_generator.py Implements process_event(), adds output_stem, and changes normalization ordering to happen after trimming.
notebooks/ONC_Data_Download_Tutorial.ipynb Reorganizes tutorial flow to lead with audio→local spectrogram workflow and introduces event-safe mode.
docs/quickstart.md Clarifies the “audio first” workflow and links to ONC server-product guidance.
docs/onc_spectrogram_options.md Reframes guidance to help users choose between local vs ONC spectrogram workflows.
docs/index.md Updates landing page to present both workflows and links to edge-safe local event section.
docs/downloads.md Clarifies JSON/CSV workflow distinctions (ONC products vs local generation).
docs/custom_spectrograms.md Documents the new process_event() and CLI event mode, plus edge-context semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +730 to +732
base_name = Path(output_stem).name if output_stem else audio_path.stem
if not base_name or base_name in {'.', '..'}:
raise ValueError("output_stem must contain a valid filename stem")
Comment on lines +682 to +686
if args.event_time is not None:
if is_directory:
raise ValueError("--event-time requires --input-file")
if args.clip_start is not None or args.clip_end is not None:
raise ValueError("--event-time cannot be combined with --clip-start/--clip-end")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants