Wavelet

From SPEDAS Wiki
Revision as of 03:14, 3 May 2020 by Nikos (talk | contribs)
Jump to navigation Jump to search

Compare IDL code to python code for the wavelet transformation of a simple wave function.

IDL code: SPEDAS

  t =  FINDGEN(4000)
  time = time_double('2010-01-01') + 10*t  
  data = sin(2*!pi*t/32.) 
  data2 = sin(2*!pi*t/64.)
  data[1000:3000] = data2[1000:3000]  
  
  var = 'sin_wav'
  store_data, var, data={x:time, y:data}

  pvar = 'sin_wav_wv_pow'
  wav_data, var 
  tplot, [var, pvar]

IDL spectrogram example


Python code: pySPEDAS

import numpy as np
import pytplot
import pyspedas
from pyspedas.analysis.wavelet import wavelet

t = np.arange(4000.)
y = np.sin(2*np.pi*t/32.) 
y2 = np.sin(2*np.pi*t/64.) 
y[1000:3000] = y2[1000:3000]

var = 'sin_wav'
time = pyspedas.time_float('2010-01-01') + 10*t

pytplot.store_data(var, data={'x':time, 'y':y})

# Complex wavelet transformation
powervar = wavelet(var, mother='cmorl0.5-1.0')
pvar = powervar[0]

pytplot.tplot_names()

pytplot.options(pvar, 'colormap', 'jet')
pytplot.ylim(pvar, 0.001, 0.1)
pytplot.options(pvar, 'ylog', True)
pytplot.options(pvar, 'ytitle', pvar)
pytplot.tplot([var, pvar])

pyspedas spectrogram example