Skip to content

Commit 09905cc

Browse files
committed
possible slution
Signed-off-by: PopPaul2021 <Paul.Pop@analog.com>
1 parent 4dbe9d9 commit 09905cc

File tree

1 file changed

+70
-53
lines changed

1 file changed

+70
-53
lines changed

examples/plot_identification_data.py

+70-53
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import adi
1616
import scipy.io
1717

18-
app = Dash(__name__)
18+
app = Dash(__name__, update_title=None)
1919

2020
# Data
2121
labels = ['16QAM', '64QAM', '8PSK', 'BPSK', 'CPFSK', 'GFSK', 'PAM4', 'QPSK']
@@ -66,8 +66,8 @@ def plot_modulated_data1():
6666
estimated_ch7 = 0
6767
estimated_ch8 = 0
6868

69-
file_path = 'cnn_output.txt'
70-
file_path1 = 'cnn_output1.txt'
69+
file_path = '/home/analog/Workspace/holohub/build/matlab_classify_modulator/applications/matlab_classify_modulator/cpp/modulation_results.txt'
70+
file_path1 = '/home/analog/Workspace/holohub/build/matlab_classify_modulator/applications/matlab_classify_modulator/cpp/modulation_results1.txt'
7171

7272
truth = 0
7373
truth1 = 0
@@ -213,7 +213,7 @@ def get_cnn_data():
213213
sdr3.tx(iq)
214214
sdr3._tx2.tx(iq)
215215

216-
time.sleep(0.1)
216+
time.sleep(0.5)
217217
if get_timestamp(file_path):
218218
with open(file_path, 'r') as file:
219219
lines = file.readlines()
@@ -314,7 +314,9 @@ def plot_confusion_matrix():
314314
z=confusion_matrix,
315315
x=labels,
316316
y=labels,
317-
colorscale='Blues'
317+
colorscale='Blues',
318+
linewidths=.5,
319+
annot=True
318320
))
319321
fig.update_layout(
320322
xaxis=dict(title='Estimated Modulation'),
@@ -327,7 +329,9 @@ def plot_confusion_matrix1():
327329
z=confusion_matrix1,
328330
x=labels,
329331
y=labels,
330-
colorscale='Blues'
332+
colorscale='Blues',
333+
linewidths=.5,
334+
annot=True
331335
))
332336
fig.update_layout(
333337
xaxis=dict(title='Estimated Modulation'),
@@ -368,12 +372,12 @@ def update_table():
368372
r2 = r2_score(y_true, y_pred)
369373

370374
table_data = [
371-
{'column-1': f'{accuracy:.2f}',
372-
'column-2': f'{precision:.2f}',
373-
'column-3': f'{recall:.2f}',
374-
'column-4': f'{f1:.2f}',
375-
'column-5': f'{mse:.2f}',
376-
'column-6': f'{r2:.2f}'
375+
{'column-1': f'{accuracy:.4f}',
376+
'column-2': f'{precision:.4f}',
377+
'column-3': f'{recall:.4f}',
378+
'column-4': f'{f1:.4f}',
379+
'column-5': f'{mse:.4f}',
380+
'column-6': f'{r2:.4f}'
377381
},
378382
]
379383

@@ -382,87 +386,83 @@ def update_truth_table():
382386
global truth_table_data1
383387

384388
truth_table_data = [
385-
{'column-1': 'Channel 1', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch1)]}'},
386-
{'column-1': 'Channel 2', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch2)]}'},
387-
{'column-1': 'Channel 3', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch3)]}'},
388-
{'column-1': 'Channel 4', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch4)]}'},
389+
{'column-1': ' Channel 1 ', 'column-2': f' {modulation_map[str(truth)]}', 'column-3': f' {modulation_map[str(estimated_ch1)]}'},
390+
{'column-1': ' Channel 2 ', 'column-2': f' {modulation_map[str(truth)]}', 'column-3': f' {modulation_map[str(estimated_ch2)]}'},
391+
{'column-1': ' Channel 3 ', 'column-2': f' {modulation_map[str(truth)]}', 'column-3': f' {modulation_map[str(estimated_ch3)]}'},
392+
{'column-1': ' Channel 4 ', 'column-2': f' {modulation_map[str(truth)]}', 'column-3': f' {modulation_map[str(estimated_ch4)]}'},
389393
]
390394

