Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iexcode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
29id
iexcode
Commits
c9f64df1
Commit
c9f64df1
authored
2 years ago
by
29iduser
Browse files
Options
Downloads
Patches
Plain Diff
dubug
parent
c8519496
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
iexcode/instruments/xrays.py
+1
-0
1 addition, 0 deletions
iexcode/instruments/xrays.py
iexcode/macros/commissioning.py
+1
-1
1 addition, 1 deletion
iexcode/macros/commissioning.py
iexcode/macros/start_of_the_week.py
+205
-173
205 additions, 173 deletions
iexcode/macros/start_of_the_week.py
with
207 additions
and
174 deletions
iexcode/instruments/xrays.py
+
1
−
0
View file @
c9f64df1
...
...
@@ -9,6 +9,7 @@ from time import sleep
from
epics
import
caget
,
caput
import
iexcode.instruments.cfg
as
iex
from
iexcode.instruments.conversions_constants
import
*
from
iexcode.instruments.SRS_current_amplifiers
import
*
from
iexcode.instruments.Keithley_current_amplifiers
import
*
from
iexcode.instruments.diagnostics
import
*
...
...
This diff is collapsed.
Click to expand it.
iexcode/macros/commissioning.py
+
1
−
1
View file @
c9f64df1
...
...
@@ -604,7 +604,7 @@ def M0M1_steering(h_position,v_position,verbose=False):
def
monoVslit_quick_scan
(
slit_name
,
**
kwargs
):
def
monoVslit_quick_scan
(
slit_name
,
**
kwargs
):
"""
sets the slit to be narrow and scans along and across the grating
at 500 eV to see if M0/M1 are steering the beam to the center of the grating
...
...
This diff is collapsed.
Click to expand it.
iexcode/macros/start_of_the_week.py
+
205
−
173
View file @
c9f64df1
...
...
@@ -123,6 +123,202 @@ def interactive_fit_mda(val_name,scannum,det,FWHM_or_PolyOrder,fct,**kwargs):
flagfit
=
2
return
flagfit
,
val
def
sotw_BLinit
(
branch
):
"""
returns the init function for sotw
"""
if
branch
==
'
c
'
:
BL_init
=
ARPES_init
elif
branch
==
'
d
'
:
BL_init
=
kappa_init
else
:
print_warning_message
(
'
Not a valid branch
'
)
BL_init
=
None
return
BL_init
def
sotw_setup
(
grt
,
branch
,
wait
,
**
kwargs
):
"""
All the start_of_the_week initalization stuff
doesn
'
t get run if kwargs[
'
repeat
'
]=False
"""
# checkin branch is defined and initializing BLconfig
branch
=
branch
.
lower
()
BL_init
=
sotw_BLinit
(
branch
)
if
branch
==
'
d
'
:
cam_exposure_time
(
m3r_camNum
,
0.001
)
BL_init
(
'
staff
'
,
reset
=
True
,
set_folders
=
True
,
xrays
=
True
)
switch_branch
(
branch
)
log_name_set
(
'
StartOfTheWeek_log.txt
'
)
log_print
(
"
\n\n
================== Start Of The Week @
"
+
today
(
'
slash
'
)
+
'
:
\n
'
)
#switching grating if needed
grating
(
grt
)
###########################################################################
### stuff that requires beam
###########################################################################
### Wait for next 8AM:
if
wait
:
t
=
datetime
.
today
()
if
0
<=
t
.
hour
<=
8
:
wait_for_it
(
0
,
8
,
5
)
else
:
wait_for_it
(
1
,
8
,
5
)
### checking branch shutter:
branch_shutter_open
()
main_shutter_open
()
if
main_shutter_status
()
==
False
:
print_warning_message
(
'
Aborting... main shutter did not open
'
)
return
if
branch_shutter_status
()
==
False
:
print_warning_message
(
'
Aborting...
'
+
branch
+
'
-branch shutter did not open
'
)
return
### checking QP ratio:
QP
=
ID_QP_ratio_get
()[
0
]
if
QP
!=
100
:
foo
=
input
(
'
QP on!!! Continue (y or n)? >
'
)
if
foo
.
lower
()
==
'
y
'
or
foo
.
lower
()
==
'
yes
'
:
status
=
'
Continueing
'
else
:
status
=
'
Aborting...
'
print
(
status
)
return
### checking ID:
polarization
(
kwargs
[
'
mode
'
])
def
sotw_ID_steering
(
detCA4
,
**
kwargs
):
"""
slit1A/ID_steering
"""
#scanning
ID_steering_scans
(
**
kwargs
)
#plotting
scanNum_h
=
last_mda
()
-
1
scanNum_v
=
last_mda
()
flagfit
,
h
=
interactive_fit_mda
(
'
H_center
'
,
scanNum_h
,
detCA4
,
1
,
'
gauss
'
,
xrange
=
[
-
1
,
1
])
if
flagfit
==
''
:
return
flagfit
,
v
=
interactive_fit_mda
(
'
V_center
'
,
scanNum_v
,
detCA4
,
1
,
'
gauss
'
,
xrange
=
[
-
1
,
1
],
val_name
=
'
V_center
'
)
if
flagfit
==
''
:
return
try
:
ID_steering_message
(
h
,
v
)
flag
=
interactive_fct
()
except
:
print
(
'
\n
Unable to calculate ID steering
'
)
print
(
'
steering out => move beam more positive (10 urad ~ 0.25 mm)
'
)
print
(
'
steering up => move beam more positive (10 urad ~ 0.25 mm)
'
)
flag
=
interactive_fct
()
return
flag
def
sotw_wire
(
detH
,
detV
,
**
kwargs
):
"""
"""
#scanning
wire_scans
(
**
kwargs
)
#plotting
try
:
scanNum_h
=
last_mda
()
-
1
scanNum_v
=
last_mda
()
plot_mda
(
scanNum_h
,
detH
,
scanNum_v
,
detV
,
title
=
'
wire-H (blue) & wire-V (orange)
'
);
plt
.
show
()
except
:
print
(
'
Unable to plot. Try:
'
)
print
(
"
plot_mda(
"
+
str
(
scanNum_h
)
+
"
,
"
+
str
(
detH
)
+
"
,
"
+
str
(
scanNum_v
)
+
"
,
"
+
str
(
detV
)
+
"
,title=
'
wire-H (blue) & wire-V (orange)
'
);plt.show()
"
)
flag
=
interactive_fct
()
return
flag
def
sotw_slit_vs_mono
(
grt
,
slit_name
,
detDiode
,
**
kwargs
):
"""
"""
for
slit_name
in
[
'
slit2B
'
,
'
slit1A
'
]:
message
=
{
'
slit2B
'
:
'
M1 alignment and slit center
'
,
'
slit1A
'
:
'
slit center
'
}
print
(
'
\n
---------- Scanning
'
+
slit_name
+
'
:
\n
'
)
message
[
slit_name
]
flag
=
2
list_position
=
[
grt
,
0
,
0
,
0
,
0
]
flag
=
2
while
flag
>
1
:
#scanning
if
kwargs
[
'
monoVslit_quick
'
]:
monoVslit_quick_scan
(
slit_name
,
**
kwargs
)
else
:
monoVslit_full_profile_scan
(
slit_name
,
**
kwargs
)
#plotting
c
=
mono_grating_density_get
()
/
1200
scanNum_v
=
last_mda
()
-
1
scanNum_h
=
last_mda
()
if
kwargs
[
'
monoVslit_quick
'
]:
flagfit
,
h
=
interactive_fit_mda
(
'
H_center
'
,
scanNum_h
,
detDiode
,
1
,
'
gauss
'
,
xrange
=
[
-
1
,
1
])
if
flagfit
==
''
:
return
flagfit
,
v
=
interactive_fit_mda
(
'
V_center
'
,
scanNum_v
,
detDiode
,
c
,
'
gauss
'
,
xrange
=
[
-
1
,
1
])
if
flagfit
==
''
:
return
flag
=
interactive_fct
()
print
(
'
\n
Beam position -
'
+
slit_name
[
-
2
:]
+
'
:
'
)
print
(
f
"
- vertical: V =
{
round
(
v
,
3
)
}
"
)
print
(
f
"
- horizontal: H =
{
round
(
h
,
3
)
}
"
)
if
slit_name
==
'
slit2B
'
:
#beam steering calculations
new_roll
=
M0M1_steering
(
h
,
v
)
list_position
[
2
]
=
v
list_position
[
1
]
=
h
foo
=
input
(
'
\n
Do you want to steer M1 (y or n)?
'
)
if
foo
[
0
].
lower
()
==
'
y
'
:
new_roll
=
input2float
(
'
New M1 roll value =>
'
,
new_roll
)
try
:
FMB_mirror_move
(
1
,
'
RZ
'
,
new_roll
)
sleep
(
2
)
FMB_mirror_get
(
1
)
print
(
'
\n
repeating scans...
'
)
flag
==
2
except
:
print
(
'
\invalid input; unable to move M1
'
)
flag
=
interactive_fct
()
#update M1 dictionary
foo
=
input
(
'
Do you want to update the M1 (y or n)? >
'
)
if
foo
[
0
].
lower
()
==
'
y
'
:
update_mirror_dict
(
1
)
if
flag
==
''
:
return
elif
slit_name
==
'
slit1A
'
:
list_position
[
4
]
=
v
list_position
[
3
]
=
h
if
flag
==
''
:
return
flag
=
2
#update slit dictionary
print
(
'
\n
Beam center fit @ [
'
+
grt
+
'
,2V,2H,1V,1H]:
'
+
str
(
list_position
))
foo
=
input
(
'
Do you want to update the slit dictionary (y or n)? >
'
)
if
foo
[
0
].
lower
()
==
'
y
'
:
slit_list
=
input
(
'
do you want to use
'
+
str
(
list_position
)
+
'
(y or n)? >
'
)
if
foo
[
0
].
lower
()
==
'
y
'
:
update_slit_dict
(
list_position
)
else
:
update_slit_dict
()
def
StartOfTheWeek
(
grt
,
branch
,
wait
=
False
,
**
kwargs
):
"""
This should be run every at the start of every week; 50 min total.
...
...
@@ -168,69 +364,14 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs):
print_warning_message
(
scan
+
"
is not a valid scan scanType=[
'
slit1
'
,
'
wire
'
,
'
flux
'
,
'
monoVslit
'
]
"
)
return
# checkin branch is defined and initializing BLconfig
branch
=
branch
.
lower
()
if
branch
==
'
c
'
:
BL_init
=
ARPES_init
elif
branch
==
'
d
'
:
BL_init
=
kappa_init
cam_exposure_time
(
m3r_camNum
,
0.001
)
else
:
print_warning_message
(
'
Not a valid branch
'
)
return
if
kwargs
[
'
repeat
'
]:
#check to see if init is defined
BL_init
=
sotw_BLinit
(
branch
)
if
BLconfig_branch
()
!=
branch
:
BL_init
(
'
staff
'
,
reset
=
True
,
set_folders
=
False
,
xrays
=
True
)
else
:
BL_init
(
'
staff
'
,
reset
=
True
,
set_folders
=
True
,
xrays
=
True
)
switch_branch
(
branch
)
log_name_set
(
'
StartOfTheWeek_log.txt
'
)
log_print
(
"
\n\n
================== Start Of The Week @
"
+
today
(
'
slash
'
)
+
'
:
\n
'
)
#switching grating if needed
grating
(
grt
)
###########################################################################
### stuff that requires beam
###########################################################################
### Wait for next 8AM:
if
wait
:
t
=
datetime
.
today
()
if
0
<=
t
.
hour
<=
8
:
wait_for_it
(
0
,
8
,
5
)
else
:
wait_for_it
(
1
,
8
,
5
)
### checking branch shutter:
branch_shutter_open
()
main_shutter_open
()
if
main_shutter_status
()
==
False
:
print_warning_message
(
'
Aborting... main shutter did not open
'
)
return
if
branch_shutter_status
()
==
False
:
print_warning_message
(
'
Aborting...
'
+
branch
+
'
-branch shutter did not open
'
)
return
sotw_setup
(
grt
,
branch
,
wait
,
**
kwargs
)
### checking QP ratio:
QP
=
ID_QP_ratio_get
()[
0
]
if
QP
!=
100
:
foo
=
input
(
'
QP on!!! Continue (y or n)? >
'
)
if
foo
.
lower
()
==
'
y
'
or
foo
.
lower
()
==
'
yes
'
:
status
=
'
Continueing
'
else
:
status
=
'
Aborting...
'
print
(
status
)
return
### checking ID:
polarization
(
kwargs
[
'
mode
'
])
### Ready to start:
scanNum
=
mda_fileNum
()
###########################################################################
### scanning
###########################################################################
...
...
@@ -240,140 +381,31 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs):
print
(
"
\n\n
================== Slit 1A scans:
"
)
flag
=
2
while
flag
>
1
:
#scanning
ID_steering_scans
(
**
kwargs
)
#plotting
scanNum_h
=
last_mda
()
-
1
scanNum_v
=
last_mda
()
flagfit
,
h
=
interactive_fit_mda
(
'
H_center
'
,
scanNum_h
,
detCA4
,
1
,
'
gauss
'
,
xrange
=
[
-
1
,
1
])
if
flagfit
==
''
:
return
flagfit
,
v
=
interactive_fit_mda
(
'
V_center
'
,
scanNum_v
,
detCA4
,
1
,
'
gauss
'
,
xrange
=
[
-
1
,
1
],
val_name
=
'
V_center
'
)
if
flagfit
==
''
:
return
try
:
ID_steering_message
(
h
,
v
)
flag
=
interactive_fct
()
except
:
print
(
'
\n
Unable to calculate ID steering
'
)
print
(
'
steering out => move beam more positive (10 urad ~ 0.25 mm)
'
)
print
(
'
steering up => move beam more positive (10 urad ~ 0.25 mm)
'
)
flag
=
interactive_fct
()
flag
=
sotw_ID_steering
(
detCA4
,
**
kwargs
)
if
flag
==
''
:
return
diagnostic
(
'
mesh_W
'
,
'
out
'
)
###### Wire scans:
if
'
wire
'
in
kwargs
[
'
scanType
'
]:
print
(
"
\n\n
================== Slit 1A scans:
"
)
#scanning
wire_scans
(
**
kwargs
)
#plotting
try
:
scanNum_h
=
last_mda
()
-
1
scanNum_v
=
last_mda
()
plot_mda
(
scanNum_h
,
detH
,
scanNum_v
,
detV
,
title
=
'
wire-H (blue) & wire-V (orange)
'
);
plt
.
show
()
except
:
print
(
'
Unable to plot. Try:
'
)
print
(
"
plot_mda(
"
+
str
(
scanNum_h
)
+
"
,
"
+
str
(
detH
)
+
"
,
"
+
str
(
scanNum_v
)
+
"
,
"
+
str
(
detV
)
+
"
,title=
'
wire-H (blue) & wire-V (orange)
'
);plt.show()
"
)
flag
=
sotw_wire
(
detH
,
detV
,
**
kwargs
)
if
flag
==
''
:
return
###### Mono/slit scans:
if
'
monoVslit
'
in
kwargs
[
'
scanType
'
]:
#checking that detDiode is in
if
not
kwargs
[
'
detDiode
'
]:
foo
=
input
(
'
What is the detector number for mono scans (make sure it is IN!)? >
'
)
detDiode
=
int
(
foo
)
else
:
foo
=
input
(
'
Is detector D
'
+
str
(
kwargs
[
'
detDiode
'
])
+
'
in direct beam (y or n)? >
'
)
print
(
"
\n\n
================== Mono/slit scans:
"
)
for
slit_name
in
[
'
slit2B
'
,
'
slit1A
'
]:
# slit2B => M1 alignment
print
(
'
\n
---------- Scanning
'
+
slit_name
+
'
:
\n
'
)
flag
=
2
list_position
=
[
grt
,
0
,
0
,
0
,
0
]
while
flag
>
1
:
#scanning
if
kwargs
[
'
monoVslit_quick
'
]:
monoVslit_quick_scan
(
slit_name
,
**
kwargs
)
else
:
monoVslit_full_profile_scan
(
slit_name
,
**
kwargs
)
#plotting
c
=
mono_grating_density_get
()
/
1200
scanNum_v
=
last_mda
()
-
1
scanNum_h
=
last_mda
()
if
kwargs
[
'
monoVslit_quick
'
]:
flagfit
,
h
=
interactive_fit_mda
(
'
H_center
'
,
scanNum_h
,
detDiode
,
1
,
'
gauss
'
,
xrange
=
[
-
1
,
1
])
if
flagfit
==
''
:
return
flagfit
,
v
=
interactive_fit_mda
(
'
V_center
'
,
scanNum_v
,
detDiode
,
c
,
'
gauss
'
,
xrange
=
[
-
1
,
1
])
if
flagfit
==
''
:
return
flag
=
interactive_fct
()
print
(
'
\n
Beam position -
'
+
slit_name
[
-
2
:]
+
'
:
'
)
print
(
f
"
- vertical: V =
{
round
(
v
,
3
)
}
"
)
print
(
f
"
- horizontal: H =
{
round
(
h
,
3
)
}
"
)
if
slit_name
==
'
slit2B
'
:
#beam steering calculations
new_roll
=
M0M1_steering
(
h
,
v
)
list_position
[
4
]
=
v
list_position
[
3
]
=
h
foo
=
input
(
'
\n
Do you want to steer M1 (y or n)?
'
)
if
foo
[
0
].
lower
()
==
'
y
'
:
new_roll
=
input2float
(
'
New M1 roll value =>
'
,
new_roll
)
try
:
FMB_mirror_move
(
1
,
'
RZ
'
,
new_roll
)
sleep
(
2
)
FMB_mirror_get
(
1
)
print
(
'
\n
repeating scans...
'
)
flag
==
2
except
:
print
(
'
\invalid input; unable to move M1
'
)
flag
=
interactive_fct
()
elif
slit_name
==
'
slit1A
'
:
list_position
[
2
]
=
v
list_position
[
1
]
=
h
if
flag
==
''
:
return
flag
=
2
#update slit dictionary
print
(
'
\n
Beam center fit @ [
'
+
grt
+
'
,2V,2H,1V,1H]:
'
+
str
(
list_position
))
foo
=
input
(
'
Do you want to update the slit dictionary (y or n)? >
'
)
if
foo
[
0
].
lower
()
==
'
y
'
:
slit_list
=
input
(
'
do you want to use
'
+
str
(
list_position
)
+
'
(y or n)? >
'
)
if
foo
[
0
].
lower
()
==
'
y
'
:
update_slit_dict
(
list_position
)
else
:
update_slit_dict
()
#update M1 dictionary
foo
=
input
(
'
Do you want to update the M1 (y or n)? >
'
)
if
foo
[
0
].
lower
()
==
'
y
'
:
update_mirror_dict
(
1
)
if
flag
==
''
:
return
sotw_slit_vs_mono
(
grt
,
slit_name
,
detDiode
,
**
kwargs
)
###### Check flux:
if
'
flux
'
in
kwargs
[
'
scanType
'
]:
print
(
"
\n\n
================== Check Flux:
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment