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
8eb5c411
Commit
8eb5c411
authored
1 year ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Various additions to multi-module API
parent
01523074
No related branches found
No related tags found
1 merge request
!885
Revised CalCat API
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cal_tools/calcat_interface2.py
+34
-7
34 additions, 7 deletions
src/cal_tools/calcat_interface2.py
tests/test_calcat_interface2.py
+1
-1
1 addition, 1 deletion
tests/test_calcat_interface2.py
with
35 additions
and
8 deletions
src/cal_tools/calcat_interface2.py
+
34
−
7
View file @
8eb5c411
...
...
@@ -82,11 +82,11 @@ class ModulesConstantVersions:
@property
def
aggregators
(
self
):
return
list
(
self
.
constants
)
return
sorted
(
self
.
constants
)
@property
def
module_nums
(
self
):
return
[
int
(
da
[
-
2
:])
for
da
in
self
.
constant
s
]
return
[
int
(
da
[
-
2
:])
for
da
in
self
.
aggregator
s
]
@property
def
qm_names
(
self
):
...
...
@@ -187,8 +187,8 @@ class CalibrationData(Mapping):
return
cls
(
d
)
def
__getitem__
(
self
,
key
):
return
self
.
constant_groups
def
__getitem__
(
self
,
key
)
->
ModulesConstantVersions
:
return
self
.
constant_groups
[
key
]
def
__iter__
(
self
):
return
iter
(
self
.
constant_groups
)
...
...
@@ -196,6 +196,28 @@ class CalibrationData(Mapping):
def
__len__
(
self
):
return
len
(
self
.
constant_groups
)
@property
def
aggregators
(
self
):
names
=
set
()
for
mcv
in
self
.
constant_groups
.
values
():
names
.
update
(
mcv
.
aggregators
)
return
sorted
(
names
)
@property
def
module_nums
(
self
):
return
[
int
(
da
[
-
2
:])
for
da
in
self
.
aggregators
]
@property
def
qm_names
(
self
):
return
[
module_index_to_qm
(
n
)
for
n
in
self
.
module_nums
]
def
require_calibrations
(
self
,
*
calibrations
):
"""
Drop any modules missing the specified constant types
"""
mods
=
set
(
self
.
aggregators
)
for
cal_type
in
calibrations
:
mods
.
intersection_update
(
self
[
cal_type
].
constants
)
return
self
.
select_modules
(
mods
)
def
select_calibrations
(
self
,
*
calibrations
,
require_all
=
True
):
if
require_all
:
missing
=
set
(
calibrations
)
-
set
(
self
.
constant_groups
)
...
...
@@ -218,9 +240,14 @@ class CalibrationData(Mapping):
}
)
def
merge
(
self
,
other
:
"
CalibrationData
"
)
->
"
CalibrationData
"
:
d
=
self
.
constant_groups
.
copy
()
d
.
update
(
other
.
constant_groups
)
def
merge
(
self
,
*
others
:
Sequence
[
"
CalibrationData
"
])
->
"
CalibrationData
"
:
d
=
{}
for
cal_type
,
mcv
in
self
.
constant_groups
.
items
():
d
[
cal_type
]
=
mcv
.
constants
.
copy
()
for
other
in
others
:
if
cal_type
in
other
:
d
[
cal_type
].
update
(
other
[
cal_type
].
constants
)
return
type
(
self
)(
d
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_calcat_interface2.py
+
1
−
1
View file @
8eb5c411
...
...
@@ -35,5 +35,5 @@ def test_AGIPD_CalibrationData_report():
# Report ID: https://in.xfel.eu/calibration/reports/3757
agipd_cd
=
CalibrationData
.
from_report
(
3757
)
assert
set
(
agipd_cd
)
==
{
'
Offset
'
,
'
Noise
'
,
'
ThresholdsDark
'
,
'
BadPixelsDark
'
}
assert
agipd_cd
[
'
Offset
'
]
.
aggregators
==
[
f
'
AGIPD
{
n
:
02
}
'
for
n
in
range
(
16
)]
assert
agipd_cd
.
aggregators
==
[
f
'
AGIPD
{
n
:
02
}
'
for
n
in
range
(
16
)]
assert
isinstance
(
agipd_cd
[
'
Offset
'
].
constants
[
'
AGIPD00
'
],
SingleConstantVersion
)
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