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
39467625
Commit
39467625
authored
1 year ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Rework get_mem_cell_order
parent
1e6522fd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!851
[LPD] Automatically decide whether to inject & use memory cell order
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cal_tools/lpdlib.py
+20
-9
20 additions, 9 deletions
src/cal_tools/lpdlib.py
with
20 additions
and
9 deletions
src/cal_tools/lpdlib.py
+
20
−
9
View file @
39467625
...
@@ -772,21 +772,32 @@ class LpdCorrections:
...
@@ -772,21 +772,32 @@ class LpdCorrections:
flat_fields
)
flat_fields
)
def
get_mem_cell_order
(
run
,
sources
)
->
str
:
def
get_mem_cell_order
(
run
,
sources
,
use_param
)
->
Optional
[
str
]
:
"""
Load the memory cell order to use as a condition to find constants
"""
"""
Load the memory cell order to use as a condition to find constants
"""
res
=
set
()
if
use_param
==
'
never
'
:
return
None
patterns
=
[]
for
source
in
sources
:
for
source
in
sources
:
cell_id_data
=
run
[
source
,
'
image.cellId
'
].
drop_empty_trains
()
cell_id_data
=
run
[
source
,
'
image.cellId
'
].
drop_empty_trains
()
if
len
(
cell_id_data
.
train_ids
)
==
0
:
if
len
(
cell_id_data
.
train_ids
)
==
0
:
continue
# No data for this module
continue
# No data for this module
cell_ids
=
cell_id_data
[
0
].
ndarray
()
cell_ids
=
cell_id_data
[
0
].
ndarray
()
.
flatten
()
# Trailing comma required so e.g. "...,1" doesn't match "...,10"
if
not
any
(
np
.
array_equal
(
cell_ids
,
p
)
for
p
in
patterns
):
res
.
add
(
"
,
"
.
join
([
str
(
c
)
for
c
in
cell_ids
.
flatten
()])
+
"
,
"
)
patterns
.
append
(
cell_ids
)
if
len
(
re
s
)
>
1
:
if
len
(
pattern
s
)
>
1
:
warn
(
"
Memory cell order varies between detector modules:
"
warn
(
"
Memory cell order varies between detector modules:
"
"
;
"
.
join
([
f
"
{
s
[
:
10
]
}
...
{
s
[
-
10
:
]
}
"
for
s
in
re
s
]))
"
;
"
.
join
([
f
"
{
s
[
:
10
]
}
...
{
s
[
-
10
:
]
}
"
for
s
in
pattern
s
]))
elif
not
re
s
:
elif
not
pattern
s
:
raise
ValueError
(
"
Couldn
'
t find memory cell order for any modules
"
)
raise
ValueError
(
"
Couldn
'
t find memory cell order for any modules
"
)
return
res
.
pop
()
cellid_pattern
=
patterns
[
0
]
use
=
(
use_param
==
'
always
'
)
or
(
# auto: use cell order if it wraps around (cell IDs not monotonic)
len
(
cellid_pattern
)
>
2
and
(
np
.
diff
(
cellid_pattern
)
<
0
).
any
()
)
# Trailing comma required so e.g. "...,1" doesn't match "...,10"
return
"
,
"
.
join
([
str
(
c
)
for
c
in
cellid_pattern
])
+
"
,
"
if
use
else
None
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