Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cs
util
sequencer
scan-p-gun-vgrid
Commits
1a0dbd20
Commit
1a0dbd20
authored
Nov 21, 2022
by
Francesco Tripaldi
Browse files
Add TopUp voltage on graph
parent
b298d6f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/ScanPGunVgrid.py
View file @
1a0dbd20
...
...
@@ -125,7 +125,10 @@ def main():
y1
=
(
4
*
x1
**
2
-
2
)
*
np
.
exp
(
-
x1
**
2
)
/
smooth_width
*
8
#norm*(x1[1]-x1[0])
yp
=
p
(
xp
)
topup_grid
=
xp
[
np
.
abs
(
yp
-
0.25
).
argmin
()]
xop
=
xp
[:
np
.
where
(
yp
==
np
.
amax
(
yp
))[
0
][
0
]]
topup_grid
=
float
(
xop
[
np
.
abs
(
yp
-
0.25
).
argmin
()])
top_up_current
=
float
(
yp
[
np
.
abs
(
yp
-
0.25
).
argmin
()])
try
:
selfseq_dev
.
write_attribute
(
"topup_voltage"
,
topup_grid
)
except
:
...
...
@@ -147,8 +150,8 @@ def main():
max_current
=
max
(
current_peaks
)
#max_index = yp.index(max_current)
max_index
=
np
.
where
(
yp
==
max_current
)[
0
]
best_vgrid
=
float
(
xp
[
max_index
])
best_current
=
float
(
yp
[
max_index
])
best_vgrid
=
float
(
xp
[
max_index
-
4
])
best_current
=
float
(
yp
[
max_index
-
4
])
if
topup_test_mode
==
True
:
if
topup_grid
>
0
:
gun_dev
.
write_attribute
(
'FastGridVoltage'
,
topup_grid
)
...
...
@@ -178,7 +181,7 @@ def main():
# opacity='.6',
# opacity_hover='.9',
# transition='400ms ease-in',
colors
=
(
'#0066ff'
,
'#ff8000'
,
'#
ff3399'
,
'#E87653'
,
'#E89B53
'
))
colors
=
(
'#0066ff'
,
'#ff8000'
,
'#
33cc33'
,
'#ff3399'
,
'#0033cc
'
))
if
topup_test_mode
==
True
:
...
...
@@ -202,8 +205,11 @@ def main():
line_chart
.
add
(
"Fitting"
,
super_data2
,
show_dots
=
False
)
line_chart
.
title
=
str
(
graph_title
)
line_chart
.
add
(
'TopUp Vgrid:'
+
"{:.2f}"
.
format
(
topup_grid
)
+
'V'
,
[(
topup_grid
,
top_up_current
)],
dots_size
=
8
)
if
plot_best_vgrid
==
True
:
line_chart
.
add
(
'Best Vgrid:'
+
"{:.2f}"
.
format
(
best_vgrid
)
+
'V'
,
[(
best_vgrid
,
best_current
)],
dots_size
=
12
)
graph_svg
=
line_chart
.
render
(
style
=
custom_style
)
file_buffer
=
[(
'file'
,(
'booster_performance'
+
datetime
.
now
().
strftime
(
"%d-%m-%Y-%H-%M-%S-n"
)
+
'.svg'
,
graph_svg
,
'image/svg+xml'
))]
fig2elog
(
file_buffer
,
elog_text
)
...
...
src/test.py
deleted
100755 → 0
View file @
b298d6f5
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import
numpy
as
np
import
requests
from
datetime
import
datetime
print
(
'ou'
)
def
fig2elog
(
file_buffer
,
text
,
elog_url
=
'http://elog.elettra.eu/upload/upload.php'
,
text_after
=
''
):
try
:
rs
=
requests
.
post
(
elog_url
,
files
=
file_buffer
,
data
=
{
'string'
:
text
,
'string_after'
:
text_after
})
print
(
rs
)
print
(
rs
.
content
.
decode
())
except
Exception
as
e
:
selfseq_dev
.
write_attribute
(
"ScriptErr"
,
f
"
{
type
(
e
).
__name__
}
while connection to website:
{
e
}
"
)
# scrive l'eventuale errore sull'attributo "ScriptErr" della sequenza
pass
X
=
np
.
linspace
(
16.5
,
28
,
10
)
Y
=
[
0
,
0
,
0.2
,
0.3
,
0.5
,
0.5
,
0.4
,
0.3
,
0.3
,
0.3
]
smooth_width
=
50
z
=
np
.
polyfit
(
X
,
Y
,
5
)
p
=
np
.
poly1d
(
z
)
xp
=
np
.
linspace
(
16.5
,
28
,
smooth_width
)
publish_to_elog
=
True
topup_test_mode
=
False
elog_text
=
'Scan booster test'
graph_title
=
'Booster scan'
best_vgrid
=
22
best_current
=
0.5
plot_best_vgrid
=
True
if
True
:
if
publish_to_elog
==
True
:
import
pygal
from
pygal.style
import
Style
super_data
=
[]
super_data2
=
[]
yrange
=
()
custom_style
=
Style
(
#background='transparent',
#plot_background='transparent',
major_label_font_size
=
12
,
label_font_size
=
12
,
# foreground='#53E89B',
# foreground_strong='#53A0E8',
# foreground_subtle='#630C0D',
# opacity='.6',
# opacity_hover='.9',
# transition='400ms ease-in',
colors
=
(
'#0066ff'
,
'#ff8000'
,
'#ff3399'
,
'#E87653'
,
'#E89B53'
))
if
topup_test_mode
==
True
:
y_range
=
(
0
,
0.6
)
else
:
y_range
=
(
0
,
1.6
)
for
index
,
data
in
enumerate
(
Y
):
super_data
.
append
((
X
[
index
],
Y
[
index
]))
line_chart
=
pygal
.
XY
(
explicit_size
=
True
,
height
=
550
,
width
=
500
,
legend_at_bottom
=
True
,
human_readable
=
True
,
style
=
custom_style
,
x_title
=
'GUN Vgrid (V)'
,
y_title
=
'Booster current (mA)'
,
range
=
y_range
)
#, x_labels_major_count=5)#,show_minor_x_labels=False)
line_chart
.
add
(
"GUN Vgrid scan data"
,
super_data
)
yp
=
p
(
xp
)
for
index2
,
data2
in
enumerate
(
yp
):
super_data2
.
append
((
xp
[
index2
],
yp
[
index2
]))
line_chart
.
add
(
"Fitting"
,
super_data2
,
show_dots
=
False
)
line_chart
.
title
=
str
(
graph_title
)
if
plot_best_vgrid
==
True
:
line_chart
.
add
(
'Best Vgrid:'
+
"{:.2f}"
.
format
(
best_vgrid
)
+
'V'
,
[(
best_vgrid
,
best_current
)],
dots_size
=
12
)
graph_svg
=
line_chart
.
render
(
style
=
custom_style
)
file_buffer
=
[(
'file'
,(
'booster_performance'
+
datetime
.
now
().
strftime
(
"%d-%m-%Y-%H-%M-%S-n"
)
+
'.svg'
,
graph_svg
,
'image/svg+xml'
))]
fig2elog
(
file_buffer
,
elog_text
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment