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
e9d95fb0
Commit
e9d95fb0
authored
10 months ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Modernise use of extra_data to get AGIPD control data
parent
2adc8ca1
No related branches found
No related tags found
1 merge request
!1015
[AGIPD] Modernise use of extra_data to get AGIPD control data
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cal_tools/agipdlib.py
+23
-41
23 additions, 41 deletions
src/cal_tools/agipdlib.py
with
23 additions
and
41 deletions
src/cal_tools/agipdlib.py
+
23
−
41
View file @
e9d95fb0
...
@@ -12,7 +12,9 @@ import h5py
...
@@ -12,7 +12,9 @@ import h5py
import
numpy
as
np
import
numpy
as
np
import
sharedmem
import
sharedmem
from
dateutil
import
parser
from
dateutil
import
parser
from
extra_data
import
DataCollection
,
H5File
,
RunDirectory
,
by_id
from
extra_data
import
(
DataCollection
,
H5File
,
RunDirectory
,
by_id
,
PropertyNameError
,
SourceNameError
,
)
from
cal_tools
import
agipdalgs
as
calgs
from
cal_tools
import
agipdalgs
as
calgs
from
cal_tools.agipdutils
import
(
from
cal_tools.agipdutils
import
(
...
@@ -51,14 +53,10 @@ class AgipdCtrl:
...
@@ -51,14 +53,10 @@ class AgipdCtrl:
def
_get_num_cells_ctrl
(
self
)
->
Optional
[
int
]:
def
_get_num_cells_ctrl
(
self
)
->
Optional
[
int
]:
"""
Get number of cells from CONTROL source.
"""
"""
Get number of cells from CONTROL source.
"""
# Attempt to look for number of cells in slow data
# Attempt to look for number of cells in slow data
ncell_src
=
(
try
:
self
.
ctrl_src
,
"
bunchStructure.nPulses.value
"
)
kd
=
self
.
run_dc
[
self
.
ctrl_src
,
"
bunchStructure.nPulses
"
]
if
(
return
int
(
kd
.
as_single_value
(
reduce_by
=
'
max
'
))
ncell_src
[
0
]
in
self
.
run_dc
.
all_sources
and
except
(
SourceNameError
,
PropertyNameError
):
ncell_src
[
1
]
in
self
.
run_dc
.
keys_for_source
(
ncell_src
[
0
])
):
return
int
(
self
.
run_dc
[
ncell_src
].
as_single_value
(
reduce_by
=
'
max
'
))
else
:
return
None
return
None
def
_get_num_cells_instr
(
self
)
->
int
:
def
_get_num_cells_instr
(
self
)
->
int
:
...
@@ -91,15 +89,11 @@ class AgipdCtrl:
...
@@ -91,15 +89,11 @@ class AgipdCtrl:
def
_get_acq_rate_ctrl
(
self
)
->
Optional
[
float
]:
def
_get_acq_rate_ctrl
(
self
)
->
Optional
[
float
]:
"""
Get acquisition (repetition) rate from CONTROL source.
"""
"""
Get acquisition (repetition) rate from CONTROL source.
"""
# Attempt to look for acquisition rate in slow data
# Attempt to look for acquisition rate in slow data
rep_rate_src
=
(
try
:
self
.
ctrl_src
,
"
bunchStructure.repetitionRate.value
"
)
kd
=
self
.
run_dc
[
self
.
ctrl_src
,
"
bunchStructure.repetitionRate
"
]
if
(
return
round
(
float
(
kd
.
as_single_value
()),
1
)
rep_rate_src
[
0
]
in
self
.
run_dc
.
all_sources
and
except
(
SourceNameError
,
PropertyNameError
):
rep_rate_src
[
1
]
in
self
.
run_dc
.
keys_for_source
(
rep_rate_src
[
0
])
return
None
):
# It is desired to loose precision here because the usage is
# about bucketing the rate for managing meta-data.
return
round
(
float
(
self
.
run_dc
[
rep_rate_src
].
as_single_value
()),
1
)
def
_get_acq_rate_instr
(
self
)
->
Optional
[
float
]:
def
_get_acq_rate_instr
(
self
)
->
Optional
[
float
]:
"""
Get acquisition (repetition rate) from INSTRUMENT source.
"""
"""
Get acquisition (repetition rate) from INSTRUMENT source.
"""
...
@@ -194,7 +188,7 @@ class AgipdCtrl:
...
@@ -194,7 +188,7 @@ class AgipdCtrl:
print
(
"
Set gain-setting to None for runs taken before 2020-01-31
"
)
print
(
"
Set gain-setting to None for runs taken before 2020-01-31
"
)
return
return
if
"
gain.value
"
in
self
.
run_dc
.
keys_for_source
(
self
.
ctrl_src
)
:
if
"
gain.value
"
in
self
.
run_dc
[
self
.
ctrl_src
]
:
return
self
.
_get_gain_setting_ctrl
()
return
self
.
_get_gain_setting_ctrl
()
gain_setting
=
self
.
_get_gain_setting_ctrl_old
()
gain_setting
=
self
.
_get_gain_setting_ctrl_old
()
...
@@ -210,16 +204,11 @@ class AgipdCtrl:
...
@@ -210,16 +204,11 @@ class AgipdCtrl:
def
get_gain_mode
(
self
)
->
int
:
def
get_gain_mode
(
self
)
->
int
:
"""
Returns the gain mode (adaptive or fixed) from slow data.
"""
"""
Returns the gain mode (adaptive or fixed) from slow data.
"""
try
:
if
(
kd
=
self
.
run_dc
[
self
.
ctrl_src
,
"
gainModeIndex
"
]
self
.
ctrl_src
in
self
.
run_dc
.
all_sources
and
return
AgipdGainMode
(
int
(
kd
.
as_single_value
()))
"
gainModeIndex.value
"
in
self
.
run_dc
.
keys_for_source
(
except
(
SourceNameError
,
PropertyNameError
):
self
.
ctrl_src
)
return
AgipdGainMode
.
ADAPTIVE_GAIN
):
return
AgipdGainMode
(
int
(
self
.
run_dc
[
self
.
ctrl_src
,
"
gainModeIndex
"
].
as_single_value
()))
return
AgipdGainMode
.
ADAPTIVE_GAIN
def
get_bias_voltage
(
def
get_bias_voltage
(
self
,
self
,
...
@@ -257,16 +246,13 @@ class AgipdCtrl:
...
@@ -257,16 +246,13 @@ class AgipdCtrl:
"
highVoltage.actual.value
"
)
"
highVoltage.actual.value
"
)
default_voltage
=
None
default_voltage
=
None
if
(
try
:
voltage_src
[
0
]
in
self
.
run_dc
.
all_sources
and
voltage_src
[
1
]
in
self
.
run_dc
.
keys_for_source
(
voltage_src
[
0
])
):
# Use RUN source for reading the bias voltage value.
# Use RUN source for reading the bias voltage value.
# As HED_DET_AGIPD500K2G has a hardware issue that leads
# As HED_DET_AGIPD500K2G has a hardware issue that leads
# to storing arbitrary voltage values in the CONTROL source
# to storing arbitrary voltage values in the CONTROL source
# array. e.g. /gpfs/exfel/exp/HED/202230/p900248/raw
# array. e.g. /gpfs/exfel/exp/HED/202230/p900248/raw
return
int
(
self
.
run_dc
.
get_run_value
(
*
voltage_src
))
return
int
(
self
.
run_dc
.
get_run_value
(
*
voltage_src
))
e
lse
:
e
xcept
(
SourceNameError
,
PropertyNameError
)
:
# TODO: Validate if removing this and
# TODO: Validate if removing this and
# and using NB value for old RAW data.
# and using NB value for old RAW data.
error
=
(
"
ERROR: Unable to read bias_voltage from
"
error
=
(
"
ERROR: Unable to read bias_voltage from
"
...
@@ -287,15 +273,11 @@ class AgipdCtrl:
...
@@ -287,15 +273,11 @@ class AgipdCtrl:
:return: integration time
:return: integration time
"""
"""
if
(
try
:
self
.
ctrl_src
in
self
.
run_dc
.
all_sources
and
'
integrationTime.value
'
in
self
.
run_dc
.
keys_for_source
(
self
.
ctrl_src
)
):
return
int
(
self
.
run_dc
[
return
int
(
self
.
run_dc
[
self
.
ctrl_src
,
'
integrationTime
'
].
as_single_value
())
self
.
ctrl_src
,
'
integrationTime
'
].
as_single_value
())
except
(
SourceNameError
,
PropertyNameError
):
return
12
return
12
@dataclass
@dataclass
...
...
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