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
Thomas Kluyver
ToolBox
Commits
1cb9ea84
"README.md" did not exist on "90fc8b3585594f19c04aca8d2c44ebac6af5b4ce"
Commit
1cb9ea84
authored
5 years ago
by
Loïc Le Guyader
Browse files
Options
Downloads
Patches
Plain Diff
Correct SA3 slow data by SASA1 contribution
parent
e66e8e00
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xgm.py
+16
-16
16 additions, 16 deletions
xgm.py
with
16 additions
and
16 deletions
xgm.py
+
16
−
16
View file @
1cb9ea84
...
@@ -335,21 +335,26 @@ def calibrateXGMs(data, rollingWindow=200, plot=False):
...
@@ -335,21 +335,26 @@ def calibrateXGMs(data, rollingWindow=200, plot=False):
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
))
# Calculate SASE3 slow data
sa3contrib
=
saseContribution
(
data
,
'
sase3
'
,
'
SA3_XGM
'
)
SA3_SLOW
=
data
[
'
SA3_XGM_SLOW
'
]
*
(
data
[
'
npulses_sase3
'
]
+
data
[
'
npulses_sase1
'
])
*
sa3contrib
/
data
[
'
npulses_sase3
'
]
SA1_SLOW
=
data
[
'
SA3_XGM_SLOW
'
]
*
(
data
[
'
npulses_sase3
'
]
+
data
[
'
npulses_sase1
'
])
*
(
1
-
sa3contrib
)
/
data
[
'
npulses_sase1
'
]
SCS_SLOW
=
data
[
'
SCS_XGM_SLOW
'
]
*
(
data
[
'
npulses_sase3
'
]
+
data
[
'
npulses_sase1
'
])
*
sa3contrib
/
data
[
'
npulses_sase3
'
]
# Calibrate SASE3 XGM with all signal from SASE1 and SASE3
# Calibrate SASE3 XGM with all signal from SASE1 and SASE3
if
not
noSA3
:
if
not
noSA3
:
xgm_avg
=
data
[
'
SA3_XGM
'
].
where
(
data
[
'
SA3_XGM
'
]
!=
1.0
).
mean
(
axis
=
1
)
xgm_avg
=
selectSASEinXGM
(
data
,
'
sase3
'
,
'
SA3_XGM
'
).
mean
(
axis
=
1
)
rolling_sa3_xgm
=
xgm_avg
.
rolling
(
trainId
=
rollingWindow
).
mean
()
rolling_sa3_xgm
=
xgm_avg
.
rolling
(
trainId
=
rollingWindow
).
mean
()
ratio
=
data
[
'
SA3_XGM
_SLOW
'
]
/
rolling_sa3_xgm
ratio
=
SA3
_SLOW
/
rolling_sa3_xgm
sa3_calib_factor
=
ratio
[
start
:
stop
].
mean
().
values
sa3_calib_factor
=
ratio
[
start
:
stop
].
mean
().
values
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
=
saseContribution
(
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
()
ratio
=
((
data
[
'
npulses_sase3
'
]
+
data
[
'
npulses_sase1
'
])
*
ratio
=
SCS_SLOW
/
meanFast
data
[
'
SCS_XGM_SLOW
'
]
*
sa3contrib
)
/
(
meanFast
*
data
[
'
npulses_sase3
'
])
scs_calib_factor
=
ratio
[
start
:
stop
].
median
().
values
scs_calib_factor
=
ratio
[
start
:
stop
].
median
().
values
print
(
'
calibration factor SCS XGM: %f
'
%
scs_calib_factor
)
print
(
'
calibration factor SCS XGM: %f
'
%
scs_calib_factor
)
...
@@ -357,31 +362,26 @@ def calibrateXGMs(data, rollingWindow=200, plot=False):
...
@@ -357,31 +362,26 @@ def calibrateXGMs(data, rollingWindow=200, plot=False):
plt
.
figure
(
figsize
=
(
8
,
8
))
plt
.
figure
(
figsize
=
(
8
,
8
))
plt
.
subplot
(
211
)
plt
.
subplot
(
211
)
plt
.
title
(
'
E[uJ] = %.2f x IntensityTD
'
%
(
sa3_calib_factor
))
plt
.
title
(
'
E[uJ] = %.2f x IntensityTD
'
%
(
sa3_calib_factor
))
plt
.
plot
(
data
[
'
SA3_XGM
_SLOW
'
]
,
label
=
'
SA3 slow
'
,
color
=
'
C1
'
)
plt
.
plot
(
SA3
_SLOW
,
label
=
'
SA3 slow
'
,
color
=
'
C1
'
)
plt
.
plot
(
rolling_sa3_xgm
*
sa3_calib_factor
,
plt
.
plot
(
rolling_sa3_xgm
*
sa3_calib_factor
,
label
=
'
SA3 fast signal rolling avg
'
,
color
=
'
C4
'
)
label
=
'
SA3 fast signal rolling avg
'
,
color
=
'
C4
'
)
plt
.
plot
(
xgm_avg
*
sa3_calib_factor
,
label
=
'
SA3 fast signal train avg
'
,
alpha
=
0.2
,
color
=
'
C4
'
)
plt
.
ylabel
(
'
Energy [uJ]
'
)
plt
.
ylabel
(
'
Energy [uJ]
'
)
plt
.
xlabel
(
'
train in run
'
)
plt
.
xlabel
(
'
train in run
'
)
plt
.
legend
(
loc
=
'
upper left
'
,
fontsize
=
10
)
plt
.
legend
(
loc
=
'
upper left
'
,
fontsize
=
10
)
plt
.
twinx
()
plt
.
twinx
()
plt
.
plot
(
xgm_avg
*
sa3_calib_factor
,
label
=
'
SA3 fast signal train avg
'
,
alpha
=
0.2
,
color
=
'
C
4
'
)
plt
.
plot
(
SA1_SLOW
,
label
=
'
SA1 slow
'
,
alpha
=
0.2
,
color
=
'
C
2
'
)
plt
.
ylabel
(
'
Calibrated SA3 fast
signal [uJ]
'
)
plt
.
ylabel
(
'
SA1 slow
signal [uJ]
'
)
plt
.
legend
(
loc
=
'
lower right
'
,
fontsize
=
10
)
plt
.
legend
(
loc
=
'
lower right
'
,
fontsize
=
10
)
plt
.
subplot
(
212
)
plt
.
subplot
(
212
)
plt
.
title
(
'
E[uJ] = %.2f x HAMP
'
%
scs_calib_factor
)
plt
.
title
(
'
E[uJ] = %.2f x HAMP
'
%
scs_calib_factor
)
plt
.
plot
(
data
[
'
SCS_XGM_SLOW
'
],
label
=
'
SCS slow (all SASE)
'
,
color
=
'
C0
'
)
plt
.
plot
(
SCS_SLOW
,
label
=
'
SCS slow
'
,
color
=
'
C1
'
)
slow_avg_sase3
=
data
[
'
SCS_XGM_SLOW
'
]
*
(
data
[
'
npulses_sase1
'
]
+
data
[
'
npulses_sase3
'
])
*
sa3contrib
/
data
[
'
npulses_sase3
'
]
plt
.
plot
(
slow_avg_sase3
,
label
=
'
SCS slow (SASE3 only)
'
,
color
=
'
C1
'
)
plt
.
plot
(
meanFast
*
scs_calib_factor
,
label
=
'
SCS HAMP rolling avg
'
,
color
=
'
C2
'
)
plt
.
plot
(
meanFast
*
scs_calib_factor
,
label
=
'
SCS HAMP rolling avg
'
,
color
=
'
C2
'
)
plt
.
ylabel
(
'
Energy [uJ]
'
)
plt
.
ylabel
(
'
Energy [uJ]
'
)
plt
.
xlabel
(
'
train in run
'
)
plt
.
xlabel
(
'
train in run
'
)
plt
.
legend
(
loc
=
'
upper left
'
,
fontsize
=
10
)
plt
.
twinx
()
plt
.
plot
(
scs_sase3_fast
*
scs_calib_factor
,
label
=
'
SCS HAMP train avg
'
,
alpha
=
0.2
,
color
=
'
C2
'
)
plt
.
plot
(
scs_sase3_fast
*
scs_calib_factor
,
label
=
'
SCS HAMP train avg
'
,
alpha
=
0.2
,
color
=
'
C2
'
)
plt
.
ylabel
(
'
Calibrated HAMP signal [uJ]
'
)
plt
.
legend
(
loc
=
'
upper left
'
,
fontsize
=
10
)
plt
.
legend
(
loc
=
'
lower right
'
,
fontsize
=
10
)
plt
.
tight_layout
()
plt
.
tight_layout
()
return
np
.
array
([
sa3_calib_factor
,
scs_calib_factor
])
return
np
.
array
([
sa3_calib_factor
,
scs_calib_factor
])
...
...
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