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
9e38518f
Commit
9e38518f
authored
3 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Move some initialization out of __init__
parent
7cfb2ca6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+6
-4
6 additions, 4 deletions
src/calng/AgipdCorrection.py
src/calng/DsscCorrection.py
+0
-4
0 additions, 4 deletions
src/calng/DsscCorrection.py
src/calng/base_correction.py
+21
-18
21 additions, 18 deletions
src/calng/base_correction.py
with
27 additions
and
26 deletions
src/calng/AgipdCorrection.py
+
6
−
4
View file @
9e38518f
...
@@ -219,7 +219,7 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner):
...
@@ -219,7 +219,7 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner):
self
.
g_gain_value
=
cupy
.
float32
(
override_value
)
self
.
g_gain_value
=
cupy
.
float32
(
override_value
)
def
load_bad_pixels_map
(
self
,
bad_pixels_map
,
override_flags_to_use
=
None
):
def
load_bad_pixels_map
(
self
,
bad_pixels_map
,
override_flags_to_use
=
None
):
print
(
f
"
Loading bad pixels with shape:
{
bad_pixels_map
.
shape
}
"
)
self
.
log_status_info
(
f
"
Loading bad pixels with shape:
{
bad_pixels_map
.
shape
}
"
)
# will simply OR with already loaded, does not take into account which ones
# will simply OR with already loaded, does not take into account which ones
# TODO: inquire what "mask for double size pixels" means
# TODO: inquire what "mask for double size pixels" means
if
len
(
bad_pixels_map
.
shape
)
==
3
:
if
len
(
bad_pixels_map
.
shape
)
==
3
:
...
@@ -619,11 +619,12 @@ class AgipdCorrection(BaseCorrection):
...
@@ -619,11 +619,12 @@ class AgipdCorrection(BaseCorrection):
else
:
else
:
self
.
_override_md_additional_offset
=
None
self
.
_override_md_additional_offset
=
None
# configurability: disabling subset of bad pixel masking bits
self
.
_has_updated_bad_pixel_selection
=
False
self
.
_has_updated_bad_pixel_selection
=
False
self
.
registerInitialFunction
(
self
.
_update_bad_pixel_selection
)
self
.
updateState
(
State
.
ON
)
def
_initialization
(
self
):
self
.
_update_bad_pixel_selection
()
super
().
_initialization
()
def
process_data
(
def
process_data
(
self
,
self
,
...
@@ -763,6 +764,7 @@ class AgipdCorrection(BaseCorrection):
...
@@ -763,6 +764,7 @@ class AgipdCorrection(BaseCorrection):
def
postReconfigure
(
self
):
def
postReconfigure
(
self
):
super
().
postReconfigure
()
super
().
postReconfigure
()
# TODO: move after getting cached update, check if necessary
if
self
.
get
(
"
corrections.relGainPc.overrideMdAdditionalOffset
"
):
if
self
.
get
(
"
corrections.relGainPc.overrideMdAdditionalOffset
"
):
self
.
_override_md_additional_offset
=
self
.
get
(
self
.
_override_md_additional_offset
=
self
.
get
(
"
corrections.relGainPc.mdAdditionalOffset
"
"
corrections.relGainPc.mdAdditionalOffset
"
...
...
This diff is collapsed.
Click to expand it.
src/calng/DsscCorrection.py
+
0
−
4
View file @
9e38518f
...
@@ -205,10 +205,6 @@ class DsscCorrection(BaseCorrection):
...
@@ -205,10 +205,6 @@ class DsscCorrection(BaseCorrection):
self
.
get
(
"
dataFormat.pixelsX
"
),
self
.
get
(
"
dataFormat.pixelsX
"
),
)
)
def
__init__
(
self
,
config
):
super
().
__init__
(
config
)
self
.
updateState
(
State
.
ON
)
def
process_data
(
def
process_data
(
self
,
self
,
data_hash
,
data_hash
,
...
...
This diff is collapsed.
Click to expand it.
src/calng/base_correction.py
+
21
−
18
View file @
9e38518f
...
@@ -555,34 +555,34 @@ class BaseCorrection(PythonDevice):
...
@@ -555,34 +555,34 @@ class BaseCorrection(PythonDevice):
k
:
config
.
get
(
k
)
for
k
in
self
.
_schema_cache_fields
if
config
.
has
(
k
)
k
:
config
.
get
(
k
)
for
k
in
self
.
_schema_cache_fields
if
config
.
has
(
k
)
}
}
super
().
__init__
(
config
)
super
().
__init__
(
config
)
self
.
updateState
(
State
.
INIT
)
if
not
sorted
(
config
.
get
(
"
dataFormat.outputAxisOrder
"
))
==
[
"
c
"
,
"
x
"
,
"
y
"
]:
if
not
sorted
(
config
.
get
(
"
dataFormat.outputAxisOrder
"
))
==
[
"
c
"
,
"
x
"
,
"
y
"
]:
# TODO: figure out how to get this information to operator
# TODO: figure out how to get this information to operator
self
.
log_status_error
(
"
Invalid output axis order string
"
)
self
.
log_status_error
(
"
Invalid output axis order string
"
)
return
return
self
.
KARABO_ON_INPUT
(
"
dataInput
"
,
self
.
input_handler
)
self
.
input_data_dtype
=
np
.
dtype
(
config
.
get
(
"
dataFormat.inputImageDtype
"
)
)
self
.
KARABO_ON_EOS
(
"
dataInput
"
,
self
.
handle_eos
)
self
.
output_data_dtype
=
np
.
dtype
(
config
.
get
(
"
dataFormat.outputImageDtype
"
)
)
self
.
sources
=
set
(
config
.
get
(
"
fastSources
"
))
self
.
sources
=
set
(
config
.
get
(
"
fastSources
"
))
self
.
input_data_dtype
=
np
.
dtype
(
config
.
get
(
"
dataFormat.inputImageDtype
"
))
self
.
output_data_dtype
=
np
.
dtype
(
config
.
get
(
"
dataFormat.outputImageDtype
"
))
self
.
kernel_runner
=
None
# must call _update_buffers to initialize
self
.
kernel_runner
=
None
# must call _update_buffers to initialize
self
.
registerInitialFunction
(
self
.
_update_frame_filter
)
self
.
_shmem_buffer
=
None
# ditto
self
.
registerInitialFunction
(
self
.
_update_buffers
)
self
.
calcat_friend
=
self
.
_calcat_friend_class
(
self
,
pathlib
.
Path
.
cwd
()
/
"
calibration-client-secrets.json
"
)
self
.
_correction_flag_enabled
=
self
.
_correction_flag_class
.
NONE
self
.
_correction_flag_enabled
=
self
.
_correction_flag_class
.
NONE
self
.
_correction_flag_preview
=
self
.
_correction_flag_class
.
NONE
self
.
_correction_flag_preview
=
self
.
_correction_flag_class
.
NONE
self
.
_buffer_lock
=
threading
.
Lock
()
self
.
_last_processing_started
=
0
# used for processing time and timeout
self
.
_shmem_buffer
=
None
self
.
registerInitialFunction
(
self
.
_initialization
)
self
.
_processing_time_ema
=
utils
.
ExponentialMovingAverage
(
alpha
=
0.3
)
self
.
_rate_tracker
=
utils
.
WindowRateTracker
()
def
_initialization
(
self
):
self
.
updateState
(
State
.
INIT
)
self
.
calcat_friend
=
self
.
_calcat_friend_class
(
self
,
pathlib
.
Path
.
cwd
()
/
"
calibration-client-secrets.json
"
)
self
.
_update_frame_filter
()
self
.
_update_buffers
()
self
.
_buffered_status_update
=
Hash
(
self
.
_buffered_status_update
=
Hash
(
"
trainId
"
,
"
trainId
"
,
...
@@ -592,14 +592,15 @@ class BaseCorrection(PythonDevice):
...
@@ -592,14 +592,15 @@ class BaseCorrection(PythonDevice):
"
performance.processingTime
"
,
"
performance.processingTime
"
,
0
,
0
,
)
)
self
.
_last_processing_started
=
0
# used for processing time and timeout
self
.
_processing_time_ema
=
utils
.
ExponentialMovingAverage
(
alpha
=
0.3
)
self
.
_rate_tracker
=
utils
.
WindowRateTracker
()
self
.
_rate_update_timer
=
utils
.
RepeatingTimer
(
self
.
_rate_update_timer
=
utils
.
RepeatingTimer
(
interval
=
1
,
interval
=
1
,
callback
=
self
.
_update_rate_and_state
,
callback
=
self
.
_update_rate_and_state
,
)
)
self
.
_buffer_lock
=
threading
.
Lock
()
self
.
KARABO_
SLOT
(
self
.
loadMostRecentConstants
)
self
.
KARABO_
ON_INPUT
(
"
dataInput
"
,
self
.
input_handler
)
self
.
KARABO_
SLOT
(
self
.
requestScene
)
self
.
KARABO_
ON_EOS
(
"
dataInput
"
,
self
.
handle_eos
)
if
parse_version
(
karaboVersion
)
>=
parse_version
(
"
2.11
"
):
if
parse_version
(
karaboVersion
)
>=
parse_version
(
"
2.11
"
):
# TODO: the CalCatFriend could add these for us
# TODO: the CalCatFriend could add these for us
...
@@ -620,6 +621,8 @@ class BaseCorrection(PythonDevice):
...
@@ -620,6 +621,8 @@ class BaseCorrection(PythonDevice):
slotName
=
meth_name
,
slotName
=
meth_name
,
)
)
self
.
updateState
(
State
.
ON
)
def
__del__
(
self
):
def
__del__
(
self
):
del
self
.
_shmem_buffer
del
self
.
_shmem_buffer
...
...
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