Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
F-CRG
BM07
bm07
Commits
9dc74bb2
Commit
9dc74bb2
authored
Sep 14, 2021
by
Yoann Sallaz Damaz
Browse files
suite
parent
bf70105e
Pipeline
#54570
failed with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bm07/datacollection.py
View file @
9dc74bb2
...
...
@@ -21,7 +21,7 @@ def acq_externalSingle(expo_s, step_deg, start_angle_deg, end_angle_deg):
pilatus_6m
.
proxy
.
saving_directory
=
"/lima_data/pics"
pilatus_6m
.
proxy
.
saving_prefix
=
"pilatus_6m_"
pilatus_6m
.
proxy
.
saving_prefix
=
"
det%d_"
%
round
(
detfwd
.
position
)
#
pilatus_6m_"
pilatus_6m
.
proxy
.
saving_suffix
=
".cbf"
pilatus_6m
.
proxy
.
saving_index_format
=
"%04d"
pilatus_6m
.
proxy
.
saving_format
=
"CBF"
...
...
@@ -83,4 +83,49 @@ def opensh():
fastshut
.
open_manual
()
def
closesh
():
fastshut
.
close_manual
()
\ No newline at end of file
fastshut
.
close_manual
()
def
pico_moyenne
(
seconde
):
import
tango
pico
=
tango
.
DeviceProxy
(
'bm07/pico/oh'
)
pico
.
StartT
(
seconde
*
1000
)
time
.
sleep
(
seconde
+
0.5
)
dstopMoyenne
=
pico
.
ReadIBuffer
()[
4
]
/
pico
.
ReadIBuffer
()[
1
]
dMono1Moyenne
=
pico
.
ReadIBuffer
()[
2
]
/
pico
.
ReadIBuffer
()[
1
]
dMono2Moyenne
=
pico
.
ReadIBuffer
()[
3
]
/
pico
.
ReadIBuffer
()[
1
]
return
[
dstopMoyenne
,
0.5
*
(
dMono1Moyenne
+
dMono2Moyenne
)]
def
nrjcal_vYo
(
eMin
,
eMax
,
eStep
,
tMoy
):
import
numpy
as
np
txt
=
"energy beta dstop dmono
\n
"
for
e
in
np
.
arange
(
eMin
,
eMax
,
eStep
):
energy
.
move
(
e
)
counts
=
pico_moyenne
(
tMoy
)
txt
+=
"%f %f %f %f
\n
"
%
(
energy
.
position
,
beta
.
position
,
counts
[
0
],
counts
[
1
])
print
(
txt
)
def
read_mca_p0
():
mca
.
mca
.
times
[
'real_t_preset'
]
=
3
mca
.
start_acq
()
sleep
(
1
)
resp
=
mca
.
mca
.
sl
.
write_readline
(
b
"$GR 1
\r
"
)
return
int
(
resp
[
3
:])
def
nrjcal_vYo2
(
eMin
,
eMax
,
eStep
,
tMoy
):
import
numpy
as
np
mca
.
mca
.
times
[
'real_t_preset'
]
=
tMoy
mca
.
set_roi
(
2.0
,
15.0
,
channel
=
1
,
element
=
"Se"
,
atomic_nb
=
34
)
txt
=
"energy beta dstop dmono
\n
"
for
e
in
np
.
arange
(
eMin
,
eMax
,
eStep
):
energy
.
move
(
e
)
mca
.
start_acq
()
counts
=
pico_moyenne
(
tMoy
)
resp
=
mca
.
mca
.
sl
.
write_readline
(
b
"$GR 1
\r
"
)
p0
=
int
(
resp
[
3
:])
txt
+=
"%f %f %f %f %f
\n
"
%
(
energy
.
position
,
beta
.
position
,
p0
,
counts
[
0
],
counts
[
1
])
print
(
txt
)
\ No newline at end of file
bm07/grob_FIP.py
View file @
9dc74bb2
...
...
@@ -272,16 +272,21 @@ class grob_FIP(object):
self
.
dstop
=
get_config
().
get
(
self
.
config
[
"dstop"
])
self
.
wago
=
self
.
config
[
"wago"
]
self
.
keyence
=
get_config
().
get
(
self
.
config
[
"keyence"
])
self
.
heatgun
=
self
.
config
[
"heatgun"
]
self
.
real_device_init
=
True
def
_move_gonio
(
self
,
motor_list_first
,
target_list_first
,
motor_list_next
,
target_list_next
,
checkonly
=
False
):
for
motor_list
,
target_list
in
((
motor_list_first
,
target_list_first
),
(
motor_list_next
,
target_list_next
)):
if
not
checkonly
:
for
mot
,
target
in
list
(
zip
(
motor_list
,
target_list
)):
mot
.
move
(
target
,
wait
=
False
)
if
mot
.
name
==
"kappa"
and
target
==
0
:
mot
.
reset_pos
()
else
:
mot
.
move
(
target
,
wait
=
False
)
notok
=
True
with
gevent
.
Timeout
(
15
,
False
):
...
...
@@ -365,15 +370,17 @@ class grob_FIP(object):
txt
+=
"Keyence Light on
\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
dewar
.
is_open
():
txt
+=
"Dewar Lid open
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
txt
+=
"Dewar Lid open
\t
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Dewar Lid open
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
ok
:
print
(
txt
)
if
not
checkonly
:
print
(
txt
)
return
True
else
:
time
.
sleep
(
1
)
print
(
txt
)
return
False
def
move_accessories_in_sample_collect_geo
(
self
,
checkonly
=
False
):
...
...
@@ -425,7 +432,7 @@ class grob_FIP(object):
txt
+=
"Keyence Light off
\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
dewar
.
is_close
():
txt
+=
"Dewar Lid close
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
txt
+=
"Dewar Lid close
\t
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Dewar Lid close
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
...
...
@@ -438,7 +445,7 @@ class grob_FIP(object):
def
move_motors_in_sample_mount_geo
(
self
,
checkonly
=
False
):
self
.
init_real_device
()
self
.
omega
.
velocity
=
2
0
self
.
omega
.
velocity
=
3
0
motor_list_first
=
[
self
.
omega
,
self
.
y
]
target_list_first
=
[
self
.
omega_mountsample
,
self
.
y_mountsample
]
motor_list_next
=
[
self
.
kappa
,
...
...
@@ -464,7 +471,7 @@ class grob_FIP(object):
def
move_motors_in_sample_collect_geo
(
self
,
checkonly
=
False
):
self
.
init_real_device
()
self
.
omega
.
velocity
=
2
0
self
.
omega
.
velocity
=
3
0
motor_list_first
=
[
self
.
kappa
,
self
.
x
,
self
.
z
,
...
...
@@ -529,8 +536,11 @@ class grob_FIP(object):
else
:
self
.
send_command
(
"mount_sample"
,
[
sample_number
])
time
.
sleep
(
3
)
self
.
read_all_memory
()
cryoshortactiondone
=
False
kappaactiondone
=
False
#with gevent.Timeout(15,False):
while
self
.
Status
==
2
:
#self.NumSampleMounted != sample_number:
self
.
read_all_memory
()
...
...
@@ -547,28 +557,38 @@ class grob_FIP(object):
self
.
wago
.
set
(
"magnet_boost"
,
0
)
self
.
wago
.
set
(
"magnet_degauss"
,
0
)
if
self
.
CryoShort
==
1
:
self
.
kappa
.
reset_pos
()
if
not
(
kappaactiondone
):
self
.
heatgun
.
on
(
60
)
self
.
kappa
.
reset_pos
()
kappaactiondone
=
True
if
self
.
kappa
.
position
<
10
:
self
.
cryoshort
.
down
()
if
not
(
cryoshortactiondone
):
self
.
cryoshort
.
down
()
cryoshortactiondone
=
True
time
.
sleep
(
0.1
)
if
self
.
NumSampleMounted
!=
sample_number
:
return
False
if
self
.
SIMU
:
self
.
state_grob
=
1
time
.
sleep
(
1
)
self
.
state_gonio
=
1
else
:
#gonio position for collecting sample
if
self
.
Status
==
1
:
print
(
"SampleChangerState="
,
self
.
get_state
())
if
self
.
get_state
()
in
[
SampleChangerState
.
Ready
,
SampleChangerState
.
Loading
,
SampleChangerState
.
Loaded
]:
if
not
self
.
move_motors_in_sample_collect_geo
():
print
(
'Pb with move_motors_in_sample_collect_geo'
)
return
False
if
not
self
.
move_accessories_in_sample_collect_geo
():
print
(
'Pb with move_accessories_in_sample_collect_geo'
)
return
False
if
self
.
NumSampleMounted
!=
sample_number
:
print
(
'Not the wanted sample'
)
return
False
return
True
else
:
return
True
return
False
def
dismount_sample
(
self
):
self
.
mount_sample
(
0
)
...
...
bm07/ippowerplug.py
0 → 100644
View file @
9dc74bb2
from
bliss.config
import
static
as
static_config
import
requests
class
ippowerplug
(
object
):
def
__init__
(
self
,
name
,
config
,
config_objects
=
None
):
self
.
_config_objects
=
config_objects
self
.
ip
=
config
.
get
(
"ip"
)
self
.
auth
=
requests
.
auth
.
HTTPBasicAuth
(
config
.
get
(
"login"
),
config
.
get
(
"pass"
))
self
.
url
=
"http://%s/set.cmd"
%
self
.
ip
def
__repr__
(
self
):
txt
=
"ip: %s
\n
"
%
self
.
ip
if
self
.
is_on
():
txt
+=
"ON
\n
"
else
:
txt
+=
"OFF
\n
"
return
txt
def
on
(
self
,
duration
=
None
):
if
duration
:
requests
.
get
(
self
.
url
+
"?cmd=setpower+p61=1+p61n=0+t61=%d"
%
duration
,
auth
=
self
.
auth
)
else
:
requests
.
get
(
self
.
url
+
"?cmd=setpower+p61=1"
,
auth
=
self
.
auth
)
def
off
(
self
,
duration
=
None
):
if
duration
:
requests
.
get
(
self
.
url
+
"?cmd=setpower+p61=0+p61n=1+t61=%d"
%
duration
,
auth
=
self
.
auth
)
else
:
requests
.
get
(
self
.
url
+
"?cmd=setpower+p61=0"
,
auth
=
self
.
auth
)
def
is_on
(
self
):
resp
=
requests
.
get
(
self
.
url
+
"?cmd=getpower"
,
auth
=
self
.
auth
)
#print(resp.text)
return
"p61=1"
in
resp
.
text
\ No newline at end of file
bm07/optical_setup.py
View file @
9dc74bb2
...
...
@@ -50,7 +50,8 @@ def find_energy_in_conf(nrj_target):
optical_conf
=
cc
.
get
(
"optical_setup"
)
list_selected_str
=
list
(
optical_conf
[
"selected"
].
keys
())
date_selected
=
list
(
optical_conf
[
"selected"
].
values
())
list_selected_float
=
[
float
(
i
)
for
i
in
list_selected_str
]
list_selected_dict
=
{
float
(
i
):
i
for
i
in
list_selected_str
}
list_selected_float
=
list
(
list_selected_dict
.
keys
())
list_selected_float
.
sort
()
#pas extrapolation on ne peux pas aller au dela de la plage d'energie deja alignée
...
...
@@ -58,10 +59,10 @@ def find_energy_in_conf(nrj_target):
nrj_target
=
list_selected_float
[
0
]
elif
nrj_target
>
list_selected_float
[
-
1
]:
nrj_target
=
list_selected_float
[
-
1
]
#est-ce une energie pile poile calibrée
if
nrj_target
in
list_selected_float
:
idx
=
list_selected_
float
.
index
(
nrj_target
)
idx
=
list_selected_
str
.
index
(
list_selected_dict
[
nrj_target
]
)
confdata
=
dict
(
optical_conf
.
get
(
list_selected_str
[
idx
]).
get
(
date_selected
[
idx
]))
geofipdata
=
geofip
(
nrj_target
,
VERBOSE
=
0
)
if
"alpha1"
not
in
confdata
:
...
...
@@ -71,12 +72,20 @@ def find_energy_in_conf(nrj_target):
return
confdata
#sinon interpolation
else
:
search1
=
min
(
enumerate
(
list_selected_float
),
key
=
lambda
x
:
abs
(
11
-
x
[
1
]))
search1
=
min
(
enumerate
(
list_selected_float
),
key
=
lambda
x
:
abs
(
nrj_target
-
x
[
1
]))
if
nrj_target
>
list_selected_float
[
search1
[
0
]]:
search2
=
(
search1
[
0
]
+
1
,
list_selected_float
[
search1
[
0
]
+
1
])
else
:
search2
=
(
search1
[
0
]
-
1
,
list_selected_float
[
search1
[
0
]
-
1
])
print
(
search1
)
print
(
search2
)
idx1
=
list_selected_str
.
index
(
list_selected_dict
[
list_selected_float
[
search1
[
0
]]])
idx2
=
list_selected_str
.
index
(
list_selected_dict
[
list_selected_float
[
search2
[
0
]]])
print
(
search1
)
print
(
idx1
)
print
(
search2
)
print
(
idx2
)
confdata1
=
dict
(
optical_conf
.
get
(
list_selected_str
[
search1
[
0
]]).
get
(
date_selected
[
search1
[
0
]]))
confdata2
=
dict
(
optical_conf
.
get
(
list_selected_str
[
search2
[
0
]]).
get
(
date_selected
[
search2
[
0
]]))
geofipdata1
=
geofip
(
search1
[
1
],
VERBOSE
=
0
)
...
...
@@ -106,7 +115,7 @@ def beam_set(nrj_target, mono_only=False):
final_pos_dict
=
find_energy_in_conf
(
nrj_target
)
if
final_pos_dict
is
None
:
return
return
final_pos_dict
mono_motor_name_list
=
[
"beta"
,
"utx"
,
"utz"
,
"moveh"
]
#get usefull object motor
...
...
@@ -663,3 +672,209 @@ def flux_from_diode_val(diode_mA, NRJ_keV = 12.65, Si_um = 300, Air_cm = 6, Al_u
print
(
"%e ph.s"
%
flux
)
return
"{:e}"
.
format
(
flux
)
def
nrjcal
(
nelem
):
# local pas_mot;
# pas_mot=1./4000.;
import
time
energyTab
=
{
"AU"
:
11.9208
,
"BR"
:
13.4698
,
"CO"
:
7.7093
,
"CU"
:
8.9800
,
# pmax = 0.015 , pmx2 = 0.05 ,
"FE"
:
7.1109
,
#pmax = 0.015 , pmx2 = 0.04 ,
"GD"
:
7.2429
,
"HG"
:
12.2858
,
"HO"
:
8.0672
,
"NI"
:
8.3314
,
#pmax = 0.005 , pmx2 = 0.04 ,
"PB"
:
13.0401
,
"PT"
:
11.5617
,
#pmax = 0.03 , pmx2 = 0.08 ,
"RE"
:
10.5306
,
"SE"
:
12.6540
,
"TA"
:
9.8762
,
"U"
:
17.1660
,
#pmax = 0.005 , pmx2 = 0.017 ,
"ZN"
:
9.6600
,
"YB"
:
8.9436
,
"EU"
:
6.9830
,
"TB"
:
7.5151
,
"RB"
:
15.2018
,
"KR"
:
14.3239
}
wavelengthTab
=
{}
for
key
,
value
in
energyTab
.
items
():
wavelengthTab
.
update
({
key
:(
6.62606957e-34
*
299792458
/
1.602176565E-19
)
/
1.00001501e-7
/
value
})
nitx
=
5
# valeurs generales :
pmax
=
0.02
pmx2
=
0.06
# voir aussi valeurs particulieres pour U, Ni, Fe
nbpas
=
150
#parametres de mscan:
#moteur, nb.de lissages, 1/2 domaine de scan, moniteur 1 2 ou 1/2), fichier
print
(
"
\n\n
********************************************
\n
"
)
print
(
"*** nrjcal ***
\n
"
)
print
(
"*** reglage automatique du zero mono ***
\n
"
)
print
(
"********************************************
\n\n
"
)
print
(
"
\n
filtres disponibles AU BR CU CO FE GD NI PB PT SE TA U ZN
\n\n
"
)
ene
=-
1
duree
=
1.
#epai_att1_initiale=att_readwidth(); A refaire en bliss
#parametres concernant l element#
targetEnergy
=
energyTab
[
nelem
]
targetWavelength
=
wavelengthTab
[
nelem
]
if
targetEnergy
==
0
:
print
(
"
\n
Unknown filter
\n
"
)
print
(
"
\n
**** nrjcal stopped ****
\n
"
)
print
(
"
\n
"
)
print
(
"************************
\n
"
)
print
(
" seuil absorption %s
\n
"
,
nelem
)
print
(
"************************
\n
"
)
print
(
"
\n
selected lambda %8.5f energy %8.5f
\n\n
"
,
targetWavelength
,
targetEnergy
)
print
(
"Filter is assumed to be in place...
\n
"
)
""" Calcul des pas de rotation mono pour 150 points. Remplacer par procédure BLISS
#position angulaire theorique du seuil
monot=Wavelength_to_MonoAngle(wavelengthTab[nelem]);
#position initiale
posi=mono_angle_enco();
lami=getwl();
#l increment de position est fonction de l angle
dpos=0.000075*monot;
if(dpos<pas_mot)
{
dpos=pas_mot;
}else{
ipos = int(dpos/pas_mot) ;
epos = 1. - pas_mot*ipos/dpos ;
if(epos<0.5) ipos=ipos+1.;
dpos = ipos*pas_mot ;
}
local nbpas, dmono, mono1, mono2, ecar1, ecar2;
#nbpas=70.;
nbpas=150.;
dmono=0.5*nbpas*dpos;
mono1=monot-dmono;
mono2=monot+dmono;
printf("scan %10.5f %10.5f %10.5f %8.0f
\n\n
", mono1, monot, mono2, nbpas);
ecar1=fabs(posi-mono1);
ecar2=fabs(posi-mono2);
ecart=ecar1;
if(ecar2>ecar1) ecart=ecar2 ;
if(ecart>1.)
{
printf("Mono position initial = %f
\n
", posi);
printf("ecart de position trop grand - stop
\n\n
");
return ;
}
"""
#scan en energie
#positionnement initial
"""
pos=mono1; #donner position départ du scan
mono_mva(pos) ;
pos=mono_getpos();
"""
#comptage et test initial
dstop_in
()
######### Corriger pour BLISS #########
bstop_down
()
######### Corriger pour BLISS #########
#att_setwidth(calcAttValTh(wavelengthTab[nelem])+1.2)
#calc_diode_bg(3.);
pico_read_diode
()
######### Corriger pour BLISS #########
print
(
"dstop=%d
\n
"
,
diode
[
"dstop"
])
print
(
"dmono=%d
\n
"
,
diode
[
"dmono"
])
if
diode
[
"dstop"
]
<
10
:
print
(
"CRITICAL ERROR !
\n
DSTOP moniteur very low - pas de faisceau ?
\n
EXIT
\n
"
)
bstop_in
()
dstop_out
()
#att_setwidth(epai_att1_initiale);
#mono_mva(posi);
#return ;
initCountDstop
=
diode
[
"dstop"
]
dataTab
=
[[],[],[]]
#Fait le scan en position sur mono et mesure les diodes d0 et dstop pour calculer leur rapport
# data_grp(1, 0, 0);
# data_grp(1, nbpas, 2)
for
nb
in
nbpas
:
pos
+=
dpos
;
# ! gérer index position
beam_set
()
#mvr mono dpos
pico_read_diode
()
dataTab
[
0
].
append
(
mono_angle_enco
())
#dataTab[0][nb]=mono_angle_enco()+dpos*nb;
dataTab
[
1
].
append
(
diode
[
"dstop"
])
dataTab
[
2
].
append
(
diode
[
"dmono"
])
if
(
diode
[
"dmono"
]
!=
0
):
rap
=
diode
[
"dstop"
]
/
diode
[
"dmono"
]
else
:
rap
=
1
if
nb
==
0
:
ref
=
10000.
/
rap
rap
=
ref
*
rap
dataTab
[
3
][
nb
]
=
rap
# data_put(1, nb, 0, dataTab[0][nb])
# data_put(1, nb, 1, dataTab[3][nb])
print
(
"mono angle %f --> dstop=%f dmono=%f rapport=%f
\n
"
,
dataTab
[
0
][
nb
],
diode
[
"dstop"
],
diode
[
"dmono"
],
dataTab
[
3
][
nb
])
#array_plot(1) créer graphe
#calcul fenetre de lissage
hamminWin
=
[]
hamminWinSum
=
0.
for
ii
in
range
(
0
,
6
,
1
):
hamminWin
[
ii
]
=
0.54
-
0.46
*
cos
(
2
*
math
.
pi
*
ii
/
7.
)
hamminWinSum
+=
hamminWin
[
ii
]
#double application fenetre de lissage
# data_grp(1, 0, 0)
# data_grp(1, nbpas, 2)
for
nb
in
range
(
0
,
nbpas
,
1
):
dataTabLiss
[
nb
]
=
0
nbptLiss
=
0
for
ii
in
range
(
0
,
6
,
1
):
if
nb
-
3
+
ii
>=
0
and
nb
-
3
+
ii
<
nbpas
:
dataTabLiss
[
nb
]
+=
hamminWin
[
ii
]
*
dataTab
[
3
][
nb
-
3
+
ii
]
nbptLiss
+=
hamminWin
[
ii
]
if
nbptLiss
!=
0
:
dataTabLiss
[
nb
]
/=
nbptLiss
# data_put(1, nb, 0, dataTab[0][nb])
# data_put(1, nb, 1, dataTabLiss[nb])
# array_plot(1); Ajouter graphe
#calcul de la derivée
#on commence a 6 et on fini 6 avant la fin parce que les lissages sont mauvais au bord.
for
nb
in
range
(
6
,
nbpas
-
6
,
1
)
:
Yderive
[
nb
-
6
]
=
(
dataTabLiss
[
nb
]
-
dataTabLiss
[
nb
-
1
])
/
(
dataTab
[
0
][
nb
]
-
dataTab
[
0
][
nb
-
1
])
Xderive
[
nb
-
6
]
=
(
dataTab
[
0
][
nb
]
+
dataTab
[
0
][
nb
-
1
])
/
2
#recuper la position du maximum de la derive
PosMax
=
Xderive
[
Yderive
.
index
(
max
(
Yderive
))]
print
(
"Mono angle where the transition takes place: %f
\n
"
,
PosMax
)
##########################
#Corriger le mono du delta
########################
dstop_out
()
########## Corriger pour BLISS #########
\ No newline at end of file
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