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
93690d4f
Commit
93690d4f
authored
2 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Enable configurable bad pixel subset
parent
cc9459fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!25
GH2: CalCat support and updates for next run
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/calng/corrections/Gotthard2Correction.py
+61
-7
61 additions, 7 deletions
src/calng/corrections/Gotthard2Correction.py
with
61 additions
and
7 deletions
src/calng/corrections/Gotthard2Correction.py
+
61
−
7
View file @
93690d4f
...
...
@@ -28,6 +28,12 @@ class Constants(enum.Enum):
BadPixelsFFGotthard2
=
enum
.
auto
()
bp_constant_types
=
{
Constants
.
BadPixelsDarkGotthard2
,
Constants
.
BadPixelsFFGotthard2
,
}
class
CorrectionFlags
(
enum
.
IntFlag
):
NONE
=
0
LUT
=
1
...
...
@@ -46,6 +52,7 @@ class Gotthard2CpuRunner(base_kernel_runner.BaseKernelRunner):
input_data_dtype
=
np
.
uint16
,
output_data_dtype
=
np
.
float32
,
bad_pixel_mask_value
=
np
.
nan
,
bad_pixel_subset
=
None
,
):
super
().
__init__
(
pixels_x
,
...
...
@@ -71,6 +78,7 @@ class Gotthard2CpuRunner(base_kernel_runner.BaseKernelRunner):
self
.
bad_pixel_map
=
np
.
empty
(
self
.
map_shape
,
dtype
=
np
.
uint32
)
self
.
bad_pixel_mask_value
=
bad_pixel_mask_value
self
.
flush_buffers
()
self
.
_bad_pixel_subset
=
bad_pixel_subset
self
.
input_data
=
None
# will just point to data coming in
self
.
input_gain_stage
=
None
# will just point to data coming in
...
...
@@ -87,15 +95,20 @@ class Gotthard2CpuRunner(base_kernel_runner.BaseKernelRunner):
self
.
offset_map
[:]
=
np
.
transpose
(
data
.
astype
(
np
.
float32
,
copy
=
False
))
elif
constant_type
is
Constants
.
RelativeGainGotthard2
:
self
.
rel_gain_map
[:]
=
np
.
transpose
(
data
.
astype
(
np
.
float32
,
copy
=
False
))
elif
constant_type
in
{
Constants
.
BadPixelsDarkGotthard2
,
Constants
.
BadPixelsFFGotthard2
,
}:
elif
constant_type
in
bp_constant_types
:
# TODO: add the regular bad pixel subset configuration
self
.
bad_pixel_map
|=
np
.
transpose
(
data
.
astype
(
np
.
uint32
,
copy
=
False
))
data
=
data
.
astype
(
np
.
uint32
,
copy
=
False
)
if
self
.
_bad_pixel_subset
is
not
None
:
data
=
data
&
self
.
_bad_pixel_subset
self
.
bad_pixel_map
|=
np
.
transpose
(
data
)
else
:
raise
ValueError
(
f
"
What is this constant
'
{
constant_type
}
'
?
"
)
def
set_bad_pixel_subset
(
self
,
subset
,
apply_now
=
True
):
self
.
_bad_pixel_subset
=
subset
if
apply_now
:
self
.
bad_pixel_map
&=
self
.
_bad_pixel_subset
def
load_data
(
self
,
image_data
,
input_gain_stage
):
"""
Experiment: loading both in one function as they are tied
"""
self
.
input_data
=
image_data
.
astype
(
np
.
uint16
,
copy
=
False
)
...
...
@@ -318,6 +331,9 @@ class Gotthard2Correction(base_correction.BaseCorrection):
Gotthard2Correction
.
_managed_keys
,
Gotthard2Correction
.
_correction_steps
,
)
base_correction
.
add_bad_pixel_config_node
(
expected
,
Gotthard2Correction
.
_managed_keys
)
# mandatory: manager needs this in schema
(
...
...
@@ -344,12 +360,50 @@ class Gotthard2Correction(base_correction.BaseCorrection):
@property
def
_kernel_runner_init_args
(
self
):
return
{
"
bad_pixel_mask_value
"
:
self
.
bad_pixel_mask_value
}
return
{
"
bad_pixel_mask_value
"
:
self
.
_bad_pixel_mask_value
,
"
bad_pixel_subset
"
:
self
.
_bad_pixel_subset
,
}
@property
def
bad_pixel_mask_value
(
self
):
def
_
bad_pixel_mask_value
(
self
):
return
np
.
float32
(
self
.
unsafe_get
(
"
corrections.badPixels.maskingValue
"
))
_bad_pixel_subset
=
property
(
base_correction
.
get_bad_pixel_field_selection
)
def
postReconfigure
(
self
):
super
().
postReconfigure
()
update
=
self
.
_prereconfigure_update_hash
if
update
.
has
(
"
corrections.badPixels.subsetToUse
"
):
if
any
(
update
.
get
(
f
"
corrections.badPixels.subsetToUse.
{
field
.
name
}
"
,
default
=
False
)
for
field
in
utils
.
BadPixelValues
):
self
.
log_status_info
(
"
Some fields reenabled, reloading cached bad pixel constants
"
)
self
.
kernel_runner
.
set_bad_pixel_subset
(
self
.
_bad_pixel_subset
,
apply_now
=
False
)
with
self
.
calcat_friend
.
cached_constants_lock
:
self
.
kernel_runner
.
flush_buffers
(
bp_constant_types
)
for
constant_type
in
(
bp_constant_types
&
self
.
calcat_friend
.
cached_constants
.
keys
()
):
self
.
_load_constant_to_runner
(
constant_type
,
self
.
calcat_friend
.
cached_constants
[
constant_type
],
)
else
:
# just narrowing the subset - no reload, just AND
self
.
kernel_runner
.
set_bad_pixel_subset
(
self
.
_bad_pixel_subset
,
apply_now
=
True
)
if
update
.
has
(
"
corrections.badPixels.maskingvalue
"
):
self
.
kernel_runner
.
bad_pixel_mask_value
=
self
.
_bad_pixel_mask_value
def
__init__
(
self
,
config
):
super
().
__init__
(
config
)
try
:
...
...
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