Tools for downloading and processing Ocean Networks Canada hydrophone data
Project description
🌊 ONC Hydrophone Data Tools
Tools for downloading and processing Ocean Networks Canada hydrophone data, including spectrograms, FLAC audio files, and custom spectrogram generation.
📦 Installation
pip install onc-hydrophone-data
For development:
git clone https://github.com/Spiffical/onc-hydrophone-data.git
cd onc-hydrophone-data
pip install -e .
⚙️ Configuration
-
Get your ONC API token from: https://data.oceannetworks.ca/Profile
-
Create a
.envfile in your project directory:
ONC_TOKEN=your_onc_token_here
DATA_DIR=./data
🚀 Quick Start
📓 Tutorial Notebook - The best way to get started with interactive examples.
Python API
from onc_hydrophone_data.onc.common import load_config
from onc_hydrophone_data.data import HydrophoneDownloader
from onc_hydrophone_data.audio import SpectrogramGenerator
# Load credentials from .env file
onc_token, data_dir = load_config()
# Download spectrograms using intelligent sampling
downloader = HydrophoneDownloader(onc_token, data_dir)
downloader.download_spectrograms_with_sampling_schedule(
deviceCode="ICLISTENHF6020",
start_date=(2021, 1, 1),
threshold_num=100
)
# Generate custom spectrograms from audio files
generator = SpectrogramGenerator(win_dur=2.0, overlap=0.75)
generator.process_directory("data/DEVICE/audio/", "output/spectrograms/")
Command Line
# Interactive mode (guided setup - recommended)
python scripts/download_hydrophone_data.py
# Download spectrograms with specific parameters
python scripts/download_hydrophone_data.py --mode sampling \
--device ICLISTENHF6020 --start-date 2021 1 1 --threshold 500
# Include FLAC audio files
python scripts/download_hydrophone_data.py --mode sampling \
--device ICLISTENHF6020 --start-date 2021 1 1 --threshold 100 --download-audio
# Generate custom spectrograms
python scripts/generate_spectrograms.py --input-dir data/DEVICE/audio/ --win-dur 2.0
✨ Features
- Smart Sampling: Intelligently distributes downloads across date ranges
- Parallel ONC Requests: Submits many requests at once so ONC processes them in parallel, then downloads when ready (faster than sequential requests)
- Audio Downloads: Download raw audio (FLAC/WAV) alongside spectrograms
- Custom Spectrograms: Generate spectrograms with configurable parameters
- Deployment Validation: Ensures data exists for requested time periods
- Interactive Mode: Guided CLI for easy setup
📁 Output Structure
Downloads are organized in a clean, flat structure:
data/
└── ICLISTENHF6020/
└── sampling_2021-01-01_to_2021-01-31/
├── onc_spectrograms/ # ONC-downloaded spectrograms (MAT/PNG)
│ ├── *.mat # Spectrogram data files
│ └── anomaly_report.txt # Any validation issues (if found)
├── audio/ # Downloaded audio files
│ └── *.flac
└── custom_spectrograms/ # Locally-generated spectrograms
├── mat/ # Custom MAT files
└── png/ # Custom PNG plots
Note: Unlike previous versions, there are no processed/ or rejects/ subdirectories. All files stay in flat directories for simplicity.
🛠️ Troubleshooting
| Issue | Solution |
|---|---|
| Invalid ONC Token | Verify token in .env file |
| No data found | Use --check-deployments to verify coverage |
| Memory errors | Reduce --spectrograms-per-batch |
📚 Documentation
Docs site: https://spiffical.github.io/onc-hydrophone-data/
See the Tutorial Notebook for comprehensive examples including:
- Different download modes (sampling, range, specific times)
- Parallel download optimization
- Custom spectrogram generation
- JSON timestamp requests
📄 License
MIT License - see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file onc_hydrophone_data-0.2.0.tar.gz.
File metadata
- Download URL: onc_hydrophone_data-0.2.0.tar.gz
- Upload date:
- Size: 81.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ca377aa54e4147c4bc6e0d6c928fb97df8905ec1c4bf3045e8701ca002a6e14
|
|
| MD5 |
6290a772f99a8973ca2153b1f7962d01
|
|
| BLAKE2b-256 |
f639b0d4e74fe71e2f59c4bc3357a29c73958eb908eb91d1f31530ddc8b0b2bb
|
File details
Details for the file onc_hydrophone_data-0.2.0-py3-none-any.whl.
File metadata
- Download URL: onc_hydrophone_data-0.2.0-py3-none-any.whl
- Upload date:
- Size: 84.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8714c39f67a0b73b6fc36f758e87a9c80f727a2472403e5ec31d645372cc930
|
|
| MD5 |
a96620e0ea26c66846c7c063cb24a069
|
|
| BLAKE2b-256 |
1ad7c11849c3d7e6d017aeae257ed7b25ca998b80b7a1be72801383dfe4d0cf1
|