Skip to main content

sslf is designed to be a dead-simple, effective and useful spectral line finder for 1D data. It utilises the continuous wavelet transform from scipy, which is a productive way to find even weak spectral lines.

Because there are many definitions for a spectral line, this package can not conceivably work in all cases. Here, I have designed sslf for Gaussian-profiled spectral lines. A big part of my work focuses on recovering weak signals in the noise, so sslf aims to identify lines, flag them, and subtract the non-zero bandpass around them.

Usage

With a 1D spectrum (spectral_data) and a range of scales to test (e.g. 1 through 20), statistically significant spectral peaks can be found with:

import numpy as np
from sslf.sslf import Spectrum

s = Spectrum(spectral_data)
s.find_cwt_peaks(scales=np.arange(1, 20), snr=6.5)
s.subtract_bandpass()

The flattened spectrum is then contained in s.modified, and peak locations at s.channel_peaks. Other parameters related to the peaks are s.peak_snrs, s.vel_peaks and s.channel_edges.

Note that the snr parameter specified to find_cwt_peaks actually refers to the signal-to-noise ratio in the wavelet domain, not the input-signal domain; for this reason, if you wanted all signals above 5-sigma, you would have to put in a little more work to determine what your spectrum’s noise RMS is and how it maps to the wavelet RMS.

Also note that channel_edges can be quite inaccurate; by default, this variable is populated by the wavelet scale that found the spectral line. The wavelet need not match very well; it only needs to be significant enough to be picked up by sslf. The Spectrum object has an optional refine_line_widths method which (hopefully) does a better job of finding the channel extent of all detected spectral lines. Read the documentation of sslf functions for more information.

find_cwt_peaks can optionally take the wavelet to be used in the wavelet transformation (Ricker wavelet by default). subtract_bandpass is a little harder to explain; more complicated examples of usage can be found in the notebooks directory. A reasonably complex example of sslf usage is here.

Contributions and Suggestions

I created this software because I could not find anything in the community that functioned similarly. So, I would welcome contributions to make this software more generally flexible, to be suitable for a wide audience. It’s really simple, just look at the code!

Issues? Bugs? Inconsistencies?

Absolutely! Please raise a GitLab issue if you find something odd, with your inputs and expected outputs, and I’ll attempt to fix it ASAP.

Installation

pip install sslf

or

  • clone this repo (git clone https://gitlab.com/cjordan/sslf.git)

  • within the directory, run: python setup.py install --optimize=1

Dependencies

  • python 2.7.x or 3.x

  • numpy 1.8+

  • scipy

  • future

Metadata

Release files for sslf 0.2.0

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

Built distribution (wheel)

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

Release files / sslf-0.2.0-py2.py3-none-any.whl

Download URL sslf-0.2.0-py2.py3-none-any.whl
Size 8.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b1cdd79085b95cd5ea675cc311b7aeabcf90b20c97ebea036305f7c21155225a
BLAKE2b-256 checksum
How to use checksums
6989c8ff0c17c0e1af6b0b0f728adedcfd424d9c483c7ac3b92daae69d260ac6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3

Security for sslf 0.2.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.

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