Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
ToolBox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SCS
ToolBox
Commits
d0b91c37
Commit
d0b91c37
authored
6 years ago
by
Laurent Mercadier
Browse files
Options
Downloads
Patches
Plain Diff
renamed calcContribSASE() to saseContribution() and fixed it
parent
70ab551b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Tim calibration table
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xgm.py
+10
-19
10 additions, 19 deletions
xgm.py
with
10 additions
and
19 deletions
xgm.py
+
10
−
19
View file @
d0b91c37
...
@@ -195,7 +195,7 @@ def selectSASEinXGM(data, sase='sase3', xgm='SCS_XGM'):
...
@@ -195,7 +195,7 @@ def selectSASEinXGM(data, sase='sase3', xgm='SCS_XGM'):
return
result
return
result
def
calc
Contrib
SASE
(
data
,
sase
=
'
sase1
'
,
xgm
=
'
SA3_XGM
'
):
def
sase
Contrib
ution
(
data
,
sase
=
'
sase1
'
,
xgm
=
'
SA3_XGM
'
):
'''
Calculate the relative contribution of SASE 1 or SASE 3 pulses
'''
Calculate the relative contribution of SASE 1 or SASE 3 pulses
for each train in the run. Supports fresh bunch, dedicated trains
for each train in the run. Supports fresh bunch, dedicated trains
and pulse on demand modes.
and pulse on demand modes.
...
@@ -211,13 +211,11 @@ def calcContribSASE(data, sase='sase1', xgm='SA3_XGM'):
...
@@ -211,13 +211,11 @@ def calcContribSASE(data, sase='sase1', xgm='SA3_XGM'):
'''
'''
xgm_sa1
=
selectSASEinXGM
(
data
,
'
sase1
'
,
xgm
=
xgm
)
xgm_sa1
=
selectSASEinXGM
(
data
,
'
sase1
'
,
xgm
=
xgm
)
xgm_sa3
=
selectSASEinXGM
(
data
,
'
sase3
'
,
xgm
=
xgm
)
xgm_sa3
=
selectSASEinXGM
(
data
,
'
sase3
'
,
xgm
=
xgm
)
if
np
.
all
(
xgm_sa1
.
trainId
.
isin
(
xgm_sa3
.
trainId
).
values
)
==
False
:
#Fill missing train ids with 0
print
(
'
Dedicated mode
'
)
r
=
xr
.
align
(
*
[
xgm_sa1
,
xgm_sa3
],
join
=
'
outer
'
,
exclude
=
[
'
XGMbunchId
'
])
r
=
xr
.
align
(
*
[
xgm_sa1
,
xgm_sa3
],
join
=
'
outer
'
,
exclude
=
[
'
SA3_XGM_dim
'
,
'
SA1_XGM_dim
'
])
xgm_sa1
=
r
[
0
].
fillna
(
0
)
xgm_sa1
=
r
[
0
]
xgm_sa3
=
r
[
1
].
fillna
(
0
)
xgm_sa1
.
fillna
(
0
)
xgm_sa3
=
r
[
1
]
xgm_sa3
.
fillna
(
0
)
contrib
=
xgm_sa1
.
sum
(
axis
=
1
)
/
(
xgm_sa1
.
sum
(
axis
=
1
)
+
xgm_sa3
.
sum
(
axis
=
1
))
contrib
=
xgm_sa1
.
sum
(
axis
=
1
)
/
(
xgm_sa1
.
sum
(
axis
=
1
)
+
xgm_sa3
.
sum
(
axis
=
1
))
if
sase
==
'
sase1
'
:
if
sase
==
'
sase1
'
:
return
contrib
return
contrib
...
@@ -300,7 +298,7 @@ def calibrateXGMs(data, rollingWindow=200, plot=False):
...
@@ -300,7 +298,7 @@ def calibrateXGMs(data, rollingWindow=200, plot=False):
print
(
'
calibration factor SA3 XGM: %f
'
%
sa3_calib_factor
)
print
(
'
calibration factor SA3 XGM: %f
'
%
sa3_calib_factor
)
# Calibrate SCS XGM with SASE3-only contribution
# Calibrate SCS XGM with SASE3-only contribution
sa3contrib
=
calc
Contrib
SASE
(
data
,
'
sase3
'
,
'
SA3_XGM
'
)
sa3contrib
=
sase
Contrib
ution
(
data
,
'
sase3
'
,
'
SA3_XGM
'
)
if
not
noSCS
:
if
not
noSCS
:
scs_sase3_fast
=
selectSASEinXGM
(
data
,
'
sase3
'
,
'
SCS_XGM
'
).
mean
(
axis
=
1
)
scs_sase3_fast
=
selectSASEinXGM
(
data
,
'
sase3
'
,
'
SCS_XGM
'
).
mean
(
axis
=
1
)
meanFast
=
scs_sase3_fast
.
rolling
(
trainId
=
rollingWindow
).
mean
()
meanFast
=
scs_sase3_fast
.
rolling
(
trainId
=
rollingWindow
).
mean
()
...
@@ -438,8 +436,8 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
...
@@ -438,8 +436,8 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
return
tim
return
tim
def
calibrateTIM
(
data
,
rollingWindow
=
200
,
mcp
=
1
,
plot
=
False
,
use_apd
=
True
,
intstart
=
None
,
intstop
=
None
,
def
calibrateTIM
(
data
,
rollingWindow
=
200
,
mcp
=
1
,
plot
=
False
,
use_apd
=
True
,
intstart
=
None
,
bkgstart
=
None
,
bkgstop
=
None
,
t_offset
=
1760
,
npulses_apd
=
None
):
intstop
=
None
,
bkgstart
=
None
,
bkgstop
=
None
,
t_offset
=
1760
,
npulses_apd
=
None
):
'''
Calibrate TIM signal (Peak-integrated signal) to the slow ion signal of SCS_XGM
'''
Calibrate TIM signal (Peak-integrated signal) to the slow ion signal of SCS_XGM
(photocurrent read by Keithley, channel
'
pulseEnergy.photonFlux.value
'
).
(photocurrent read by Keithley, channel
'
pulseEnergy.photonFlux.value
'
).
The aim is to find F so that E_tim_peak[uJ] = F x TIM_peak. For this, we want to
The aim is to find F so that E_tim_peak[uJ] = F x TIM_peak. For this, we want to
...
@@ -486,9 +484,8 @@ def calibrateTIM(data, rollingWindow=200, mcp=1, plot=False, use_apd=True, intst
...
@@ -486,9 +484,8 @@ def calibrateTIM(data, rollingWindow=200, mcp=1, plot=False, use_apd=True, intst
print
(
'
not enough consecutive data points with the largest number of pulses per train
'
)
print
(
'
not enough consecutive data points with the largest number of pulses per train
'
)
start
+=
rollingWindow
start
+=
rollingWindow
stop
=
np
.
min
((
ntrains
,
stop
+
rollingWindow
))
stop
=
np
.
min
((
ntrains
,
stop
+
rollingWindow
))
#print(start, stop)
filteredTIM
=
getTIMapd
(
data
,
mcp
,
use_apd
,
intstart
,
intstop
,
bkgstart
,
bkgstop
,
t_offset
,
npulses_apd
)
filteredTIM
=
getTIMapd
(
data
,
mcp
,
use_apd
,
intstart
,
intstop
,
bkgstart
,
bkgstop
,
t_offset
,
npulses_apd
)
sa3contrib
=
calc
Contrib
SASE
(
data
,
'
sase3
'
,
'
SA3_XGM
'
)
sa3contrib
=
sase
Contrib
ution
(
data
,
'
sase3
'
,
'
SA3_XGM
'
)
avgFast
=
filteredTIM
.
mean
(
axis
=
1
).
rolling
(
trainId
=
rollingWindow
).
mean
()
avgFast
=
filteredTIM
.
mean
(
axis
=
1
).
rolling
(
trainId
=
rollingWindow
).
mean
()
ratio
=
((
data
[
'
npulses_sase3
'
]
+
data
[
'
npulses_sase1
'
])
*
ratio
=
((
data
[
'
npulses_sase3
'
]
+
data
[
'
npulses_sase1
'
])
*
data
[
'
SCS_XGM_SLOW
'
]
*
sa3contrib
)
/
(
avgFast
*
data
[
'
npulses_sase3
'
])
data
[
'
SCS_XGM_SLOW
'
]
*
sa3contrib
)
/
(
avgFast
*
data
[
'
npulses_sase3
'
])
...
@@ -505,9 +502,7 @@ def calibrateTIM(data, rollingWindow=200, mcp=1, plot=False, use_apd=True, intst
...
@@ -505,9 +502,7 @@ def calibrateTIM(data, rollingWindow=200, mcp=1, plot=False, use_apd=True, intst
ax
.
plot
(
avgFast
*
F
,
label
=
'
Calibrated TIM rolling avg
'
,
color
=
'
C2
'
)
ax
.
plot
(
avgFast
*
F
,
label
=
'
Calibrated TIM rolling avg
'
,
color
=
'
C2
'
)
ax
.
legend
(
loc
=
'
upper left
'
,
fontsize
=
8
)
ax
.
legend
(
loc
=
'
upper left
'
,
fontsize
=
8
)
ax
.
set_ylabel
(
'
Energy [$\mu$J]
'
,
size
=
10
)
ax
.
set_ylabel
(
'
Energy [$\mu$J]
'
,
size
=
10
)
#ax2=ax#.twinx()
ax
.
plot
(
filteredTIM
.
mean
(
axis
=
1
)
*
F
,
label
=
'
Calibrated TIM train avg
'
,
alpha
=
0.2
,
color
=
'
C9
'
)
ax
.
plot
(
filteredTIM
.
mean
(
axis
=
1
)
*
F
,
label
=
'
Calibrated TIM train avg
'
,
alpha
=
0.2
,
color
=
'
C9
'
)
#ax2.set_ylabel('Calibrated TIM (MCP{}) [uJ]'.format(mcp))
ax
.
legend
(
loc
=
'
best
'
,
fontsize
=
8
,
ncol
=
2
)
ax
.
legend
(
loc
=
'
best
'
,
fontsize
=
8
,
ncol
=
2
)
plt
.
xlabel
(
'
train in run
'
)
plt
.
xlabel
(
'
train in run
'
)
...
@@ -530,10 +525,6 @@ def calibrateTIM(data, rollingWindow=200, mcp=1, plot=False, use_apd=True, intst
...
@@ -530,10 +525,6 @@ def calibrateTIM(data, rollingWindow=200, mcp=1, plot=False, use_apd=True, intst
ax
.
hist
(
filteredTIM
.
values
.
flatten
()
*
F
,
bins
=
50
,
rwidth
=
0.8
)
ax
.
hist
(
filteredTIM
.
values
.
flatten
()
*
F
,
bins
=
50
,
rwidth
=
0.8
)
ax
.
set_ylabel
(
'
number of pulses
'
,
size
=
10
)
ax
.
set_ylabel
(
'
number of pulses
'
,
size
=
10
)
ax
.
set_xlabel
(
'
Pulse energy MCP{} [uJ]
'
.
format
(
mcp
),
size
=
10
)
ax
.
set_xlabel
(
'
Pulse energy MCP{} [uJ]
'
.
format
(
mcp
),
size
=
10
)
#ax2 = ax.twiny()
#ax2.set_xlabel('MCP 1 APD')
#toRaw = lambda x: x/F
#ax2.set_xlim((toRaw(ax.get_xlim()[0]),toRaw(ax.get_xlim()[1])))
ax
.
set_yscale
(
'
log
'
)
ax
.
set_yscale
(
'
log
'
)
ax
=
plt
.
subplot
(
236
)
ax
=
plt
.
subplot
(
236
)
...
...
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