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
61257760
Commit
61257760
authored
1 year ago
by
Egor Sobolev
Committed by
David Hammer
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve integrated intensity addon
parent
4d477e94
No related branches found
No related tags found
1 merge request
!58
Improve integrated intensity addon
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/calng/correction_addons/integrated_intensity.py
+61
-6
61 additions, 6 deletions
src/calng/correction_addons/integrated_intensity.py
with
61 additions
and
6 deletions
src/calng/correction_addons/integrated_intensity.py
+
61
−
6
View file @
61257760
import
numpy
as
np
from
karabo.bound
import
NDARRAY_ELEMENT
from
karabo.bound
import
DOUBLE_ELEMENT
,
NDARRAY_ELEMENT
,
NODE_ELEMENT
from
.base_addon
import
BaseCorrectionAddon
...
...
@@ -13,18 +13,73 @@ def maybe_get(a):
class
IntegratedIntensityAddon
(
BaseCorrectionAddon
):
_node_name
=
"
integratedIntensity
"
def
__init__
(
self
,
config
):
global
cupy
import
cupy
self
.
_vmin
=
config
[
"
valueMin
"
]
self
.
_vmax
=
config
[
"
valueMax
"
]
def
reconfigure
(
self
,
changed_config
):
if
changed_config
.
has
(
"
valueMin
"
):
self
.
_vmin
=
changed_config
[
"
valueMin
"
]
if
changed_config
.
has
(
"
valueMax
"
):
self
.
_vmax
=
changed_config
[
"
valueMax
"
]
@staticmethod
def
extend_output_schema
(
schema
):
# note: sort of assumes XTDF hash structure
(
NODE_ELEMENT
(
schema
)
.
key
(
"
integratedIntensity
"
)
.
commit
(),
NDARRAY_ELEMENT
(
schema
)
.
key
(
"
integratedIntensity.mean
"
)
.
dtype
(
"
DOUBLE
"
)
.
commit
(),
NDARRAY_ELEMENT
(
schema
)
.
key
(
"
image.
integratedIntensity
"
)
.
key
(
"
integratedIntensity
.variance
"
)
.
dtype
(
"
DOUBLE
"
)
.
commit
(),
NDARRAY_ELEMENT
(
schema
)
.
key
(
"
integratedIntensity.count
"
)
.
dtype
(
"
UINT64
"
)
.
commit
()
)
def
post_correction
(
self
,
processed_data
,
cell_table
,
pulse_table
,
output_hash
):
# Numpy should handle CuPy dispatch for us
output_hash
[
"
image.integratedIntensity
"
]
=
maybe_get
(
np
.
nansum
(
processed_data
,
axis
=
(
1
,
2
))
@staticmethod
def
extend_device_schema
(
schema
,
prefix
):
(
DOUBLE_ELEMENT
(
schema
)
.
key
(
f
"
{
prefix
}
.valueMin
"
)
.
tags
(
"
managed
"
)
.
assignmentOptional
()
.
defaultValue
(
-
10.0
)
.
reconfigurable
()
.
commit
(),
DOUBLE_ELEMENT
(
schema
)
.
key
(
f
"
{
prefix
}
.valueMax
"
)
.
tags
(
"
managed
"
)
.
assignmentOptional
()
.
defaultValue
(
20000.0
)
.
reconfigurable
()
.
commit
()
)
def
post_correction
(
self
,
data
,
cell_table
,
pulse_table
,
output_hash
):
# Numpy should handle CuPy dispatch for us
mask
=
np
.
isfinite
(
data
)
&
(
self
.
_vmin
<
data
)
&
(
data
<
self
.
_vmax
)
count
=
np
.
sum
(
mask
,
axis
=
(
1
,
2
))
tmp
=
mask
*
data
mu
=
np
.
sum
(
tmp
,
axis
=
(
1
,
2
))
/
count
var
=
np
.
sum
(
tmp
*
data
,
axis
=
(
1
,
2
))
/
count
-
mu
*
mu
output_hash
[
"
integratedIntensity.mean
"
]
=
maybe_get
(
mu
)
output_hash
[
"
integratedIntensity.variance
"
]
=
maybe_get
(
var
)
output_hash
[
"
integratedIntensity.count
"
]
=
maybe_get
(
count
)
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