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
29d74c4d
Commit
29d74c4d
authored
5 years ago
by
Laurent Mercadier
Browse files
Options
Downloads
Patches
Plain Diff
Simplified test of conditions in mcpPeaks
parent
87cfeec6
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
+15
-9
15 additions, 9 deletions
xgm.py
with
15 additions
and
9 deletions
xgm.py
+
15
−
9
View file @
29d74c4d
...
...
@@ -351,11 +351,14 @@ def mcpPeaks(data, intstart, intstop, bkgstart, bkgstop, mcp=1, t_offset=None, n
bkgstart: trace index of background start
bkgstop: trace index of background stop
mcp: MCP channel number
t_offset: index separation between two pulses
npulses: number of pulses
t_offset: index separation between two pulses. If None, checks the
pulse pattern and determine the t_offset assuming mininum pulse
separation of 220 ns and digitizer resolution of 2 GHz.
npulses: number of pulses. If None, takes the maximum number of
pulses according to the bunch patter (field
'
npulses_sase3
'
)
Output:
results: DataArray with dims trainId x max(sase3 pulses)
*1MHz/intra-train rep.rate
results: DataArray with dims trainId x max(sase3 pulses)
'''
keyraw
=
'
MCP{}raw
'
.
format
(
mcp
)
...
...
@@ -364,13 +367,14 @@ def mcpPeaks(data, intstart, intstop, bkgstart, bkgstop, mcp=1, t_offset=None, n
if
npulses
is
None
:
npulses
=
int
(
data
[
'
npulses_sase3
'
].
max
().
values
)
sa3
=
data
[
'
sase3
'
].
where
(
data
[
'
sase3
'
]
>
1
)
if
npulses
>
1
:
step
=
sa3
.
where
(
data
[
'
npulses_sase3
'
]
>
1
,
drop
=
True
)[
0
,:
2
].
values
step
=
int
(
step
[
1
]
-
step
[
0
])
if
t_offset
is
None
:
if
t_offset
is
None
:
if
npulses
>
1
:
#Calculate the number of pulses between two lasing pulses (step)
step
=
sa3
.
where
(
data
[
'
npulses_sase3
'
]
>
1
,
drop
=
True
)[
0
,:
2
].
values
step
=
int
(
step
[
1
]
-
step
[
0
])
#multiply by elementary samples length (220 ns @ 2 GHz = 440)
t_offset
=
440
*
step
else
:
if
t_offset
is
None
:
else
:
t_offset
=
1
results
=
xr
.
DataArray
(
np
.
empty
((
sa3
.
shape
[
0
],
npulses
)),
coords
=
sa3
.
coords
,
dims
=
[
'
trainId
'
,
'
MCP{}fromRaw
'
.
format
(
mcp
)])
...
...
@@ -409,6 +413,7 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
maxpulses
=
int
(
npulses_sa3
.
max
().
values
)
step
=
1
if
maxpulses
>
1
:
#Calculate the number of non-lasing pulses between two lasing pulses (step)
step
=
sa3
.
where
(
data
[
'
npulses_sase3
'
]
>
1
,
drop
=
True
)[
0
,:
2
].
values
step
=
int
(
step
[
1
]
-
step
[
0
])
if
use_apd
:
...
...
@@ -429,6 +434,7 @@ def getTIMapd(data, mcp=1, use_apd=True, intstart=None, intstop=None,
if
np
.
all
(
npulses_sa3
==
npulses_sa3
[
0
]):
tim
=
apd
[:,
sa3
[
0
].
values
]
return
tim
stride
=
1
if
use_apd
:
stride
=
np
.
max
([
stride
,
int
(
step
/
npulses_per_apd
)])
...
...
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