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
d1f7d1cf
Commit
d1f7d1cf
authored
5 years ago
by
Mercadier
Browse files
Options
Downloads
Patches
Plain Diff
Adds function repRate()
parent
faa99930
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Adds function repRate()
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xgm.py
+26
-3
26 additions, 3 deletions
xgm.py
with
26 additions
and
3 deletions
xgm.py
+
26
−
3
View file @
d1f7d1cf
...
...
@@ -83,14 +83,37 @@ def pulsePatternInfo(data, plot=False):
print
(
'
\n
'
)
if
plot
:
plt
.
figure
(
figsize
=
(
6
,
3
))
plt
.
plot
(
data
[
'
npulses_sase3
'
].
trainId
,
data
[
'
npulses_sase3
'
],
'
o-
'
,
ms
=
3
,
label
=
'
SASE 3
'
)
plt
.
plot
(
data
[
'
npulses_sase3
'
].
trainId
,
data
[
'
npulses_sase3
'
],
'
o-
'
,
ms
=
3
,
label
=
'
SASE 3
'
)
plt
.
xlabel
(
'
trainId
'
)
plt
.
ylabel
(
'
pulses per train
'
)
plt
.
plot
(
data
[
'
npulses_sase1
'
].
trainId
,
data
[
'
npulses_sase1
'
],
'
^-
'
,
ms
=
3
,
color
=
'
C2
'
,
label
=
'
SASE 1
'
)
plt
.
plot
(
data
[
'
npulses_sase1
'
].
trainId
,
data
[
'
npulses_sase1
'
],
'
^-
'
,
ms
=
3
,
color
=
'
C2
'
,
label
=
'
SASE 1
'
)
plt
.
legend
()
plt
.
tight_layout
()
def
repRate
(
data
,
sase
=
'
sase3
'
):
'''
Calculates the pulse repetition rate in sase according
to the bunch pattern and assuming a minimum pulse
separation of 222e-9 seconds.
Inputs:
data: xarray Dataset containing pulse pattern
sase: sase in which the repetition rate is
calculated (1,2 or 3)
Output:
f: repetition rate in kHz
'''
assert
sase
in
data
,
'
key
"
{}
"
not found in data!
'
.
format
(
sase
)
sase
=
data
[
sase
].
where
(
data
[
'
npulses_{}
'
.
format
(
sase
)]
>
1
,
drop
=
True
).
values
if
len
(
sase
)
==
0
:
print
(
'
Not enough pulses to extract repetition rate
'
)
return
0
f
=
1
/
((
sase
[
0
,
1
]
-
sase
[
0
,
0
])
*
222e-6
)
return
f
def
selectSASEinXGM
(
data
,
sase
=
'
sase3
'
,
xgm
=
'
SCS_XGM
'
):
'''
Extract SASE1- or SASE3-only XGM data.
There are various cases depending on i) the mode of operation (10 Hz
...
...
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