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
25ec1920
Commit
25ec1920
authored
5 years ago
by
Laurent Mercadier
Browse files
Options
Downloads
Plain Diff
Merge branch 'bam' into 'master'
Bam See merge request
SCS/ToolBox!72
parents
e0d3745a
253d56d8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Load.py
+14
-2
14 additions, 2 deletions
Load.py
bunch_pattern.py
+37
-1
37 additions, 1 deletion
bunch_pattern.py
with
51 additions
and
3 deletions
Load.py
+
14
−
2
View file @
25ec1920
...
@@ -38,6 +38,18 @@ mnemonics = {
...
@@ -38,6 +38,18 @@ mnemonics = {
"
npulses_sase1
"
:
{
'
source
'
:
'
SCS_RR_UTC/MDL/BUNCH_DECODER
'
,
"
npulses_sase1
"
:
{
'
source
'
:
'
SCS_RR_UTC/MDL/BUNCH_DECODER
'
,
'
key
'
:
'
sase1.nPulses.value
'
,
'
key
'
:
'
sase1.nPulses.value
'
,
'
dim
'
:
None
},
'
dim
'
:
None
},
#Bunch Arrival Monitors
"
BAM6
"
:
{
'
source
'
:
'
SCS_ILH_LAS/DOOCS/BAM_414_B2:output
'
,
'
key
'
:
'
data.lowChargeArrivalTime
'
,
'
dim
'
:[
'
BAMbunchId
'
]},
"
BAM7
"
:
{
'
source
'
:
'
SCS_ILH_LAS/DOOCS/BAM_1932M_TL:output
'
,
'
key
'
:
'
data.lowChargeArrivalTime
'
,
'
dim
'
:[
'
BAMbunchId
'
]},
"
BAM8
"
:
{
'
source
'
:
'
SCS_ILH_LAS/DOOCS/BAM_1932S_TL:output
'
,
'
key
'
:
'
data.lowChargeArrivalTime
'
,
'
dim
'
:[
'
BAMbunchId
'
]},
# SA3
# SA3
"
nrj
"
:
{
'
source
'
:
'
SA3_XTD10_MONO/MDL/PHOTON_ENERGY
'
,
"
nrj
"
:
{
'
source
'
:
'
SA3_XTD10_MONO/MDL/PHOTON_ENERGY
'
,
'
key
'
:
'
actualEnergy.value
'
,
'
key
'
:
'
actualEnergy.value
'
,
...
@@ -437,8 +449,8 @@ def load(fields, runNB, proposalNB, subFolder='raw', display=False, validate=Fal
...
@@ -437,8 +449,8 @@ def load(fields, runNB, proposalNB, subFolder='raw', display=False, validate=Fal
else
:
else
:
bp_table
=
run
.
get_array
(
bp_mnemo
[
'
source
'
],
bp_mnemo
[
'
key
'
],
bp_table
=
run
.
get_array
(
bp_mnemo
[
'
source
'
],
bp_mnemo
[
'
key
'
],
extra_dims
=
bp_mnemo
[
'
dim
'
])
extra_dims
=
bp_mnemo
[
'
dim
'
])
sase1
,
npulses_sase1
=
extractBunchPattern
(
bp_table
,
'
sase1
'
)
sase1
,
npulses_sase1
,
dummy
=
extractBunchPattern
(
bp_table
,
'
sase1
'
)
sase3
,
npulses_sase3
=
extractBunchPattern
(
bp_table
,
'
sase3
'
)
sase3
,
npulses_sase3
,
dummy
=
extractBunchPattern
(
bp_table
,
'
sase3
'
)
keys
+=
[
"
sase1
"
,
"
npulses_sase1
"
,
"
sase3
"
,
"
npulses_sase3
"
]
keys
+=
[
"
sase1
"
,
"
npulses_sase1
"
,
"
sase3
"
,
"
npulses_sase3
"
]
vals
+=
[
sase1
,
npulses_sase1
,
sase3
,
npulses_sase3
]
vals
+=
[
sase1
,
npulses_sase1
,
sase3
,
npulses_sase3
]
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
bunch_pattern.py
+
37
−
1
View file @
25ec1920
...
@@ -25,6 +25,7 @@ def extractBunchPattern(bp_table=None, key='sase3', runDir=None):
...
@@ -25,6 +25,7 @@ def extractBunchPattern(bp_table=None, key='sase3', runDir=None):
bunchPattern: DataArray containing indices of the sase/laser pulses for
bunchPattern: DataArray containing indices of the sase/laser pulses for
each train
each train
npulses: DataArray containing the number of pulses for each train
npulses: DataArray containing the number of pulses for each train
matched: 2-D DataArray mask (trainId x 2700), True where
'
key
'
has pulses
'''
'''
keys
=
[
'
sase1
'
,
'
sase2
'
,
'
sase3
'
,
'
scs_ppl
'
]
keys
=
[
'
sase1
'
,
'
sase2
'
,
'
sase3
'
,
'
scs_ppl
'
]
...
@@ -74,7 +75,7 @@ def extractBunchPattern(bp_table=None, key='sase3', runDir=None):
...
@@ -74,7 +75,7 @@ def extractBunchPattern(bp_table=None, key='sase3', runDir=None):
npulses
=
xr
.
DataArray
(
npulses
,
dims
=
[
'
trainId
'
],
npulses
=
xr
.
DataArray
(
npulses
,
dims
=
[
'
trainId
'
],
coords
=
{
'
trainId
'
:
matched
.
trainId
},
coords
=
{
'
trainId
'
:
matched
.
trainId
},
name
=
f
'
npulses_
{
key
}
'
)
name
=
f
'
npulses_
{
key
}
'
)
return
bunchPattern
,
npulses
return
bunchPattern
,
npulses
,
matched
def
pulsePatternInfo
(
data
,
plot
=
False
):
def
pulsePatternInfo
(
data
,
plot
=
False
):
...
@@ -179,3 +180,38 @@ def repRate(data, sase='sase3'):
...
@@ -179,3 +180,38 @@ def repRate(data, sase='sase3'):
return
0
return
0
f
=
1
/
((
sase
[
0
,
1
]
-
sase
[
0
,
0
])
*
12e-3
/
54.1666667
)
f
=
1
/
((
sase
[
0
,
1
]
-
sase
[
0
,
0
])
*
12e-3
/
54.1666667
)
return
f
return
f
def
sortBAMdata
(
data
,
key
=
'
sase3
'
):
'''
Extracts beam arrival monitor data from the raw arrays
'
BAM6
'
,
'
BAM7
'
, etc...
according to the bunchPatternTable. The BAM arrays contain 7220 values, which
corresponds to FLASH busrt length of 800 us @ 9 MHz. The bunchPatternTable
only has 2700 values, corresponding to XFEL 600 us burst length @ 4.5 MHz.
Hence, we truncate the BAM arrays to 5400 with a stride of 2 and match them
to the bunchPatternTable. If key is one of the sase, the given dimension name
of the bam arrays is
'
sa[sase number]_pId
'
, to match other data (XGM, TIM...).
Inputs:
data: xarray Dataset containing BAM arrays
key: str, [
'
sase1
'
,
'
sase2
'
,
'
sase3
'
,
'
scs_ppl
'
]
Output:
ndata: xarray Dataset with same keys as input data (but new bam arrays)
'''
a
,
b
,
mask
=
extractBunchPattern
(
key
=
key
,
runDir
=
data
.
attrs
[
'
run
'
])
mask
=
mask
.
rename
({
'
pulse_slot
'
:
'
BAMbunchId
'
})
ndata
=
data
dropList
=
[]
mergeList
=
[]
for
k
in
data
:
if
'
BAM
'
in
k
:
dropList
.
append
(
k
)
bam
=
data
[
k
].
isel
(
BAMbunchId
=
slice
(
0
,
5400
,
2
))
bam
=
bam
.
where
(
mask
,
drop
=
True
)
if
'
sase
'
in
key
:
name
=
f
'
sa
{
key
[
4
]
}
_pId
'
bam
=
bam
.
rename
({
'
BAMbunchId
'
:
name
})
mergeList
.
append
(
bam
)
mergeList
.
append
(
data
.
drop
(
dropList
))
ndata
=
xr
.
merge
(
mergeList
,
join
=
'
inner
'
)
for
k
in
data
.
attrs
.
keys
():
ndata
.
attrs
[
k
]
=
data
.
attrs
[
k
]
return
ndata
\ No newline at end of file
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