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
08ad9193
Commit
08ad9193
authored
3 years ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
get_bias_voltage for AGIPD1M and AGIPD500K and test_agipdlib AGIPDCtrl
parent
b159cdc2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cal_tools/agipdlib.py
+1
-0
1 addition, 0 deletions
src/cal_tools/agipdlib.py
tests/conftest.py
+26
-0
26 additions, 0 deletions
tests/conftest.py
tests/test_agipdlib.py
+209
-0
209 additions, 0 deletions
tests/test_agipdlib.py
with
236 additions
and
0 deletions
src/cal_tools/agipdlib.py
+
1
−
0
View file @
08ad9193
...
...
@@ -243,6 +243,7 @@ class AgipdCtrl:
)
return
300
def
get_integration_time
(
self
)
->
int
:
"""
Read integration time from the FPGA device.
...
...
This diff is collapsed.
Click to expand it.
tests/conftest.py
+
26
−
0
View file @
08ad9193
import
socket
from
functools
import
lru_cache
from
pathlib
import
Path
from
tempfile
import
TemporaryDirectory
import
extra_data.tests.make_examples
as
make_examples
import
pytest
@pytest.fixture
(
scope
=
'
session
'
)
def
mock_agipd1m_run
():
with
TemporaryDirectory
()
as
td
:
make_examples
.
make_agipd1m_run
(
td
)
yield
td
@pytest.fixture
(
scope
=
'
session
'
)
def
mock_agipd1m_run_old
():
# No gain.value or bunchStructure.repetitionRate in /CONTROL/
with
TemporaryDirectory
()
as
td
:
make_examples
.
make_agipd1m_run
(
td
,
rep_rate
=
False
,
gain_setting
=
False
,
integration_time
=
False
)
yield
td
@pytest.fixture
(
scope
=
'
session
'
)
def
mock_agipd500k_run
():
# No gain.value or bunchStructure.repetitionRate in /CONTROL/
with
TemporaryDirectory
()
as
td
:
make_examples
.
make_agipd500k_run
(
td
)
yield
td
def
pytest_addoption
(
parser
):
parser
.
addoption
(
"
--no-gpfs
"
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_agipdlib.py
0 → 100644
+
209
−
0
View file @
08ad9193
from
datetime
import
datetime
from
extra_data
import
RunDirectory
from
cal_tools.agipdlib
import
AgipdCtrl
SPB_AGIPD_INST_SRC
=
'
SPB_DET_AGIPD1M-1/DET/0CH0:xtdf
'
CTRL_SRC
=
'
SPB_IRU_AGIPD1M1/MDL/FPGA_COMP
'
def
test_get_acq_rate_run
(
mock_agipd1m_run
):
# Current up to date data with acq_rate stored
# as repetition rate in slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
acq_rate
=
agipd_ctrl
.
get_acq_rate
()
assert
isinstance
(
acq_rate
,
float
)
assert
acq_rate
==
4.5
def
test_get_acq_rate_fast
(
mock_agipd1m_run
):
# Current up to date data with acq_rate stored
# as repetition rate in slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
acq_rate
=
agipd_ctrl
.
_get_acq_rate_run
()
assert
isinstance
(
acq_rate
,
float
)
assert
acq_rate
==
4.5
def
test_get_acq_rate_instr
(
mock_agipd1m_run_old
):
# Old data with no stored acq_rate in slow data.
# Reading acq_rate from fast data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run_old
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
None
)
acq_rate
=
agipd_ctrl
.
get_acq_rate
()
assert
isinstance
(
acq_rate
,
float
)
assert
acq_rate
==
4.5
def
test_get_acq_rate
(
mock_agipd1m_run
,
mock_agipd1m_run_old
):
# Current up to date data with acq_rate stored
# as repetition rate in slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
acq_rate
=
agipd_ctrl
.
_get_acq_rate_instr
()
assert
isinstance
(
acq_rate
,
float
)
assert
acq_rate
==
4.5
# Old data with no stored acq_rate in slow data.
# Reading acq_rate from fast data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run_old
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
None
)
acq_rate
=
agipd_ctrl
.
get_acq_rate
()
assert
isinstance
(
acq_rate
,
float
)
assert
acq_rate
==
4.5
def
test_get_num_cells
(
mock_agipd1m_run
):
# Reading number of memory cells from fast data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
None
)
mem_cells
=
agipd_ctrl
.
get_num_cells
()
assert
isinstance
(
mem_cells
,
int
)
assert
mem_cells
==
64
def
test_get_gain_setting_run
(
mock_agipd1m_run
):
# Reading gain setting from slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
gain_setting
=
agipd_ctrl
.
_get_gain_setting_run
()
assert
isinstance
(
gain_setting
,
int
)
assert
gain_setting
==
0
def
test_get_gain_setting_run_old
(
mock_agipd1m_run_old
):
# Reading gain setting from setupr and .....
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run_old
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
gain_setting
=
agipd_ctrl
.
_get_gain_setting_run_old
()
assert
isinstance
(
gain_setting
,
int
)
assert
gain_setting
==
0
def
test_get_gain_setting
(
mock_agipd1m_run
,
mock_agipd1m_run_old
):
# Reading gain setting from slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
gain_setting
=
agipd_ctrl
.
get_gain_setting
()
assert
isinstance
(
gain_setting
,
int
)
assert
gain_setting
==
0
# Reading gain setting from setupr and .....
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run_old
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
gain_setting
=
agipd_ctrl
.
get_gain_setting
()
assert
isinstance
(
gain_setting
,
int
)
assert
gain_setting
==
0
# Old data without gain setting.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run_old
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
gain_setting
=
agipd_ctrl
.
get_gain_setting
(
creation_time
=
datetime
.
strptime
(
"
2019-12-16T08:52:25
"
,
"
%Y-%m-%dT%H:%M:%S
"
))
assert
gain_setting
is
None
def
test_get_bias_voltage
(
mock_agipd1m_run
,
mock_agipd500k_run
,
mock_agipd1m_run_old
):
# Read bias voltage for HED_DET_AGIPD500K from slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd500k_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
bias_voltage
=
agipd_ctrl
.
get_bias_voltage
(
karabo_id_control
=
"
HED_EXP_AGIPD500K2G
"
)
assert
isinstance
(
bias_voltage
,
int
)
assert
bias_voltage
==
200
# Read bias voltage for SPB_DET_AGIPD1M-1 and MID_DET_AGIPD1M-1
# from slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
bias_voltage
=
agipd_ctrl
.
get_bias_voltage
(
karabo_id_control
=
"
SPB_IRU_AGIPD1M1
"
)
assert
isinstance
(
bias_voltage
,
int
)
assert
bias_voltage
==
300
# Read bias voltage for SPB_DET_AGIPD1M-1 and MID_DET_AGIPD1M-1
# from slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run_old
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
bias_voltage
=
agipd_ctrl
.
get_bias_voltage
(
karabo_id_control
=
"
SPB_IRU_AGIPD1M1
"
)
assert
isinstance
(
bias_voltage
,
int
)
assert
bias_voltage
==
300
def
test_get_integration_time
(
mock_agipd1m_run
,
mock_agipd1m_run_old
):
# Read integration time.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
integration_time
=
agipd_ctrl
.
get_integration_time
()
assert
isinstance
(
integration_time
,
int
)
assert
integration_time
==
15
# Integration time is not available in slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run_old
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
integration_time
=
agipd_ctrl
.
get_integration_time
()
assert
isinstance
(
integration_time
,
int
)
assert
integration_time
==
12
def
test_get_gain_mode
(
mock_agipd1m_run
):
# Read gain mode from slow data.
agipd_ctrl
=
AgipdCtrl
(
run_dc
=
RunDirectory
(
mock_agipd1m_run
),
image_src
=
SPB_AGIPD_INST_SRC
,
ctrl_src
=
CTRL_SRC
)
gain_mode
=
agipd_ctrl
.
get_gain_mode
()
assert
isinstance
(
gain_mode
,
int
)
assert
gain_mode
==
0
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