Unidata / pyCWT

Continuous Wavelet Transform Library for Python
Other
16 stars 3 forks source link

scalogram coi is wrong when time is set #2

Open rickyegeland opened 9 years ago

rickyegeland commented 9 years ago

The scalogram cone of influence is wrong when the time= parameter is set to put the axis in time units as opposed to sample indices.

import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt
import cwt

# make signal
P = 17.0 # period, s
D = 100   # duration, s
N = 1000 # number of samples
x = np.linspace(0, D, N) # time, s
data = np.sin(2*np.pi/P*x)
label = 'P=%0.1f sine wave' % P

# plot signal
plt.plot(x, data)
plt.title(label)
plt.xlabel('Time [s]')
plt.ylabel('signal')

# continuous wavelet transform
scales = np.arange(200)    
mother = cwt.Morlet(len_signal = len(data), scales = scales)
wavelet = cwt.cwt(data, mother)

# plot with builtin function
wavelet.scalogram(time=x, show_coi=True)
lesserwhirls commented 9 years ago

I'm thinking this may be related to not setting sampf. Let's work on the API of cwt, mother, before checking this one out, if that's ok.

Thanks!

Sean