Skip to main content

Command Line Interface Spectrogram

cli-spectrogram

Simple python module that creates spectrograms from multi channel hydrophone array data in the command line.

Purpose

Our group needed a lightweight, command line tool to look at spectrogram data coming from multi channel hydrophone arrays. This was designed for text or binary files created using the uldaq library. Link to their source code here.

Example data file with two channels

The first column contains voltage readings from channel 1 The second column contains voltage readings from channel 2 The data points are separated by ','

0.001782, 0.002414
0.002414, 0.002414
0.001641, -0.001416
0.000060, -0.001416
-0.001416, -0.001416
-0.001908, -0.001100
-0.001100, -0.001100

Installing cli-spectrogram

cli-spectrogram is meant to be a standalone tool.

$ pip install cli-spectrogram 

Running cli-spectrogram

$ cli_spectrogram --sample-rate 38400 --file-length 1 --source ./examples
$ cli_spectrogram --help

usage: cli_spectrogram [-h] --sample-rate SAMPLE_RATE --file-length
                       FILE_LENGTH [-d] [--source SOURCE]
                       [--threshold-steps THRESHOLD_STEPS]
                       [-c {1,2,3,4,5,6,7,8}] [-t THRESHOLD_DB]
                       [-m MARKFREQ_HZ] [--nfft NFFT]

optional arguments:
  -h, --help            show this help message and exit
  --sample-rate SAMPLE_RATE
  --file-length FILE_LENGTH
                        in seconds
  -d, --debug           Show debugging print messsages
  --source SOURCE       Source directory with .txt files
  --threshold-steps THRESHOLD_STEPS
                        How many dB above and below threshold
  -c {1,2,3,4,5,6,7,8}, --display-channel {1,2,3,4,5,6,7,8}
  -t THRESHOLD_DB, --threshold-db THRESHOLD_DB
  -m MARKFREQ_HZ, --markfreq-hz MARKFREQ_HZ
  --nfft NFFT

Different ways to launch cli-spectrogram

$ cli_spectrogram --sample-rate 38400 --file-length 1 --source ./examples

$ cli_spectrogram --sample-rate 38400 --file-length 1 --source ./examples --markfreq-hz 2000 --threshold-db 80

$ cli_spectrogram --sample-rate 38400 --file-length 1 --source ./examples --markfreq-hz 2000 --threshold-db 80 --threshold-steps 20

Navigating the user interface

Adjust the Threshold (dB)

  • press the 'up arrow' to increase the threshold dB value by THRESHOLD_STEPS.
  • press the 'down arrow' to decrease the threshold dB value by THRESHOLD_STEPS.

Adjust the Mark Frequency

  • press the 'right arrow' to increase the mark frequency value by 200Hz.
  • press the 'left arrow' to decrease the mark frequency value by 200Hz.

Toggle Full Screen

  • press 'F' or 'f' to toggle full screen mode. In full screen mode there are more rows to the spectrogram but the menu and legend are hidden.

Navigation Mode

  • press 'pg up' to display the next file. (if you're at the most current file, 'pg up' won't do anything).
  • press 'pg down' to display the previous file. (if you're at the oldest file, 'pg down' won't do anything).
  • press 'escape' to exit Navigation mode and return to streaming mode. Note: in Navigation mode, the spectrogram will be displayed for the current file and wait indefinitely. When Streaming mode is resumed, the spectrogram will be of the latest file, NOT where it left off.

Ui Indicators

Left column info Center column legend Right column help
Threshold (dB): Current threshold. Mode: Streaming OR Navigation up / down Keys to adjust the threshold
Sample Rate (Hz): Sample rate of collected data. Color bar for spectrogram left / right Keys to adjust the frequency marker
Viewing same file: if True, the spectrogram is being re-rendered from the same file. if False, then the spectrogram on display is a new render. lower bound dB - upper bount dB pg up/pg down view next file/view prev file
file: name of the file that is being rendered. ESC Exit navigation mode
time: time the file was created/last modified converted to local time F/f toggle full screen
refresh count: The heartbeat of the app.

Errors and fail states

  • cli-spectrogram has a minimum console size. If you shrink the window past the minimum size, you'll be prompted to resize until the minimum dimensions are met.

  • If there aren't any files in the log directory, you'll need to restart the cli-spectrogram and provide a directory to --source that has the text/binary files generated by the uldaq library; however, if files are added to the directory while in this state, cli-spectrogram will return to/start streaming.

Metadata

Release files for cli-spectrogram 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cli-spectrogram 1.0.0
File Size Uploaded Provenance Actions
cli-spectrogram-1.0.0.tar.gz 9.0 kB Without provenance Details for cli-spectrogram-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cli-spectrogram 1.0.0
File Interpreter ABI Platform Actions
cli_spectrogram-1.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for cli_spectrogram-1.0.0-py2.py3-none-any.whl

Total release size: 29.7 kB

Release files / cli-spectrogram-1.0.0.tar.gz

Download URL cli-spectrogram-1.0.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4a35d21e1acbf0d70453e9b7dc2576489ba56e6cf1023d93fc65ca6c0f111156
BLAKE2b-256 checksum
How to use checksums
c84554174f697afbd09dd6874a332aad53aa440292dc4cfa7443637386dbb0bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

Release files / cli_spectrogram-1.0.0-py2.py3-none-any.whl

Download URL cli_spectrogram-1.0.0-py2.py3-none-any.whl
Size 20.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
42eb89ce257332e4d13176bc69568e62d4bddee2b38c47d0254fd1bd1ab0f71b
BLAKE2b-256 checksum
How to use checksums
484fff032e90d16d660064e6a1f5699caacb55f5f009fc5a3b55b1ce6f674066
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

Security for cli-spectrogram 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page