Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
calng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
calng
Commits
79811c01
Commit
79811c01
authored
1 month ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Prepare hack to sneak in gain counting
parent
988ae56e
No related branches found
Branches containing commit
No related tags found
1 merge request
!149
Draft: AGIPD count pixels per gain stage
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/calng/base_correction.py
+4
-0
4 additions, 0 deletions
src/calng/base_correction.py
src/calng/corrections/AgipdCorrection.py
+75
-6
75 additions, 6 deletions
src/calng/corrections/AgipdCorrection.py
with
79 additions
and
6 deletions
src/calng/base_correction.py
+
4
−
0
View file @
79811c01
...
...
@@ -893,6 +893,10 @@ class BaseCorrection(PythonDevice):
corrections
,
processed_buffer
,
previews
=
self
.
kernel_runner
.
correct
(
image_data
,
cell_table
,
*
additional_data
)
# hack: get extra data out from AGIPD until addon API is updated
if
isinstance
(
corrections
,
list
):
corrections
,
extra_stuff
=
corrections
data_hash
.
merge
(
extra_stuff
)
data_hash
[
"
corrections
"
]
=
corrections
# write previews first so addons cannot mess with them
...
...
This diff is collapsed.
Click to expand it.
src/calng/corrections/AgipdCorrection.py
+
75
−
6
View file @
79811c01
...
...
@@ -6,10 +6,12 @@ from karabo.bound import (
DOUBLE_ELEMENT
,
FLOAT_ELEMENT
,
KARABO_CLASSINFO
,
NDARRAY_ELEMENT
,
OUTPUT_CHANNEL
,
OVERWRITE_ELEMENT
,
STRING_ELEMENT
,
UINT32_ELEMENT
,
Hash
,
MetricPrefix
,
Unit
,
)
...
...
@@ -343,11 +345,6 @@ class AgipdBaseRunner(base_kernel_runner.BaseKernelRunner):
self
.
num_pixels_fs
,
)
def
extra_processing
(
self
,
out_hash
,
processed_dat
,
a
cell_table
,
pulse_table
,
gain_map
):
out_hash
[
"
numPixelsPerGainStage
"
]
=
...
@property
def
_gm_map_shape
(
self
):
return
self
.
_map_shape
+
(
3
,)
# for gain-mapped constants
...
...
@@ -611,6 +608,15 @@ class AgipdGpuRunner(AgipdBaseRunner):
),
name
=
"
common_mode_asic
"
,
)
self
.
gain_count_kernel
=
self
.
_xp
.
RawKernel
(
code
=
base_kernel_runner
.
get_kernel_template
(
"
gaincount.cu
"
).
render
(
ss_dim
=
self
.
num_pixels_ss
,
fs_dim
=
self
.
num_pixels_fs
,
block_size
=
128
,
# TODO: tune
num_gain_stages
=
3
,
),
name
=
"
count_pixels_per_gain_stage
"
,
)
def
_correct
(
self
,
flags
,
image_data
,
cell_table
,
processed_data
,
gain_map
):
num_frames
=
self
.
_xp
.
uint16
(
image_data
.
shape
[
0
])
...
...
@@ -658,6 +664,59 @@ class AgipdGpuRunner(AgipdBaseRunner):
),
)
def
correct
(
self
,
image_data
,
cell_table
,
*
additional_data
):
"""
Temporary override to utilize gain map for monitoring
"""
num_frames
=
image_data
.
shape
[
0
]
processed_buffers
=
self
.
_make_output_buffers
(
num_frames
,
self
.
_correction_flag_preview
)
image_data
=
self
.
_xp
.
asarray
(
image_data
)
additional_data
=
[
self
.
_xp
.
asarray
(
data
)
for
data
in
additional_data
]
self
.
_correct
(
self
.
_correction_flag_preview
,
image_data
,
cell_table
,
*
additional_data
,
*
processed_buffers
,
)
preview_buffers
=
self
.
_preview_data_views
(
image_data
,
*
additional_data
,
*
processed_buffers
)
if
self
.
_correction_flag_preview
!=
self
.
_correction_flag_enabled
:
processed_buffers
=
self
.
_make_output_buffers
(
num_frames
,
self
.
_correction_flag_enabled
)
self
.
_correct
(
self
.
_correction_flag_enabled
,
image_data
,
cell_table
,
*
additional_data
,
*
processed_buffers
,
)
num_frames
=
buffers
[
"
image.data
"
].
shape
[
0
]
gain_count_buffer
=
self
.
_xp
.
empty
(
(
num_frames
,
3
),
dtype
=
np
.
uint32
)
self
.
gain_count_kernel
(
(
num_frames
,
1
,
1
),
(
1
,
128
,
1
),
(
buffers
[
"
image.gain
"
],
num_frames
,
gain_count_buffer
,
)
)
return
(
[
self
.
_correction_applied_hash
,
Hash
(
"
numPixelsPerGainStage
"
,
gain_count_buffer
.
get
()),
],
processed_buffers
,
preview_buffers
,
)
class
AgipdCalcatFriend
(
base_calcat
.
BaseCalcatFriend
):
_constant_enum_class
=
Constants
...
...
@@ -786,10 +845,20 @@ class AgipdCalcatFriend(base_calcat.BaseCalcatFriend):
return
res
def
custom_output_schema
(
use_shmem_handles
):
res
=
schemas
.
xtdf_output_schema
(
use_shmem_handles
)
(
NDARRAY_ELEMENT
(
res
)
.
key
(
"
numPixelsPerGainStage
"
)
.
commit
(),
)
return
res
@KARABO_CLASSINFO
(
"
AgipdCorrection
"
,
deviceVersion
)
class
AgipdCorrection
(
base_correction
.
BaseCorrection
):
# subclass *must* set these attributes
_base_output_schema
=
schemas
.
xtdf
_output_schema
_base_output_schema
=
custom
_output_schema
_calcat_friend_class
=
AgipdCalcatFriend
_constant_enum_class
=
Constants
_correction_steps
=
correction_steps
...
...
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