391395
truth_table_data1 = [
392-
{'column-1': 'Channel 1', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch5)]}'},
393-
{'column-1': 'Channel 2', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch6)]}'},
394-
{'column-1': 'Channel 3', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch7)]}'},
395-
{'column-1': 'Channel 4', 'column-2': f'{modulation_map[str(truth)]}', 'column-3': f'{modulation_map[str(estimated_ch8)]}'},
396+
{'column-1': 'Channel 1', 'column-2': f'{modulation_map[str(truth1)]}', 'column-3': f'{modulation_map[str(estimated_ch5)]}'},
397+
{'column-1': 'Channel 2', 'column-2': f'{modulation_map[str(truth1)]}', 'column-3': f'{modulation_map[str(estimated_ch6)]}'},
398+
{'column-1': 'Channel 3', 'column-2': f'{modulation_map[str(truth1)]}', 'column-3': f'{modulation_map[str(estimated_ch7)]}'},
399+
{'column-1': 'Channel 4', 'column-2': f'{modulation_map[str(truth1)]}', 'column-3': f'{modulation_map[str(estimated_ch8)]}'},
396400
]
397401

398-
399-
400-
401-
402402
app.layout = html.Div([
403403
html.Div([
404404
html.Img(src='/assets/ADI_logo.svg', style={'height': '45px', 'margin-right': '16px', 'vertical-align': 'middle'}),
405405
html.H1('High-Performance Analog Meets AI', style={'display': 'inline-block', 'vertical-align': 'middle', 'fontSize': '46px'})
406406
], style={'width': '100%', 'text-align': 'left', 'padding': '5px', 'border-bottom': '1px solid #B7BBC3', 'backgroundColor': '#FFFFFF', 'font-family': 'Barlow', 'align-items': 'center'}),
407407

408408
html.Div([
409-
html.H2('ADRV9009ZU11EG device 1', style={'text-align': 'center', 'margin-top': '2%', 'font-family': 'Barlow','height': '10%'}),
409+
html.H2('First ADRV9009ZU11eg', style={'text-align': 'center', 'font-family': 'Barlow','padding': '25px'}),
410410
html.Div([
411-
dcc.Graph(id='confusion-matrix', style={'width': '40%','height': '100%' ,'display': 'inline-block'}),
411+
dcc.Graph(id='confusion-matrix', style={'width': '40%','height': '40%','display': 'inline-block'}),
412412
dash_table.DataTable(
413413
id='truth-table',
414414
columns=[
415-
{'name': 'Channel', 'id': 'column-1'},
416-
{'name': 'Estimated', 'id': 'column-2'},
417-
{'name': 'Truth', 'id': 'column-3'},
415+
{'name': 'Channel' , 'id': 'column-1'},
416+
{'name': 'Truth' , 'id': 'column-2'},
417+
{'name': 'Estimated' , 'id': 'column-3'},
418418
],
419419
data=truth_table_data,
420-
style_cell={'textAlign': 'center', 'fontSize': '20px', 'font-family': 'Barlow'},
421-
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '25px'},
422-
style_table={'width': '25%','height': '100%', 'display': 'inline-block','margin-top': '50%','vertical-align': 'middle'}
420+
style_cell={'textAlign': 'center', 'fontSize': '15px', 'font-family': 'Barlow','padding': '10px'},
421+
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '15px'},
422+
style_table={'width': '20%','height': '40%', 'display': 'inline-block','margin-top': '50%','vertical-align': 'middle'}
423423
),
424-
dcc.Graph(id='modulated-data', style={'width': '40%','height': '100%' ,'display': 'inline-block'})
424+
dcc.Graph(id='modulated-data', style={'width': '40%' ,'height': '40%','display': 'inline-block'})
425425
], style={'display': 'flex', 'justify-content': 'space-between', 'width': '100%','height': '90%'})],
426-
style={'width': '98%', 'height': '65%', 'margin-left': '1%', 'backgroundColor': 'transparent', 'border-radius': '20px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow', 'fontSize': '20px'}),
426+
style={'width': '98%', 'height': '55%', 'margin-left': '1%', 'backgroundColor': 'transparent', 'border-radius': '20px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow', 'fontSize': '20px'}),
427427
html.Div(
428428
dash_table.DataTable(
429429
id='example-table',
430430
columns=[
431-
{'name': 'Accuracy', 'id': 'column-1'},
431+
{'name': 'Accuracy' , 'id': 'column-1'},
432432
{'name': 'Precision', 'id': 'column-2'},
433-
{'name': 'Recall', 'id': 'column-3'},
434-
{'name': 'F1 rate', 'id': 'column-4'},
435-
{'name': 'MSE rate', 'id': 'column-5'},
436-
{'name': 'R2 rate', 'id': 'column-6'}
433+
{'name': 'Recall' , 'id': 'column-3'},
434+
{'name': 'F1 rate' , 'id': 'column-4'},
435+
{'name': 'MSE rate' , 'id': 'column-5'},
436+
{'name': 'R2 rate' , 'id': 'column-6'}
437437
],
438438
data=table_data,
439-
style_table={'width': '90%', 'margin-left': '5%', 'margin-top': '2%', 'border-radius': '50px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow'},
439+
style_table={'width': '90%', 'margin-left': '5%', 'margin-top': '2%', 'margin-bottom': '2%', 'border-radius': '50px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow'},
440440
style_cell={'textAlign': 'center', 'fontSize': '20px', 'font-family': 'Barlow'},
441-
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '20px'}
441+
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '20px','font-family': 'Barlow'}
442442
)
443443
),
444444
html.Div([
445-
html.H2('ADRV9009ZU11EG device 2', style={'text-align': 'center', 'margin-top': '2%', 'font-family': 'Barlow','height': '10%'}),
445+
html.H2('Second ADRV9009ZU11eg', style={'text-align': 'center', 'font-family': 'Barlow','padding': '25px'}),
446446
html.Div([
447-
dcc.Graph(id='confusion-matrix1', style={'width': '40%','height': '100%' ,'display': 'inline-block'}),
447+
dcc.Graph(id='confusion-matrix1', style={'width': '40%','height': '40%','display': 'inline-block'}),
448448
dash_table.DataTable(
449449
id='truth-table1',
450450
columns=[
451-
{'name': 'Channel', 'id': 'column-1'},
452-
{'name': 'Estimated', 'id': 'column-2'},
453-
{'name': 'Truth', 'id': 'column-3'},
451+
{'name': 'Channel ' , 'id': 'column-1'},
452+
{'name': 'Truth ' , 'id': 'column-2'},
453+
{'name': 'Estimated ' , 'id': 'column-3'},
454454
],
455455
data=truth_table_data1,
456-
style_cell={'textAlign': 'center', 'fontSize': '20px', 'font-family': 'Barlow'},
457-
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '25px'},
458-
style_table={'width': '25%','height': '100%', 'display': 'inline-block','margin-top': '50%','vertical-align': 'middle'}
456+
style_cell={'textAlign': 'center', 'fontSize': '15px', 'font-family': 'Barlow','padding': '10px'},
457+
style_header={'backgroundColor': '#1E4056', 'color': 'white', 'font-family': 'Barlow', 'fontSize': '15px'},
458+
style_table={'width': '100%', 'height': '40%','display': 'inline-block','margin-top': '50%','vertical-align': 'middle','font-family': 'Barlow'}
459459
),
460-
dcc.Graph(id='modulated-data1', style={'width': '40%','height': '100%' ,'display': 'inline-block'})
460+
dcc.Graph(id='modulated-data1', style={'width': '40%','height': '40%','display': 'inline-block'})
461461
], style={'display': 'flex', 'justify-content': 'space-between', 'width': '100%','height': '90%'})],
462-
style={'width': '98%', 'height': '65%', 'margin-left': '1%', 'backgroundColor': 'transparent', 'border-radius': '20px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow', 'fontSize': '20px'}),
462+
style={'width': '98%', 'height': '55%', 'margin-left': '1%', 'backgroundColor': 'transparent', 'border-radius': '20px', 'box-shadow': '10px 10px 20px rgba(0, 0, 0, 0.2)', 'font-family': 'Barlow', 'fontSize': '20px'}),
463463
dcc.Interval(
464464
id='interval-component',
465-
interval=1*1000, # in milliseconds
465+
interval=3*1000, # in milliseconds
466466
n_intervals=0
467467
)
468468
], style={'font-family': 'Barlow'})
@@ -495,6 +495,7 @@ def update_graph_live(n):
495495
sdr.tx_ensm_mode_chan0 = "rf_enabled"
496496
sdr.tx_ensm_mode_chan1 = "rf_enabled"
497497
sdr.tx_cyclic_buffer = True
498+
sdr.tx2_cyclic_buffer = True
498499
sdr.tx0_lo = 2400000000
499500
sdr.tx1_lo = 2400000000
500501
sdr.tx_hardwaregain_chan0 = -10
@@ -544,4 +545,20 @@ def update_graph_live(n):
544545
sdr3.tx_hardwaregain_chan0 = -10
545546
sdr3.tx_hardwaregain_chan1 = -10
546547

547-
app.run_server(debug=True)
548+
sdr.tx0_en = 1
549+
sdr.tx1_en = 1
550+
sdr1.tx0_en = 1
551+
sdr1.tx1_en = 1
552+
sdr2.tx0_en = 1
553+
sdr2.tx1_en = 1
554+
sdr3.tx0_en = 1
555+
sdr3.tx1_en = 1
556+
557+
558+
559+
560+
561+
562+
563+
564+
app.run_server(debug=True)

0 commit comments

Comments
 (0)