-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimation_vis_firstchirp.py
65 lines (49 loc) · 2.08 KB
/
animation_vis_firstchirp.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import matplotlib.pyplot as plt
import numpy as np
import time
import json
import matplotlib.animation as animation
# open Dataset
datasetnya = ".dataset/BGT60TR13C_record_220240423-143957/RadarIfxAvian_00/radar.npy"
conf_fname = '.dataset/BGT60TR13C_record_220240423-143957/RadarIfxAvian_00/config.json'
# Membuka file JSON
with open(conf_fname, 'r') as f:
conf_json = json.load(f)
print("\nData dari file JSON:")
print(conf_json["device_config"]['fmcw_single_shape']['aaf_cutoff_Hz'])
datanya = np.load(datasetnya)
print("Shape datanya : ",end="")
print(np.shape(datanya))
frame_num, i_ant, chirp_num, samples_num = np.shape(datanya)
print("Jumlah Frame : ",end="");print(frame_num)
print("Jumlah Antenna : ",end="");print(i_ant)
print("Jumlah Chirps/Frame : ",end="");print(chirp_num)
print("Jumlah Samples/Chirp : ",end="");print(samples_num)
x = np.arange(chirp_num) # Membuat array dari 0 hingga 63
y = np.arange(samples_num) # Membuat array dari 0 hingga 63
framesya = np.arange(frame_num)
fps = 30
nSeconds = 5
snapshots = [ np.random.rand(5,6) for _ in range( nSeconds * fps ) ]
snapshots2 = [ np.random.rand(5,6) for _ in range( nSeconds * fps ) ]
snapshots3 = [ np.random.rand(5,6) for _ in range( nSeconds * fps ) ]
# Buat figure dan subplot
fig, axes = plt.subplots(3, 1, figsize=(8, 12))
# # Inisialisasi plot
# x, y1, y2, y3 = generate_data(0)
lines = [ax.plot(x, y)[0] for ax, y in zip(axes, [datanya[0][0][0], datanya[0][0][0], datanya[0][0][0]])]
# Fungsi untuk animasi
def animate(i):
lines[0].set_data(x,datanya[i][0][0])
lines[0].set_ylim(np.min(datanya[i][0][0]), np.max(datanya[i][0][0]))
lines[1].set_data(x,datanya[i][1][0])
lines[1].set_ylim(np.min(datanya[i][1][0]), np.max(datanya[i][1][0]))
lines[2].set_data(x,datanya[i][2][0])
lines[2].set_ylim(np.min(datanya[i][2][0]), np.max(datanya[i][2][0]))
# x, y1, y2, y3 = generate_data(i)
# for line, y in zip(lines, [y1, y2, y3]):
# line.set_data(x, y)
return lines
# Buat animasi
anim = animation.FuncAnimation(fig, animate, frames=100, interval=0.1, blit=True)
plt.show()