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
9482ed4c
Commit
9482ed4c
authored
2 years ago
by
Egor Sobolev
Browse files
Options
Downloads
Patches
Plain Diff
Remove unrelated code
parent
acb9d7ea
No related branches found
No related tags found
1 merge request
!815
[AGIPD][CORRECT] Add reading of AGIPD number of cells from CONTROL data
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cal_tools/agipdlib.py
+11
-35
11 additions, 35 deletions
src/cal_tools/agipdlib.py
with
11 additions
and
35 deletions
src/cal_tools/agipdlib.py
+
11
−
35
View file @
9482ed4c
...
...
@@ -315,8 +315,7 @@ class CellSelection:
raise
NotImplementedError
def
get_cells_on_trains
(
self
,
train_sel
:
np
.
ndarray
,
nfrm
:
np
.
ndarray
,
cellid
:
np
.
ndarray
,
cm
:
int
=
0
self
,
train_sel
:
np
.
ndarray
,
nfrm
:
np
.
ndarray
,
cm
:
int
=
0
)
->
np
.
array
:
"""
Returns mask of cells selected for processing
...
...
@@ -327,8 +326,6 @@ class CellSelection:
for common-mode correction
:return: boolean array with flags indicating images for processing
:return: integer array with number of frames to use in the second
step in two step selection procedure
"""
raise
NotImplementedError
...
...
@@ -537,7 +534,7 @@ class AgipdCorrections:
n_valid_trains
=
len
(
valid_train_ids
)
data_dict
[
"
n_valid_trains
"
][
0
]
=
n_valid_trains
data_dict
[
"
valid_trains
"
][:
n_valid_trains
]
=
valid_train_ids
#
data_dict["nimg_in_trains"][:n_valid_trains] = nimg_in_trains
data_dict
[
"
nimg_in_trains
"
][:
n_valid_trains
]
=
nimg_in_trains
if
"
AGIPD500K
"
in
agipd_base
:
agipd_comp
=
components
.
AGIPD500K
(
im_dc
)
...
...
@@ -552,11 +549,8 @@ class AgipdCorrections:
cm
=
(
self
.
cell_sel
.
CM_NONE
if
apply_sel_pulses
else
self
.
cell_sel
.
CM_PRESEL
)
cellid
=
np
.
squeeze
(
im_dc
[
agipd_base
,
"
image.cellId
"
].
ndarray
())
img_selected
,
nimg_in_trains
=
self
.
cell_sel
.
get_cells_on_trains
(
np
.
array
(
valid_train_ids
),
nimg_in_trains
,
cellid
,
cm
=
cm
)
data_dict
[
"
nimg_in_trains
"
][:
n_valid_trains
]
=
nimg_in_trains
img_selected
=
self
.
cell_sel
.
get_cells_on_trains
(
np
.
array
(
valid_train_ids
),
nimg_in_trains
,
cm
=
cm
)
frm_ix
=
np
.
flatnonzero
(
img_selected
)
data_dict
[
"
cm_presel
"
][
0
]
=
(
cm
==
self
.
cell_sel
.
CM_PRESEL
)
...
...
@@ -1027,11 +1021,10 @@ class AgipdCorrections:
ntrains
=
data_dict
[
"
n_valid_trains
"
][
0
]
train_ids
=
data_dict
[
"
valid_trains
"
][:
ntrains
]
nimg_in_trains
=
data_dict
[
"
nimg_in_trains
"
][:
ntrains
]
cellid
=
data_dict
[
"
cellId
"
][:
n_img
]
# Initializing can_calibrate array
can_calibrate
,
_
=
self
.
cell_sel
.
get_cells_on_trains
(
train_ids
,
nimg_in_trains
,
cellid
,
cm
=
self
.
cell_sel
.
CM_FINSEL
can_calibrate
=
self
.
cell_sel
.
get_cells_on_trains
(
train_ids
,
nimg_in_trains
,
cm
=
self
.
cell_sel
.
CM_FINSEL
)
if
np
.
all
(
can_calibrate
):
return
n_img
...
...
@@ -1630,7 +1623,6 @@ class CellRange(CellSelection):
self
.
flag_cm
[:
self
.
max_cells
]
=
self
.
flag
self
.
flag_cm
=
(
self
.
flag_cm
.
reshape
(
-
1
,
self
.
row_size
).
any
(
1
)
.
repeat
(
self
.
row_size
)[:
self
.
max_cells
])
self
.
sel_type
=
[
self
.
flag
,
self
.
flag_cm
,
self
.
flag
]
def
msg
(
self
):
return
(
...
...
@@ -1640,24 +1632,10 @@ class CellRange(CellSelection):
)
def
get_cells_on_trains
(
self
,
train_sel
:
np
.
ndarray
,
nfrm
:
np
.
ndarray
,
cellid
:
np
.
ndarray
,
cm
:
int
=
0
self
,
train_sel
:
np
.
ndarray
,
nfrm
:
np
.
ndarray
,
cm
:
int
=
0
)
->
np
.
array
:
if
cm
<
0
or
cm
>
2
:
raise
ValueError
(
"
param
'
cm
'
takes only 0,1,2
"
)
flag
=
self
.
sel_type
[
cm
]
sel
=
np
.
zeros
(
np
.
sum
(
nfrm
),
bool
)
counts
=
np
.
zeros
(
len
(
nfrm
),
int
)
i0
=
0
for
i
,
nfrm_i
in
enumerate
(
nfrm
):
iN
=
i0
+
nfrm_i
f
=
flag
[
cellid
[
i0
:
iN
]]
sel
[
i0
:
iN
]
=
f
counts
[
i
]
=
np
.
sum
(
f
)
i0
=
iN
return
sel
,
counts
return
np
.
tile
(
self
.
_sel_for_cm
(
self
.
flag
,
self
.
flag_cm
,
cm
),
len
(
train_sel
))
def
filter_trains
(
self
,
train_sel
:
np
.
ndarray
):
return
train_sel
...
...
@@ -1734,14 +1712,12 @@ class LitFrameSelection(CellSelection):
)
def
get_cells_on_trains
(
self
,
train_sel
:
np
.
ndarray
,
nfrm
:
np
.
ndarray
,
cellid
:
np
.
ndarray
,
cm
:
int
=
0
self
,
train_sel
:
np
.
ndarray
,
nfrm
:
np
.
ndarray
,
cm
:
int
=
0
)
->
np
.
array
:
cell_flags
,
cm_flags
=
self
.
_sel
.
litframes_on_trains
(
train_sel
,
nfrm
,
[
self
.
final_sel_type
,
self
.
cm_sel_type
])
sel
=
self
.
_sel_for_cm
(
cell_flags
,
cm_flags
,
cm
)
return
sel
,
nfrm
return
self
.
_sel_for_cm
(
cell_flags
,
cm_flags
,
cm
)
def
filter_trains
(
self
,
train_sel
:
np
.
ndarray
):
return
self
.
_sel
.
filter_trains
(
train_sel
,
drop_empty
=
True
)
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