of frequency components. As this example shows, they coincide with each other
for a given signal when the time bandwidth product of the signal is
sufficiently high.

"""

import numpy as np
import matplotlib.pyplot as plt
from tftb.generators import amgauss, fmlin
from tftb.processing import loctime, locfreq, inst_freq, group_delay

time_instants = np.arange(2, 256)
sig1 = amgauss(256, 128, 90) * fmlin(256)[0]
tm, T1 = loctime(sig1)
fm, B1 = locfreq(sig1)
ifr1 = inst_freq(sig1, time_instants)[0]
f1 = np.linspace(0, 0.5 - 1.0 / 256, 256)
gd1 = group_delay(sig1, f1)

plt.subplot(211)
plt.plot(time_instants, ifr1, '*', label='inst_freq')
plt.plot(gd1, f1, '-', label='group delay')
plt.xlim(0, 256)
plt.grid(True)
plt.legend()
plt.title("Time-Bandwidth product: {0}".format(T1 * B1))
plt.xlabel('Time')
plt.ylabel('Normalized Frequency')


sig2 = amgauss(256, 128, 30) * fmlin(256, 0.2, 0.4)[0]
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.
"""
Example in section 2.3 of the tutorial.
"""

from tftb.generators import fmlin
from tftb.processing import plotifl, inst_freq
import numpy as np

signal, _ = fmlin(256)
time_samples = np.arange(3, 257)
ifr = inst_freq(signal)[0]
plotifl(time_samples, ifr)
Beispiel #3
0
#
# Distributed under terms of the MIT license.
"""
Example in section 2.4 of the tutorial.
"""

import numpy as np
import matplotlib.pyplot as plt
from tftb.generators import amgauss, fmlin
from tftb.processing import loctime, locfreq, inst_freq, group_delay

time_instants = np.arange(2, 256)
sig1 = amgauss(256, 128, 90) * fmlin(256)[0]
tm, T1 = loctime(sig1)
fm, B1 = locfreq(sig1)
ifr1 = inst_freq(sig1, time_instants)[0]
f1 = np.linspace(0, 0.5 - 1.0 / 256, 256)
gd1 = group_delay(sig1, f1)

plt.subplot(211)
plt.plot(time_instants, ifr1, '*', label='inst_freq')
plt.plot(gd1, f1, '-', label='group delay')
plt.xlim(0, 256)
plt.grid(True)
plt.legend()
plt.title("Time-Bandwidth product: {0}".format(T1 * B1))
plt.xlabel('Time')
plt.ylabel('Normalized Frequency')

sig2 = amgauss(256, 128, 30) * fmlin(256, 0.2, 0.4)[0]
tm, T2 = loctime(sig2)
#  N=128; x1=fmlin(N,0,0.2); x2=fmlin(N,0.3,0.5);
#  x=x1+x2;
#  ifr=instfreq(x); subplot(211); plot(ifr);
#  fn=0:0.01:0.5; gd=sgrpdlay(x,fn);
#  subplot(212); plot(gd,fn);
from tftb.generators import fmlin
from tftb.processing import inst_freq, group_delay
import matplotlib.pyplot as plt
import numpy as np

N = 128
x1, _ = fmlin(N, 0, 0.2)
x2, _ = fmlin(N, 0.3, 0.5)
x = x1 + x2
ifr = inst_freq(x)[0]
fn = np.arange(0.51, step=0.01)
gd = group_delay(x, fn)

plt.subplot(211)
plt.plot(ifr)
plt.xlim(1, N)
plt.grid(True)
plt.title('Instantaneous Frequency')
plt.xlabel('Time')
plt.ylabel('Normalized Frequency')

plt.subplot(212)
plt.plot(gd, fn)
plt.xlim(1, N)
plt.grid(True)
Beispiel #5
0
#  N=128; x1=fmlin(N,0,0.2); x2=fmlin(N,0.3,0.5);
#  x=x1+x2;
#  ifr=instfreq(x); subplot(211); plot(ifr);
#  fn=0:0.01:0.5; gd=sgrpdlay(x,fn);
#  subplot(212); plot(gd,fn);
from tftb.generators import fmlin
from tftb.processing import inst_freq, group_delay
import matplotlib.pyplot as plt
import numpy as np

N = 128
x1, _ = fmlin(N, 0, 0.2)
x2, _ = fmlin(N, 0.3, 0.5)
x = x1 + x2
ifr = inst_freq(x)[0]
fn = np.arange(0.51, step=0.01)
gd = group_delay(x, fn)

plt.subplot(211)
plt.plot(ifr)
plt.xlim(1, N)
plt.grid(True)
plt.title('Instantaneous Frequency')
plt.xlabel('Time')
plt.ylabel('Normalized Frequency')

plt.subplot(212)
plt.plot(gd, fn)
plt.xlim(1, N)
plt.grid(True)
Beispiel #6
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""

"""


import matplotlib.pyplot as plt
from tftb.processing import inst_freq
from tftb.generators import fmsin

x = fmsin(70, 0.05, 0.35, 25)[0]
instf, timestamps = inst_freq(x)
plt.plot(timestamps, instf)
plt.xlim(0, 70)
plt.grid()
plt.title("Instantaneous frequency estimation")
plt.xlabel('Time')
plt.ylabel('Frequency')
plt.show()
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2015 jaidev <jaidev@newton>
#
# Distributed under terms of the MIT license.

"""
Example in section 2.3 of the tutorial.
"""

from tftb.generators import fmlin
from tftb.processing import plotifl, inst_freq
import numpy as np


signal, _ = fmlin(256)
time_samples = np.arange(3, 257)
ifr = inst_freq(signal)[0]
plotifl(time_samples, ifr)
Beispiel #8
0
plt.plot(t, u1, '-k')
plt.ylabel('$u_1$(t)')
plt.title('IMF $u_k$')
plt.xticks([])

# plot the instantaneous amplitude of u1
plt.subplot(332)
h = hilbert(u1)
A = np.abs(h)
plt.plot(t, A, '-k')
plt.title('Amplitude of $u_k$')
plt.xticks([])

# plot the instantaneous frequency of u1
plt.subplot(333)
instf, timestamps = inst_freq(h)
plt.plot(timestamps / fs, instf * fs, '.k')
plt.title('Frequency of $u_k$')
plt.xticks([])

# plot u2(t)
plt.subplot(334)
u2 = u[1, :]
plt.plot(t, u2, '-k')
plt.ylabel('$u_2$(t)')
plt.xticks([])

# plot the instantaneous amplitude of u2
plt.subplot(335)
h = hilbert(u2)
A = np.abs(h)