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
ac190c2d
Commit
ac190c2d
authored
3 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Restructure some helper functions
parent
0363c184
No related branches found
No related tags found
2 merge requests
!12
Snapshot: field test deployed version as of end of run 202201
,
!3
Base correction device, CalCat interaction, DSSC and AGIPD devices
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/calng/AgipdCorrection.py
+41
-26
41 additions, 26 deletions
src/calng/AgipdCorrection.py
src/calng/base_correction.py
+32
-24
32 additions, 24 deletions
src/calng/base_correction.py
src/tests/test_dssc_kernels.py
+1
-1
1 addition, 1 deletion
src/tests/test_dssc_kernels.py
with
74 additions
and
51 deletions
src/calng/AgipdCorrection.py
+
41
−
26
View file @
ac190c2d
...
@@ -98,13 +98,7 @@ class AgipdCorrection(BaseCorrection):
...
@@ -98,13 +98,7 @@ class AgipdCorrection(BaseCorrection):
.
key
(
"
corrections.relGainXray.gGainValue
"
)
.
key
(
"
corrections.relGainXray.gGainValue
"
)
.
displayedName
(
"
G_gain_value
"
)
.
displayedName
(
"
G_gain_value
"
)
.
description
(
.
description
(
"
The booleans under this node allow for selecting a subset of bad
"
"
Newer X-ray gain correction constants are absolute. The default
"
"
pixel types to take into account when doing bad pixel masking.
"
"
Upon updating these flags, the map used for bad pixel masking will
"
"
be ANDed with this selection. Therefore, if you want to toggle a
"
"
disabled flag back on, please reload constants for this to take
"
"
effect (will be triggered automatically in future version).
"
"
Modern X-ray gain correction constants are absolute. The default
"
"
G_gain_value of 1 means that output is expected to be in keV. If
"
"
G_gain_value of 1 means that output is expected to be in keV. If
"
"
this is not desired, one can here specify the mean X-ray gain value
"
"
this is not desired, one can here specify the mean X-ray gain value
"
"
over all modules to get ADU values out - operator must manually
"
"
over all modules to get ADU values out - operator must manually
"
...
@@ -129,9 +123,19 @@ class AgipdCorrection(BaseCorrection):
...
@@ -129,9 +123,19 @@ class AgipdCorrection(BaseCorrection):
NODE_ELEMENT
(
expected
)
NODE_ELEMENT
(
expected
)
.
key
(
"
corrections.badPixels.subsetToUse
"
)
.
key
(
"
corrections.badPixels.subsetToUse
"
)
.
displayedName
(
"
Bad pixel flags to use
"
)
.
displayedName
(
"
Bad pixel flags to use
"
)
.
description
(
"
The booleans under this node allow for selecting a subset of bad
"
"
pixel types to take into account when doing bad pixel masking.
"
"
Upon updating these flags, the map used for bad pixel masking will
"
"
be ANDed with this selection. Therefore, if you want to toggle a
"
"
disabled flag back on, please reload constants for this to take
"
"
effect (will be triggered automatically in future version).
"
)
.
commit
(),
.
commit
(),
)
)
AgipdCorrection
.
_managed_keys
.
append
(
"
corrections.relGainPc.overrideMdAdditionalOffset
"
)
AgipdCorrection
.
_managed_keys
.
append
(
"
corrections.relGainPc.overrideMdAdditionalOffset
"
)
AgipdCorrection
.
_managed_keys
.
append
(
"
corrections.relGainPc.mdAdditionalOffset
"
)
AgipdCorrection
.
_managed_keys
.
append
(
"
corrections.relGainPc.mdAdditionalOffset
"
)
AgipdCorrection
.
_managed_keys
.
append
(
"
corrections.relGainXray.gGainValue
"
)
AgipdCorrection
.
_managed_keys
.
append
(
"
corrections.relGainXray.gGainValue
"
)
AgipdCorrection
.
_managed_keys
.
append
(
"
corrections.badPixels.maskingValue
"
)
AgipdCorrection
.
_managed_keys
.
append
(
"
corrections.badPixels.maskingValue
"
)
...
@@ -145,7 +149,11 @@ class AgipdCorrection(BaseCorrection):
...
@@ -145,7 +149,11 @@ class AgipdCorrection(BaseCorrection):
.
reconfigurable
()
.
reconfigurable
()
.
commit
()
.
commit
()
)
)
AgipdCorrection
.
_managed_keys
.
append
(
f
"
corrections.badPixels.subsetToUse.
{
field
.
name
}
"
)
AgipdCorrection
.
_managed_keys
.
append
(
f
"
corrections.badPixels.subsetToUse.
{
field
.
name
}
"
)
# mandatory: manager needs this in schema
(
(
VECTOR_STRING_ELEMENT
(
expected
)
VECTOR_STRING_ELEMENT
(
expected
)
.
key
(
"
managedKeys
"
)
.
key
(
"
managedKeys
"
)
...
@@ -347,16 +355,7 @@ class AgipdCorrection(BaseCorrection):
...
@@ -347,16 +355,7 @@ class AgipdCorrection(BaseCorrection):
selection
|=
field
selection
|=
field
self
.
_override_bad_pixel_flags
=
selection
self
.
_override_bad_pixel_flags
=
selection
def
preReconfigure
(
self
,
config
):
super
().
preReconfigure
(
config
)
if
any
(
path
.
startswith
(
"
corrections.badPixels.subsetToUse
"
)
for
path
in
config
.
getPaths
()
):
self
.
_has_updated_bad_pixel_selection
=
False
def
postReconfigure
(
self
):
def
postReconfigure
(
self
):
# TODO: keep track of which things actually need updating
super
().
postReconfigure
()
super
().
postReconfigure
()
if
self
.
get
(
"
corrections.relGainPc.overrideMdAdditionalOffset
"
):
if
self
.
get
(
"
corrections.relGainPc.overrideMdAdditionalOffset
"
):
...
@@ -369,16 +368,32 @@ class AgipdCorrection(BaseCorrection):
...
@@ -369,16 +368,32 @@ class AgipdCorrection(BaseCorrection):
else
:
else
:
self
.
_override_md_additional_offset
=
None
self
.
_override_md_additional_offset
=
None
self
.
gpu_runner
.
set_g_gain_value
(
self
.
get
(
"
corrections.relGainXray.gGainValue
"
))
if
not
hasattr
(
self
,
"
_prereconfigure_update_hash
"
):
self
.
_gpu_runner_init_args
[
"
g_gain_value
"
]
=
self
.
get
(
return
"
corrections.relGainXray.gGainValue
"
)
self
.
bad_pixel_mask_value
=
eval
(
self
.
get
(
"
corrections.badPixels.maskingValue
"
))
update
=
self
.
_prereconfigure_update_hash
self
.
gpu_runner
.
set_bad_pixel_mask_value
(
self
.
bad_pixel_mask_value
)
self
.
_gpu_runner_init_args
[
"
bad_pixel_mask_value
"
]
=
self
.
bad_pixel_mask_value
if
not
self
.
_has_updated_bad_pixel_selection
:
if
update
.
has
(
"
corrections.relGainXray.gGainValue
"
):
self
.
gpu_runner
.
set_g_gain_value
(
self
.
get
(
"
corrections.relGainXray.gGainValue
"
)
)
self
.
_gpu_runner_init_args
[
"
g_gain_value
"
]
=
self
.
get
(
"
corrections.relGainXray.gGainValue
"
)
if
update
.
has
(
"
corrections.badPixels.maskingValue
"
):
self
.
bad_pixel_mask_value
=
eval
(
self
.
get
(
"
corrections.badPixels.maskingValue
"
)
)
self
.
gpu_runner
.
set_bad_pixel_mask_value
(
self
.
bad_pixel_mask_value
)
self
.
_gpu_runner_init_args
[
"
bad_pixel_mask_value
"
]
=
self
.
bad_pixel_mask_value
if
any
(
path
.
startswith
(
"
corrections.badPixels.subsetToUse
"
)
for
path
in
update
.
getPaths
()
):
self
.
_update_bad_pixel_selection
()
self
.
_update_bad_pixel_selection
()
self
.
gpu_runner
.
override_bad_pixel_flags_to_use
(
self
.
gpu_runner
.
override_bad_pixel_flags_to_use
(
self
.
_override_bad_pixel_flags
self
.
_override_bad_pixel_flags
...
...
This diff is collapsed.
Click to expand it.
src/calng/base_correction.py
+
32
−
24
View file @
ac190c2d
...
@@ -410,13 +410,21 @@ class BaseCorrection(PythonDevice):
...
@@ -410,13 +410,21 @@ class BaseCorrection(PythonDevice):
)
)
def
preReconfigure
(
self
,
config
):
def
preReconfigure
(
self
,
config
):
for
path
in
config
.
getPaths
():
self
.
_prereconfigure_update_hash
=
config
def
postReconfigure
(
self
):
if
not
hasattr
(
self
,
"
_prereconfigure_update_hash
"
):
self
.
log_status_warn
(
"
postReconfigure without knowing update hash
"
)
return
update
=
self
.
_prereconfigure_update_hash
for
path
in
update
.
getPaths
():
if
path
in
self
.
_schema_cache_fields
:
if
path
in
self
.
_schema_cache_fields
:
self
.
_schema_cache
[
path
]
=
config
.
get
(
path
)
self
.
_schema_cache
[
path
]
=
update
.
get
(
path
)
# TODO: pulse filter (after reimplementing)
# TODO: pulse filter (after reimplementing)
if
any
(
if
any
(
config
.
has
(
shape_param
)
update
.
has
(
shape_param
)
for
shape_param
in
(
for
shape_param
in
(
"
dataFormat.pixelsX
"
,
"
dataFormat.pixelsX
"
,
"
dataFormat.pixelsY
"
,
"
dataFormat.pixelsY
"
,
...
@@ -424,31 +432,10 @@ class BaseCorrection(PythonDevice):
...
@@ -424,31 +432,10 @@ class BaseCorrection(PythonDevice):
"
constantParameters.memoryCells
"
,
"
constantParameters.memoryCells
"
,
)
)
):
):
# will make postReconfigure handle shape update after merging schema
self
.
_has_updated_shapes
=
False
def
log_status_info
(
self
,
msg
):
self
.
log
.
INFO
(
msg
)
self
.
set
(
"
status
"
,
msg
)
def
log_status_warn
(
self
,
msg
):
self
.
log
.
WARN
(
msg
)
self
.
set
(
"
status
"
,
msg
)
def
postReconfigure
(
self
):
if
not
self
.
_has_updated_shapes
:
self
.
_update_shapes
()
self
.
_update_shapes
()
# TODO: only call this if they are changed (is cheap, though)
# TODO: only call this if they are changed (is cheap, though)
self
.
_update_correction_flags
()
self
.
_update_correction_flags
()
def
set
(
self
,
*
args
):
"""
Wrapper around PythonDevice.set to enable caching
"
hot
"
schema elements
"""
if
len
(
args
)
==
2
:
key
,
value
=
args
if
key
in
self
.
_schema_cache_fields
:
self
.
_schema_cache
[
key
]
=
value
super
().
set
(
*
args
)
def
loadMostRecentConstants
(
self
):
def
loadMostRecentConstants
(
self
):
self
.
flush_constants
()
self
.
flush_constants
()
self
.
calcat_friend
.
flush_constants
()
self
.
calcat_friend
.
flush_constants
()
...
@@ -464,6 +451,27 @@ class BaseCorrection(PythonDevice):
...
@@ -464,6 +451,27 @@ class BaseCorrection(PythonDevice):
self
.
gpu_runner
.
flush_buffers
()
self
.
gpu_runner
.
flush_buffers
()
self
.
_update_correction_flags
()
self
.
_update_correction_flags
()
def
log_status_info
(
self
,
msg
):
self
.
log
.
INFO
(
msg
)
self
.
set
(
"
status
"
,
msg
)
def
log_status_warn
(
self
,
msg
):
self
.
log
.
WARN
(
msg
)
self
.
set
(
"
status
"
,
msg
)
def
log_status_error
(
self
,
msg
):
self
.
set
(
"
status
"
,
msg
)
self
.
log
.
ERROR
(
msg
)
self
.
updateState
(
State
.
ERROR
)
def
set
(
self
,
*
args
):
"""
Wrapper around PythonDevice.set to enable caching
"
hot
"
schema elements
"""
if
len
(
args
)
==
2
:
key
,
value
=
args
if
key
in
self
.
_schema_cache_fields
:
self
.
_schema_cache
[
key
]
=
value
super
().
set
(
*
args
)
def
requestScene
(
self
,
params
):
def
requestScene
(
self
,
params
):
payload
=
Hash
()
payload
=
Hash
()
scene_name
=
params
.
get
(
"
name
"
,
default
=
""
)
scene_name
=
params
.
get
(
"
name
"
,
default
=
""
)
...
...
This diff is collapsed.
Click to expand it.
src/tests/test_dssc_kernels.py
+
1
−
1
View file @
ac190c2d
...
@@ -74,7 +74,7 @@ def test_correct_oob_cells():
...
@@ -74,7 +74,7 @@ def test_correct_oob_cells():
def
test_reshape
():
def
test_reshape
():
kernel_runner
.
processed_data_gpu
.
set
(
corrected_data
)
kernel_runner
.
processed_data_gpu
.
set
(
corrected_data
)
assert
np
.
allclose
(
kernel_runner
.
reshape
(),
corrected_data
.
transpose
())
assert
np
.
allclose
(
kernel_runner
.
reshape
(
output_order
=
"
xyc
"
),
corrected_data
.
transpose
())
def
test_preview_slice
():
def
test_preview_slice
():
...
...
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