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
0e210d4b
Commit
0e210d4b
authored
2 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
LPD: make bad pixel masking value configurable
parent
47314d47
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!12
Snapshot: field test deployed version as of end of run 202201
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/calng/LpdCorrection.py
+47
-0
47 additions, 0 deletions
src/calng/LpdCorrection.py
with
47 additions
and
0 deletions
src/calng/LpdCorrection.py
+
47
−
0
View file @
0e210d4b
...
...
@@ -6,6 +6,7 @@ from karabo.bound import (
DOUBLE_ELEMENT
,
KARABO_CLASSINFO
,
OVERWRITE_ELEMENT
,
STRING_ELEMENT
,
VECTOR_STRING_ELEMENT
,
)
...
...
@@ -287,6 +288,23 @@ class LpdCorrection(BaseCorrection):
expected
,
LpdCorrection
.
_managed_keys
,
LpdCorrection
.
_correction_field_names
)
# additional settings for correction steps
(
STRING_ELEMENT
(
expected
)
.
key
(
"
corrections.badPixels.maskingValue
"
)
.
displayedName
(
"
Bad pixel masking value
"
)
.
description
(
"
Any pixels masked by the bad pixel mask will have their value
"
"
replaced with this. Note that this parameter is to be interpreted as
"
"
a numpy.float32; use
'
nan
'
to get NaN value.
"
)
.
assignmentOptional
()
.
defaultValue
(
"
nan
"
)
.
reconfigurable
()
.
commit
(),
)
LpdCorrection
.
_managed_keys
.
add
(
"
corrections.badPixels.maskingValue
"
)
# mandatory: manager needs this in schema
(
VECTOR_STRING_ELEMENT
(
expected
)
...
...
@@ -305,6 +323,16 @@ class LpdCorrection(BaseCorrection):
self
.
unsafe_get
(
"
dataFormat.pixelsY
"
),
)
def
__init__
(
self
,
config
):
super
().
__init__
(
config
)
try
:
bad_pixel_mask_value
=
np
.
float32
(
config
.
get
(
"
corrections.badPixels.maskingValue
"
)
)
except
ValueError
:
bad_pixel_mask_value
=
np
.
float32
(
"
nan
"
)
self
.
_kernel_runner_init_args
=
{
"
bad_pixel_mask_value
"
:
bad_pixel_mask_value
}
def
_load_constant_to_runner
(
self
,
constant
,
constant_data
):
self
.
kernel_runner
.
load_constant
(
constant
,
constant_data
)
correction_step
=
{
...
...
@@ -390,3 +418,22 @@ class LpdCorrection(BaseCorrection):
),
metadata
,
)
def
preReconfigure
(
self
,
config
):
# TODO: DRY (taken from AGIPD device)
super
().
preReconfigure
(
config
)
if
config
.
has
(
"
corrections.badPixels.maskingValue
"
):
# only check if it is valid (let raise exception)
# if valid, postReconfigure will use it
np
.
float32
(
config
.
get
(
"
corrections.badPixels.maskingValue
"
))
def
postReconfigure
(
self
):
super
().
postReconfigure
()
if
not
hasattr
(
self
,
"
_prereconfigure_update_hash
"
):
return
update
=
self
.
_prereconfigure_update_hash
if
update
.
has
(
"
corrections.badPixels.maskingValue
"
):
masking_value
=
np
.
float32
(
update
[
"
corrections.badPixels.maskingValue
"
])
self
.
_kernel_runner_init_args
[
"
bad_pixel_mask_value
"
]
=
masking_value
self
.
kernel_runner
.
bad_pixel_mask_value
=
masking_value
This diff is collapsed.
Click to expand it.
David Hammer
@hammerd
mentioned in commit
3566342d
·
2 years ago
mentioned in commit
3566342d
mentioned in commit 3566342d031db1bb435b6430f100afdbaaa6c4bf
Toggle commit list
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