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
47314d47
Commit
47314d47
authored
2 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
LPD: DRYing constant loading, swapping axes for FF constants
parent
00db322c
No related branches found
No related tags found
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
+29
-36
29 additions, 36 deletions
src/calng/LpdCorrection.py
with
29 additions
and
36 deletions
src/calng/LpdCorrection.py
+
29
−
36
View file @
47314d47
...
...
@@ -14,15 +14,6 @@ from ._version import version as deviceVersion
from
.base_correction
import
BaseCorrection
,
add_correction_step_schema
class
CorrectionFlags
(
enum
.
IntFlag
):
NONE
=
0
OFFSET
=
1
GAIN_AMP
=
2
REL_GAIN
=
4
FF_CORR
=
8
BPMASK
=
16
class
LpdConstants
(
enum
.
Enum
):
Offset
=
enum
.
auto
()
BadPixelsDark
=
enum
.
auto
()
...
...
@@ -32,6 +23,15 @@ class LpdConstants(enum.Enum):
BadPixelsFF
=
enum
.
auto
()
class
CorrectionFlags
(
enum
.
IntFlag
):
NONE
=
0
OFFSET
=
1
GAIN_AMP
=
2
REL_GAIN
=
4
FF_CORR
=
8
BPMASK
=
16
class
LpdGpuRunner
(
base_gpu
.
BaseGpuRunner
):
_kernel_source_filename
=
"
lpd_gpu.cu
"
_corrected_axis_order
=
"
cxy
"
...
...
@@ -91,43 +91,36 @@ class LpdGpuRunner(base_gpu.BaseGpuRunner):
)
def
load_constant
(
self
,
constant_type
,
constant_data
):
if
constant_type
is
LpdConstants
.
Offset
:
self
.
offset_map_gpu
.
set
(
np
.
transpose
(
constant_data
.
astype
(
np
.
float32
),
(
2
,
1
,
0
,
3
),
)
)
elif
constant_type
in
(
LpdConstants
.
BadPixelsDark
,
LpdConstants
.
BadPixelsFF
):
# constant type → transpose order
bad_pixel_loading
=
{
LpdConstants
.
BadPixelsDark
:
(
2
,
1
,
0
,
3
),
LpdConstants
.
BadPixelsFF
:
(
2
,
0
,
1
,
3
),
}
# constant type → transpose order, GPU buffer
other_constant_loading
=
{
LpdConstants
.
Offset
:
((
2
,
1
,
0
,
3
),
self
.
offset_map_gpu
),
LpdConstants
.
GainAmpMap
:
((
2
,
1
,
0
,
3
),
self
.
gain_amp_map_gpu
),
LpdConstants
.
FFMap
:
((
2
,
0
,
1
,
3
),
self
.
flatfield_map_gpu
),
LpdConstants
.
RelativeGain
:
((
2
,
1
,
0
,
3
),
self
.
rel_gain_slopes_map_gpu
),
}
if
constant_type
in
bad_pixel_loading
:
self
.
bad_pixel_map_gpu
|=
cupy
.
asarray
(
np
.
transpose
(
constant_data
,
(
2
,
1
,
0
,
3
)
,
bad_pixel_loading
[
constant_type
]
,
),
dtype
=
np
.
uint32
,
)
elif
constant_type
is
LpdConstants
.
GainAmpMap
:
self
.
gain_amp_map_gpu
.
set
(
np
.
transpose
(
constant_data
.
astype
(
np
.
float32
),
(
2
,
1
,
0
,
3
),
)
)
elif
constant_type
is
LpdConstants
.
FFMap
:
self
.
flatfield_map_gpu
.
set
(
np
.
transpose
(
constant_data
.
astype
(
np
.
float32
),
(
2
,
1
,
0
,
3
),
)
)
elif
constant_type
is
LpdConstants
.
RelativeGain
:
# TODO: figure out where to get
self
.
rel_gain_slopes_map_gpu
.
set
(
elif
constant_type
in
other_constant_loading
:
transpose_order
,
gpu_buffer
=
other_constant_loading
[
constant_type
]
gpu_buffer
.
set
(
np
.
transpose
(
constant_data
.
astype
(
np
.
float32
),
(
2
,
1
,
0
,
3
)
,
transpose_order
,
)
)
else
:
raise
ValueError
(
f
"
Unhandled constant type
{
constant_type
}
"
)
def
_init_kernels
(
self
):
kernel_source
=
self
.
_kernel_template
.
render
(
...
...
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