@@ -132,11 +132,11 @@ def show_tab2():
132
132
133
133
html_tab2 = html .Div (id = 'tab2' , children = [
134
134
html .Div (id = 'main-div' , children = [
135
- #html.Div(id='polynomial', children=''),
136
- #html.Div(id='output-roi', children=''),
135
+
137
136
html .Div (id = 'bar_chart_div' , children = [
138
-
139
- dcc .Interval (id = 'interval-component' , interval = millisec , n_intervals = 0 ), # Refresh rate 1s.
137
+ html .A ("Learn" , id = "tooltip-link" , href = "#" , style = {"fontSize" : "small" , "textDecoration" : "underline" , "color" : "blue" , "margin-left" :"30px" }),
138
+ dbc .Tooltip ("Click and drag to zoom • use box select to select peak • double click on chart to reset • use camera icon to save chart as png" ,target = "tooltip-link" ,placement = "right" ),
139
+ dcc .Interval (id = 'interval-component' , interval = millisec , n_intervals = 0 ),
140
140
dcc .Graph (id = 'bar_chart' ),
141
141
]),
142
142
@@ -259,7 +259,7 @@ def show_tab2():
259
259
html .Div (dcc .Input (id = 'calib_bin_4' , type = 'number' , value = calib_bin_4 , className = 'input' )),
260
260
html .Div (dcc .Input (id = 'calib_bin_5' , type = 'number' , value = calib_bin_5 , className = 'input' )),
261
261
html .Div ('peakfinder' ),
262
- html .Div (dcc .Slider (id = 'peakfinder' , min = 0 , max = 5 , step = 0. 1 , value = peakfinder , marks = {0 : '0' , 1 : '1' , 2 : '2' , 3 : '3' , 4 : '4' , 5 : '5 ' })),
262
+ html .Div (dcc .Slider (id = 'peakfinder' , min = 0 , max = 10 , step = 1 , value = peakfinder , marks = {0 :'0' ,2 : '2' , 4 : '4' , 6 : '6' , 8 : '8' , 10 : '10 ' })),
263
263
html .Div (id = 'publish-output' , children = '' ),
264
264
]),
265
265
@@ -466,6 +466,9 @@ def update_graph(n, relayoutData, isotopes, filename, epb_switch, log_switch, ca
466
466
now = datetime .now ()
467
467
date = now .strftime ('%d-%m-%Y' )
468
468
max_log_value = 0
469
+ prefixx = 'bin'
470
+ prefixy = 'cts'
471
+ min_width = 0
469
472
470
473
with global_vars .write_lock :
471
474
counts = global_vars .counts
@@ -499,7 +502,7 @@ def update_graph(n, relayoutData, isotopes, filename, epb_switch, log_switch, ca
499
502
plot_bgcolor = '#f0f0f0' ,
500
503
showlegend = False ,
501
504
height = 460 ,
502
- margin = dict (t = 20 , b = 0 , l = 0 , r = 0 ),
505
+ margin = dict (t = 50 , b = 0 , l = 0 , r = 0 ),
503
506
autosize = True ,
504
507
yaxis = dict (range = [0 , 'auto' ]),
505
508
xaxis = dict (range = [0 , 'auto' ],
@@ -527,7 +530,8 @@ def update_graph(n, relayoutData, isotopes, filename, epb_switch, log_switch, ca
527
530
528
531
if counts > 0 :
529
532
530
- prominence = 0.5
533
+ prominence = peakfinder * 1.5
534
+ min_width = peakfinder * 1
531
535
532
536
if sigma == 0 :
533
537
gaussian = []
@@ -550,6 +554,7 @@ def update_graph(n, relayoutData, isotopes, filename, epb_switch, log_switch, ca
550
554
if epb_switch :
551
555
y = [i * count for i , count in enumerate (histogram )]
552
556
gaussian = [i * count for i , count in enumerate (gaussian )]
557
+ prefixy = 'E'
553
558
554
559
trace1 = go .Bar (
555
560
x = x ,
@@ -570,14 +575,14 @@ def update_graph(n, relayoutData, isotopes, filename, epb_switch, log_switch, ca
570
575
)
571
576
fig .add_trace (trace1 )
572
577
573
- peaks , fwhm = peak_finder (y , prominence , peakfinder )
578
+ peaks , fwhm = peak_finder (y , prominence , min_width )
574
579
575
580
for i in range (len (peaks )):
576
581
peak_value = peaks [i ]
577
582
bin_counts = y [peaks [i ]]
578
583
x_pos = peaks [i ]
579
584
y_pos = y [peaks [i ]]
580
- y_pos_ann = int (y_pos * 1.05 )
585
+ y_pos_ann = int (y_pos * 1.1 )
581
586
resolution = (fwhm [i ] / peaks [i ]) * 100
582
587
583
588
if y_pos_ann > (max_value * 0.9 ):
@@ -587,10 +592,10 @@ def update_graph(n, relayoutData, isotopes, filename, epb_switch, log_switch, ca
587
592
peak_value = np .polyval (np .poly1d (coefficients_1 ), peak_value )
588
593
x_pos = peak_value
589
594
suffix = "keV"
590
- prefix = " "
595
+ prefixx = ""
591
596
else :
592
597
suffix = " "
593
- prefix = "bin "
598
+ prefixx = "bin "
594
599
595
600
if log_switch :
596
601
y_pos_ann = np .log10 (y_pos * 1.05 )
@@ -601,10 +606,12 @@ def update_graph(n, relayoutData, isotopes, filename, epb_switch, log_switch, ca
601
606
y = y_pos_ann ,
602
607
xref = 'x' ,
603
608
yref = 'y' ,
604
- text = f'cts { bin_counts } <br>{ prefix } { peak_value :.1f} { suffix } <br>{ resolution :.1f} %' ,
609
+ text = f'{ prefixy } { bin_counts } <br>{ prefixx } { peak_value :.1f} { suffix } <br>{ resolution :.1f} %' ,
605
610
font = dict (size = 10 ),
606
- align = 'center' ,
611
+ align = 'left' ,
612
+ xanchor = 'left' ,
607
613
showarrow = True ,
614
+ arrowcolor = 'red' ,
608
615
arrowhead = 0 ,
609
616
ax = 0 ,
610
617
ay = - 60 ,
@@ -625,9 +632,9 @@ def update_graph(n, relayoutData, isotopes, filename, epb_switch, log_switch, ca
625
632
fig .update_layout (
626
633
annotations = annotations ,
627
634
title = {
628
- 'text' : f'{ filename } <br>{ date } <br> { counts } valid counts<br>{ dropped_counts } lost counts<br>{ elapsed } seconds<br>{ coincidence } ' ,
629
- 'x' : 0.85 ,
630
- 'y' : 0.9 ,
635
+ 'text' : f'{ filename } <br>{ counts } valid counts<br>{ dropped_counts } lost counts<br>{ elapsed } seconds<br>{ coincidence } <br> { date } ' ,
636
+ 'x' : 0.9 ,
637
+ 'y' : 0.85 ,
631
638
'xanchor' : 'center' ,
632
639
'yanchor' : 'top' ,
633
640
'font' : {'family' : 'Arial' , 'size' : 14 , 'color' : 'black' },
0 commit comments