Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
calibration
pycalibration
Commits
21276174
Commit
21276174
authored
4 years ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Adapt agipdlib.get_acq_rate to fetch rate from MDL control data
parent
3fa2cd9e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!353
[AGIPD] [DARK] Add support for AGIPD mini half in dark calibration
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cal_tools/cal_tools/agipdlib.py
+46
-10
46 additions, 10 deletions
cal_tools/cal_tools/agipdlib.py
notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb
+359
-8
359 additions, 8 deletions
notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb
with
405 additions
and
18 deletions
cal_tools/cal_tools/agipdlib.py
+
46
−
10
View file @
21276174
from
pathlib
import
Path
from
typing
import
Optional
,
Tuple
import
h5py
import
numpy
as
np
import
sharedmem
...
...
@@ -22,16 +25,49 @@ def get_num_cells(fname, loc, module):
return
options
[
np
.
argmin
(
dists
)]
def
get_acq_rate
(
fname
,
loc
,
module
):
with
h5py
.
File
(
fname
,
"
r
"
)
as
f
:
try
:
pulses
=
\
np
.
squeeze
(
f
[
f
"
INSTRUMENT/
{
loc
}
/DET/
{
module
}
CH0:xtdf/image/pulseId
"
][:
2
])
# noqa
diff
=
pulses
[
1
]
-
pulses
[
0
]
except
:
diff
=
0
options
=
{
8
:
0.5
,
4
:
1.1
,
2
:
2.2
,
1
:
4.5
}
return
options
.
get
(
diff
,
None
)
def
get_acq_rate
(
slow_paths
:
Tuple
[
str
,
str
],
fast_paths
:
Tuple
[
str
,
str
,
int
])
->
Optional
[
float
]:
"""
Get the acquisition rate from said detector module.
If the data is available from the middlelayer FPGA_COMP device, then it is
retrieved from there. If not, the rate is calculated from two different pulses
time.
The first entry is deliberatly not used, as the detector just began operating,
and it might have skipped a train.
:param slow_paths: in which file and h5 path to look for slow data.
The first string is the filename with complete path,
the second string is the key `karabo_id_control`
:param fast_paths: in which module file and h5 path to look for pulses.
The first string is the filename with complete path,
the second string is the module device name `karabo_id`,
the third parameter is the module number, used to navigate
through the h5 file structure.
:return acq_rate: the acquisition rate. If not found in either files, return None.
"""
# Attempt to look for acquisition rate in slow data
slow_data_file
,
karabo_id_control
=
slow_paths
slow_data_file
=
Path
(
slow_data_file
)
if
slow_data_file
.
exists
():
slow_data_path
=
f
'
CONTROL/
{
karabo_id_control
}
/MDL/FPGA_COMP/bunchStructure/repetitionRate/value
'
# noqa
with
h5py
.
File
(
slow_data_file
,
"
r
"
)
as
fin
:
if
slow_data_path
in
fin
:
return
fin
[
slow_data_path
][
3
]
# Compute acquisition rate from fast data
fast_data_file
,
karabo_id
,
module
=
fast_paths
fast_data_file
=
Path
(
fast_data_file
)
if
fast_data_file
.
exists
():
fast_data_path
=
f
'
INSTRUMENT/
{
karabo_id
}
/DET/
{
module
}
CH0:xtdf/image/pulseId
'
with
h5py
.
File
(
fast_data_file
)
as
fin
:
if
fast_data_path
in
fin
:
pulses
=
np
.
squeeze
(
fin
[
fast_data_path
][
1
:
3
])
diff
=
pulses
[
1
]
-
pulses
[
0
]
options
=
{
8
:
0.5
,
4
:
1.1
,
2
:
2.2
,
1
:
4.5
}
return
options
.
get
(
diff
,
None
)
def
get_gain_setting
(
fname
,
h5path_ctrl
):
...
...
This diff is collapsed.
Click to expand it.
notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb
+
359
−
8
View file @
21276174
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