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
39f19061
Commit
39f19061
authored
2 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Fix old tests
parent
ce294243
No related branches found
No related tags found
3 merge requests
!29
Always use 352 memory cells for SlopesFF for AGIPD
,
!26
Add CPU kernels for some big detectors
,
!21
Draft: small JF tweaks from HED installation
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/tests/test_agipd_kernels.py
+11
-14
11 additions, 14 deletions
src/tests/test_agipd_kernels.py
src/tests/test_calcat_utils.py
+1
-1
1 addition, 1 deletion
src/tests/test_calcat_utils.py
src/tests/test_dssc_kernels.py
+17
-19
17 additions, 19 deletions
src/tests/test_dssc_kernels.py
with
29 additions
and
34 deletions
src/tests/test_agipd_kernels.py
+
11
−
14
View file @
39f19061
...
...
@@ -80,38 +80,35 @@ def corr_rel_gain_pc_cpu(data, cell_table, gain_map, slopes_pc):
def
test_thresholding
():
kernel_runner
.
load_cell_table
(
cell_table
)
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
load_thresholds
(
thresholds
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
load_constant
(
AgipdCorrection
.
Constants
.
ThresholdsDark
,
thresholds
)
kernel_runner
.
correct
(
AgipdCorrection
.
CorrectionFlags
.
THRESHOLD
)
gpu_res
=
kernel_runner
.
gain_map
_gpu
.
get
()
gpu_res
=
kernel_runner
.
gain_map
.
get
()
assert
np
.
allclose
(
gpu_res
,
gain_map_cpu
)
def
test_offset
():
kernel_runner
.
load_cell_table
(
cell_table
)
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
load_thresholds
(
thresholds
)
kernel_runner
.
load_offset_map
(
offset_map
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
load_constant
(
AgipdCorrection
.
Constants
.
ThresholdsDark
,
thresholds
)
kernel_runner
.
load_constant
(
AgipdCorrection
.
Constants
.
Offset
,
offset_map
)
# have to do thresholding, otherwise all is treated as high gain
kernel_runner
.
correct
(
AgipdCorrection
.
CorrectionFlags
.
THRESHOLD
|
AgipdCorrection
.
CorrectionFlags
.
OFFSET
)
cpu_res
=
corr_offset_cpu
(
raw_data
,
cell_table
,
gain_map_cpu
,
offset_map
)
gpu_res
=
kernel_runner
.
processed_data
_gpu
.
get
()
gpu_res
=
kernel_runner
.
processed_data
.
get
()
assert
np
.
allclose
(
gpu_res
,
cpu_res
)
def
test_rel_gain_pc
():
kernel_runner
.
load_cell_table
(
cell_table
)
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
load_thresholds
(
thresholds
)
kernel_runner
.
load_rel_gain_pc_map
(
slopes_pc_map
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
load_constant
(
AgipdCorrection
.
Constants
.
ThresholdsDark
,
thresholds
)
kernel_runner
.
load_constant
(
AgipdCorrection
.
Constants
.
SlopesPC
,
slopes_pc_map
)
kernel_runner
.
correct
(
AgipdCorrection
.
CorrectionFlags
.
THRESHOLD
|
AgipdCorrection
.
CorrectionFlags
.
REL_GAIN_PC
)
cpu_res
=
corr_rel_gain_pc_cpu
(
raw_data
,
cell_table
,
gain_map_cpu
,
slopes_pc_map
)
gpu_res
=
kernel_runner
.
processed_data
_gpu
.
get
()
gpu_res
=
kernel_runner
.
processed_data
.
get
()
assert
np
.
allclose
(
gpu_res
,
cpu_res
)
This diff is collapsed.
Click to expand it.
src/tests/test_calcat_utils.py
+
1
−
1
View file @
39f19061
import
pathlib
from
calng
import
AgipdCorrection
,
DsscCorrection
from
calng
.corrections
import
AgipdCorrection
,
DsscCorrection
from
calng.utils
import
Stopwatch
from
karabo.bound
import
Hash
,
Schema
import
pytest
...
...
This diff is collapsed.
Click to expand it.
src/tests/test_dssc_kernels.py
+
17
−
19
View file @
39f19061
...
...
@@ -42,46 +42,44 @@ kernel_runner = DsscCorrection.DsscGpuRunner(
def
test_only_cast
():
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
correct
(
DsscCorrection
.
CorrectionFlags
.
NONE
)
assert
np
.
allclose
(
kernel_runner
.
processed_data
_gpu
.
get
(),
raw_data
.
astype
(
output_dtype
)
kernel_runner
.
processed_data
.
get
(),
raw_data
.
astype
(
output_dtype
)
)
def
test_correct
():
kernel_runner
.
load_offset_map
(
offset_map
)
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
load_cell_table
(
cell_table
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
correct
(
DsscCorrection
.
CorrectionFlags
.
OFFSET
)
assert
np
.
allclose
(
kernel_runner
.
processed_data
_gpu
.
get
(),
corrected_data
)
assert
np
.
allclose
(
kernel_runner
.
processed_data
.
get
(),
corrected_data
)
def
test_correct_oob_cells
():
kernel_runner
.
load_offset_map
(
offset_map
)
kernel_runner
.
load_data
(
raw_data
)
# here, half the cell IDs will be out of bounds
wild_cell_table
=
cell_table
*
2
kernel_runner
.
load_
cell_table
(
wild_cell_table
)
kernel_runner
.
load_
data
(
raw_data
,
wild_cell_table
)
# should not crash
kernel_runner
.
correct
(
DsscCorrection
.
CorrectionFlags
.
OFFSET
)
# should correct as much as possible
assert
np
.
allclose
(
kernel_runner
.
processed_data
_gpu
.
get
(),
kernel_runner
.
processed_data
.
get
(),
correct_cpu
(
raw_data
,
wild_cell_table
,
offset_map
),
)
def
test_reshape
():
kernel_runner
.
processed_data
_gpu
.
set
(
corrected_data
)
kernel_runner
.
processed_data
.
set
(
corrected_data
)
assert
np
.
allclose
(
kernel_runner
.
reshape
(
output_order
=
"
xyf
"
),
corrected_data
.
transpose
()
)
def
test_preview_slice
():
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
processed_data
_gpu
.
set
(
corrected_data
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
processed_data
.
set
(
corrected_data
)
preview_raw
,
preview_corrected
=
kernel_runner
.
compute_previews
(
42
)
assert
np
.
allclose
(
preview_raw
,
...
...
@@ -95,8 +93,8 @@ def test_preview_slice():
def
test_preview_max
():
# note: in case correction failed, still test this separately
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
processed_data
_gpu
.
set
(
corrected_data
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
processed_data
.
set
(
corrected_data
)
preview_raw
,
preview_corrected
=
kernel_runner
.
compute_previews
(
-
1
)
assert
np
.
allclose
(
preview_raw
,
np
.
max
(
raw_data
,
axis
=
0
).
astype
(
np
.
float32
))
assert
np
.
allclose
(
...
...
@@ -105,8 +103,8 @@ def test_preview_max():
def
test_preview_mean
():
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
processed_data
_gpu
.
set
(
corrected_data
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
processed_data
.
set
(
corrected_data
)
preview_raw
,
preview_corrected
=
kernel_runner
.
compute_previews
(
-
2
)
assert
np
.
allclose
(
preview_raw
,
np
.
nanmean
(
raw_data
,
axis
=
0
,
dtype
=
np
.
float32
))
assert
np
.
allclose
(
...
...
@@ -115,8 +113,8 @@ def test_preview_mean():
def
test_preview_sum
():
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
processed_data
_gpu
.
set
(
corrected_data
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
processed_data
.
set
(
corrected_data
)
preview_raw
,
preview_corrected
=
kernel_runner
.
compute_previews
(
-
3
)
assert
np
.
allclose
(
preview_raw
,
np
.
nansum
(
raw_data
,
axis
=
0
,
dtype
=
np
.
float32
))
assert
np
.
allclose
(
...
...
@@ -125,8 +123,8 @@ def test_preview_sum():
def
test_preview_std
():
kernel_runner
.
load_data
(
raw_data
)
kernel_runner
.
processed_data
_gpu
.
set
(
corrected_data
)
kernel_runner
.
load_data
(
raw_data
,
cell_table
)
kernel_runner
.
processed_data
.
set
(
corrected_data
)
preview_raw
,
preview_corrected
=
kernel_runner
.
compute_previews
(
-
4
)
assert
np
.
allclose
(
preview_raw
,
np
.
nanstd
(
raw_data
,
axis
=
0
,
dtype
=
np
.
float32
))
assert
np
.
allclose
(
...
...
This diff is collapsed.
Click to expand it.
David Hammer
@hammerd
mentioned in commit
eef8fa4e
·
2 years ago
mentioned in commit
eef8fa4e
mentioned in commit eef8fa4e40fd52a930e236db2c9158966de07ef4
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