Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cfel_fmt
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
dataAnalysis
cfel_fmt
Commits
78547b5a
Commit
78547b5a
authored
3 years ago
by
Florian Lauck
Browse files
Options
Downloads
Patches
Plain Diff
Fix return type in peakfinder
parent
ea3a8b48
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cfelpyutils/peakfinding/peakfinder8.py
+31
-20
31 additions, 20 deletions
cfelpyutils/peakfinding/peakfinder8.py
tests/peakfinding/test_peakfinder8.py
+5
-5
5 additions, 5 deletions
tests/peakfinding/test_peakfinder8.py
with
36 additions
and
25 deletions
cfelpyutils/peakfinding/peakfinder8.py
+
31
−
20
View file @
78547b5a
...
...
@@ -18,20 +18,31 @@ Peakfinder8 algorithm for detection of Bragg peaks in detector frame data.
"""
import
sys
from
typing
import
Type
,
List
,
Union
from
collections
import
namedtuple
from
typing
import
Union
import
h5py
# type: ignore
import
numpy
# type: ignore
from
mypy_extensions
import
TypedDict
from
.lib
import
peakfinder_8
PeakList
=
namedtuple
(
"
PeakList
"
,
[
"
num_peaks
"
,
"
fs
"
,
"
ss
"
,
"
intensity
"
])
"""
Information about Bragg peaks found in a detector data frame (list of peaks).
Arguments:
TypePeakList
=
TypedDict
(
"
TypePeakList
"
,
{
"
num_peaks
"
:
int
,
"
fs
"
:
List
[
float
],
"
ss
"
:
List
[
float
],
"
intensity
"
:
List
[
float
]},
total
=
True
,
)
num_peaks(int): number of peaks that were detected in the data frame.
fs (List[float]): a list of fractional fs indexes locating the detected peaks
in the detector data frame.
ss (List[float]): a list of fractional ss indexes locating the detected peaks
in the detector data frame.
intensity (List[float]): a list of integrated intensities for the detected
peaks.
"""
class
Peakfinder8PeakDetection
:
...
...
@@ -167,7 +178,7 @@ class Peakfinder8PeakDetection:
else
:
self
.
_mask
=
None
def
find_peaks
(
self
,
data
:
numpy
.
ndarray
)
->
Type
PeakList
:
def
find_peaks
(
self
,
data
:
numpy
.
ndarray
)
->
PeakList
:
"""
Finds peaks in a detector data frame.
...
...
@@ -181,19 +192,19 @@ class Peakfinder8PeakDetection:
Returns:
Type
PeakList: a
dictionary
with information about the Bragg peaks
detected in a data frame. The
dictionary
has the following
key
s:
PeakList: a
namedtuple
with information about the Bragg peaks
detected in a data frame. The
object
has the following
attribute
s:
- A
key
named
"
num_peaks
"
whose value is the number of peaks that were
- A
n attribute
named
"
num_peaks
"
whose value is the number of peaks that were
detected in the data frame.
- A
key
named
'
fs
'
whose value is a list of fractional fs indexes locating
- A
n attribute
named
'
fs
'
whose value is a list of fractional fs indexes locating
the detected peaks in the data frame.
- A
key
named
'
ss
'
whose value is a list of fractional ss indexes locating
- A
n attribute
named
'
ss
'
whose value is a list of fractional ss indexes locating
the detected peaks in the data frame.
- A
key
named
'
intensity
'
whose value is a list of integrated intensities
- A
n attribute
named
'
intensity
'
whose value is a list of integrated intensities
for the detected peaks.
"""
if
not
self
.
_mask_initialized
:
...
...
@@ -223,9 +234,9 @@ class Peakfinder8PeakDetection:
self
.
_local_bg_radius
,
)
return
{
"
num_peaks
"
:
len
(
peak_list
[
0
]),
"
fs
"
:
peak_list
[
0
],
"
ss
"
:
peak_list
[
1
],
"
intensity
"
:
peak_list
[
2
],
}
return
PeakList
(
num_peaks
=
len
(
peak_list
[
0
]),
fs
=
peak_list
[
0
],
ss
=
peak_list
[
1
],
intensity
=
peak_list
[
2
],
)
This diff is collapsed.
Click to expand it.
tests/peakfinding/test_peakfinder8.py
+
5
−
5
View file @
78547b5a
...
...
@@ -16,7 +16,7 @@
import
numpy
import
pytest
from
cfelpyutils.geometry
import
compute_pix_maps
,
load_crystfel_geometry
from
cfelpyutils.geometry
import
compute_pix_maps
from
cfelpyutils.peakfinding.peakfinder8
import
Peakfinder8PeakDetection
from
tests.fixtures
import
detector_geometry
...
...
@@ -82,7 +82,7 @@ class TestPeakfinder8PeakDetection:
def
test_find_peak
(
self
,
peakfinder_config
,
detector_image_with_4_peaks
):
peakfinder
=
Peakfinder8PeakDetection
(
**
peakfinder_config
)
peak_list
=
peakfinder
.
find_peaks
(
detector_image_with_4_peaks
)
assert
peak_list
[
"
num_peaks
"
]
==
4
assert
len
(
peak_list
[
"
intensity
"
]
)
==
4
assert
len
(
peak_list
[
"
fs
"
]
)
==
4
assert
len
(
peak_list
[
"
ss
"
]
)
==
4
assert
peak_list
.
num_peaks
==
4
assert
len
(
peak_list
.
intensity
)
==
4
assert
len
(
peak_list
.
fs
)
==
4
assert
len
(
peak_list
.
ss
)
==
4
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