Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Kluyver
Pycrystfel
Commits
2b97afc2
Commit
2b97afc2
authored
Jan 08, 2021
by
Thomas Kluyver
Browse files
Convert Crystfel feature list to pandas Dataframe
parent
6196b0aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/find_peaks.py
View file @
2b97afc2
...
...
@@ -9,4 +9,7 @@ f = h5py.File(os.path.join(THIS_DIR, 'monolithic_img_1.h5'), 'r')
arr
=
f
[
'data/data'
][()]
print
(
"Image shape:"
,
arr
.
shape
)
find_peaks_single_panel
(
arr
,
os
.
path
.
join
(
THIS_DIR
,
'1panel.geom'
))
peaks_tbl
=
find_peaks_single_panel
(
arr
,
os
.
path
.
join
(
THIS_DIR
,
'1panel.geom'
))
print
(
f
"Found
{
len
(
peaks_tbl
)
}
peaks"
)
print
(
peaks_tbl
.
head
())
pycrystfel/bindings.pyx
View file @
2b97afc2
import
os
import
numpy
as
np
import
pandas
as
pd
from
libc.stdint
cimport
uintptr_t
cimport
cython
from
libc.stdlib
cimport
malloc
,
free
cimport
numpy
as
cnp
...
...
@@ -19,6 +20,35 @@ def inspect_geom_file(path):
print
(
"photon energy:"
,
beam
.
photon_energy
)
crystfel
.
free_detector_geometry
(
det
)
cdef
featurelist_to_dataframe
(
crystfel
.
ImageFeatureList
*
flist
):
cdef
:
int
i
,
nfeat
=
crystfel
.
image_feature_count
(
flist
)
crystfel
.
imagefeature
*
feat
cnp
.
ndarray
[
cnp
.
npy_double
,
ndim
=
1
]
ss
,
fs
,
rx
,
ry
,
rz
,
it
ss
=
np
.
zeros
(
nfeat
,
np
.
double
)
fs
=
np
.
zeros
(
nfeat
,
np
.
double
)
rx
=
np
.
zeros
(
nfeat
,
np
.
double
)
ry
=
np
.
zeros
(
nfeat
,
np
.
double
)
rz
=
np
.
zeros
(
nfeat
,
np
.
double
)
it
=
np
.
zeros
(
nfeat
,
np
.
double
)
with
cython
.
boundscheck
(
False
),
cython
.
wraparound
(
False
):
for
i
in
range
(
nfeat
):
feat
=
crystfel
.
image_get_feature
(
flist
,
i
)
ss
[
i
]
=
feat
.
ss
fs
[
i
]
=
feat
.
fs
rx
[
i
]
=
feat
.
rx
ry
[
i
]
=
feat
.
ry
rz
[
i
]
=
feat
.
rz
it
[
i
]
=
feat
.
intensity
return
pd
.
DataFrame
({
'ss'
:
ss
,
'fs'
:
fs
,
'rx'
:
rx
,
'ry'
:
ry
,
'rz'
:
rz
,
'intensity'
:
it
,
})
def
find_peaks_single_panel
(
cnp
.
ndarray
[
cnp
.
npy_float
,
ndim
=
2
]
data
,
str
geom_file
):
cdef
:
crystfel
.
beam_params
beam
...
...
@@ -40,9 +70,4 @@ def find_peaks_single_panel(cnp.ndarray[cnp.npy_float, ndim=2] data, str geom_fi
)
print
(
"Done peak search"
)
npeaks
=
crystfel
.
image_feature_count
(
image
.
features
)
print
(
f
"Found
{
npeaks
}
peaks"
)
for
i
in
range
(
min
(
10
,
npeaks
)):
peak
=
crystfel
.
image_get_feature
(
image
.
features
,
i
)
print
(
f
"Peak
{
i
}
: (
{
peak
.
ss
}
,
{
peak
.
fs
}
)
\t
Intensity=
{
peak
.
intensity
}
"
)
return
featurelist_to_dataframe
(
image
.
features
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment