Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
pycalibration
Commits
c23dfc1f
Commit
c23dfc1f
authored
2 years ago
by
Philipp Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
Add native implementation for LPD correction loop
parent
efe2c2c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!672
[LPD] New correction notebook
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
setup.py
+7
-0
7 additions, 0 deletions
setup.py
src/cal_tools/lpdalgs.pyx
+72
-0
72 additions, 0 deletions
src/cal_tools/lpdalgs.pyx
with
79 additions
and
0 deletions
setup.py
+
7
−
0
View file @
c23dfc1f
...
@@ -18,6 +18,13 @@ ext_modules = [
...
@@ -18,6 +18,13 @@ ext_modules = [
extra_compile_args
=
[
"
-fopenmp
"
,
"
-march=native
"
],
extra_compile_args
=
[
"
-fopenmp
"
,
"
-march=native
"
],
extra_link_args
=
[
"
-fopenmp
"
],
extra_link_args
=
[
"
-fopenmp
"
],
),
),
Extension
(
'
cal_tools.lpdalgs
'
,
[
'
src/cal_tools/lpdalgs.pyx
'
],
include_dirs
=
[
numpy
.
get_include
()],
extra_compile_args
=
[
'
-O3
'
,
'
-fopenmp
'
,
'
-march=native
'
],
extra_link_args
=
[
'
-fopenmp
'
],
)
]
]
...
...
This diff is collapsed.
Click to expand it.
src/cal_tools/lpdalgs.pyx
0 → 100644
+
72
−
0
View file @
c23dfc1f
from
cython
cimport
boundscheck
,
wraparound
,
cdivision
from
cython.view
cimport
contiguous
from
cython.parallel
cimport
prange
from
cal_tools.enums
import
BadPixels
ctypedef
unsigned
short
cell_t
ctypedef
unsigned
short
data_t
ctypedef
float
pixel_t
ctypedef
unsigned
char
gain_t
ctypedef
unsigned
int
mask_t
cdef
mask_t
WRONG_GAIN_VALUE
=
BadPixels
.
WRONG_GAIN_VALUE
,
\
VALUE_OUT_OF_RANGE
=
BadPixels
.
VALUE_OUT_OF_RANGE
,
\
VALUE_IS_NAN
=
BadPixels
.
VALUE_IS_NAN
@boundscheck
(
False
)
@wraparound
(
False
)
@cdivision
(
True
)
def
correct_lpd_frames
(
# (pulse, x, y)
data_t
[:,
:,
::
contiguous
]
in_data
,
cell_t
[::
contiguous
]
in_cell
,
# (pulse, x, y)
pixel_t
[:,
:,
::
contiguous
]
out_pixels
,
gain_t
[:,
:,
::
contiguous
]
out_gain
,
mask_t
[:,
:,
::
contiguous
]
out_mask
,
# (x, y, cell, gain)
float
[:,
:,
:,
::
contiguous
]
ccv_offset
,
float
[:,
:,
:,
::
contiguous
]
ccv_gain
,
mask_t
[:,
:,
:,
::
contiguous
]
ccv_mask
,
int
num_threads
=
1
,
):
cdef
int
frame
,
ss
,
fs
cdef
cell_t
cell
cdef
pixel_t
pixel
cdef
gain_t
gain
cdef
mask_t
mask
for
frame
in
prange
(
in_data
.
shape
[
0
],
nogil
=
True
,
num_threads
=
num_threads
):
for
ss
in
range
(
in_data
.
shape
[
1
]):
for
fs
in
range
(
in_data
.
shape
[
2
]):
cell
=
in_cell
[
frame
]
pixel
=
<
pixel_t
>
(
in_data
[
frame
,
ss
,
fs
]
&
0b0000111111111111
)
gain
=
in_data
[
frame
,
ss
,
fs
]
&
0b0000000000000011
if
gain
<=
2
:
mask
=
ccv_mask
[
ss
,
fs
,
cell
,
gain
]
else
:
pixel
=
0.0
gain
=
0
mask
=
WRONG_GAIN_VALUE
pixel
=
pixel
-
ccv_offset
[
ss
,
fs
,
cell
,
gain
]
if
ccv_gain
[
ss
,
fs
,
cell
,
gain
]
!=
0.0
:
pixel
=
pixel
*
ccv_gain
[
ss
,
fs
,
cell
,
gain
]
else
:
pixel
=
0.0
mask
=
mask
|
VALUE_IS_NAN
if
pixel
>
1e7
or
pixel
<
-
1e7
:
pixel
=
0.0
mask
=
mask
|
VALUE_OUT_OF_RANGE
out_pixels
[
frame
,
ss
,
fs
]
=
pixel
out_gain
[
frame
,
ss
,
fs
]
=
gain
out_mask
[
frame
,
ss
,
fs
]
=
mask
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