Skip to main content

A Constant Q Transform based on GWpy qtransform

The creation of this program was inspired by the need to include a CQT package with minimal size and dependency for SHARCNET (ComputeCanada) Supercomputer Clusters.

# IMPORTANT DISCLAIMER: All credits for the original Q transform algorithm go to the authors of *GWpy* and *Omega* pipeline.
# See original algorithms at: [Omega Scan] https://gwdetchar.readthedocs.io/en/stable/omega/
#                             [GWpy] https://gwpy.github.io/docs/stable/
#          particularly       [GWpy qtransform]
#              - https://github.com/gwpy/gwpy/blob/26f63684db17104c5d552c30cdf01248b2ec76c9/gwpy/signal/qtransform.py
#
# The license information does NOT imply this package (constantQ) as the original q transform/q scan algorithm.
# NOTE: Referenced programs are under the GNU license 
# for more information on the license visit: https://www.gnu.org/licenses/gpl-faq.en.html

How to use it:

Step 1: Generating a chirp signal

import numpy as np

# Generate np.array chirp signal
dt = 0.001
t = np.arange(0,3,dt)
f0 = 50
f1 = 250
t1 = 2
x = np.cos(2*np.pi*t*(f0 + (f1 - f0)*np.power(t, 2)/(3*t1**2)))
fs = 1/dt

plt.plot(x)				# plot the chirp signal
plt.show()				# display

Step 2: Generating a TimeSeries object

from constantQ.timeseries import TimeSeries
series = TimeSeries(x, dt = 0.001, unit='m', name='test', t0=0)     #np.array --> constantQ.timeseries    

Step 3: Q Transform

hdata = series
sq = hdata.q_transform(search=None)				# q transform
print(len(sq[0]))       # freq array length
print(len(sq))          # time array length

plt.imshow(sq.T, origin='lower')				# plot the spectrogram
plt.colorbar()									# colorbar
plt.show()										# display

To compare the result with a Scipy Spectrogram

from scipy import signal as scisignal

freq, ts, Sxx = scisignal.spectrogram(x)		# scipy spectrogram

plt.pcolor(ts, freq, Sxx, shading='auto')		# plot the spectrogram
plt.colorbar()									# colorbar
plt.show()										# display

This test version 0.0.1 largely follows the GWpy architecture. Changes will be made in future updates if a different structure is better for this package.

Release files for constantQ 0.0.1

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

Source distribution (sdist)

Source distribution for constantQ 0.0.1
File Size Uploaded
constantQ-0.0.1.tar.gz 27.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for constantQ 0.0.1
File Interpreter ABI Platform
constantQ-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 84.3 kB

Release files / constantQ-0.0.1.tar.gz

Download URL constantQ-0.0.1.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
89601f32ba9a967fa1580420fa6ac4c887b33ade1d212e87c0cfdcfa37c6fe15
BLAKE2b-256 checksum
How to use checksums
4f8033b0c72b92b867d032863aa142db49f4dc82b60349451b0edb7f479120f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

Release files / constantQ-0.0.1-py3-none-any.whl

Download URL constantQ-0.0.1-py3-none-any.whl
Size 56.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25f2d6e22d2bb4cc4c18524460bac00b7eebc1c4f78f69a9ca6fcc4ca1781182
BLAKE2b-256 checksum
How to use checksums
d12161d557c8d1200d0a411f0da715e47f0182c80b0b102051f0f2257238e723
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

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