Repository navigation
Expand file tree
/
Copy pathtest.py
More file actions
50 lines (40 loc) · 1.74 KB
/
Copy pathtest.py
File metadata and controls
50 lines (40 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from IdealFilter.BandStopFilter import BandStopFilter
from IdealFilter.BandPassFilter import BandPassFilter
from IdealFilter.HighPassFilter import HighPassFilter
from IdealFilter.LowPassFilter import LowPassFilter
from ModulationAndDemodulate.AMModulation import *
from ModulationAndDemodulate.FMModulation import *
from ModulationAndDemodulate.PMModulation import *
import sympy as sp
from sympy import *
t = sp.symbols('t', real=True)
if __name__ == '__main__':
exper = sin(t)
BP = BandPassFilter(exper, 100, 4, 5)
BP.create_interactive_plot((0.5, 20))
BP.show_interactive(cutoff_range=(0.5, 20))
BS = BandStopFilter(exper, 100, 4, 5)
BS.create_interactive_plot((0.5, 20))
BS.show_interactive(cutoff_range=(0.5, 20))
HP = HighPassFilter(exper, 100, 4)
HP.create_interactive_plot((0.5, 20))
HP.show_interactive(cutoff_range=(0.5, 20))
LP = LowPassFilter(exper, 100, 4)
LP.create_interactive_plot((0.5, 20))
LP.show_interactive(cutoff_range=(0.5, 20))
print("示例1: AM调制 - 简单正弦信号")
message_signal1 = sin(2 * pi * 5 * t)
am1 = AMModulation(message_signal1, sample_frequency=1000, T=2, modulation_index=0.8)
am1.visualize(demod_method='envelope', carrier_freq_range=(20, 100))
am1.show_interactive()
print("示例1: FM调制 - 简单正弦信号")
message_signal1 = sin(2 * pi * 5 * t)
fm1 = FMModulation(message_signal1, carrier_freq=100,
sample_frequency=1000, T=2, freq_deviation=30)
fm1.visualize(carrier_freq_range=(20, 100))
fm1.show_interactive()
print("PM调制")
PM = PMModulation(exper, carrier_freq=100,
sample_frequency=1000, T=2, phase_deviation=np.pi / 2)
fig1 = PM.visualize()
fig1.show()