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
6b1d2e45
Commit
6b1d2e45
authored
Jan 15, 2021
by
Thomas Kluyver
Browse files
First attempt at binding UnitCell struct
parent
df353ddf
Changes
2
Hide whitespace changes
Inline
Side-by-side
pycrystfel/bindings.pyx
View file @
6b1d2e45
...
...
@@ -115,3 +115,40 @@ cdef class Detector:
def
panel_names
(
self
):
return
[
self
.
_img
.
detgeom
.
panels
[
i
].
name
.
decode
(
'utf-8'
)
for
i
in
range
(
self
.
n_panels
)]
cdef
class
UnitCell
:
cdef
crystfel
.
UnitCell
*
_ptr
cdef
bint
ptr_owner
def
__cinit__
(
self
):
self
.
ptr_owner
=
False
def
__dealloc__
(
self
):
# De-allocate if not null and flag is set
if
self
.
_ptr
is
not
NULL
and
self
.
ptr_owner
is
True
:
crystfel
.
cell_free
(
self
.
_ptr
)
self
.
_ptr
=
NULL
@
staticmethod
cdef
UnitCell
from_ptr
(
crystfel
.
UnitCell
*
ptr
,
bint
owner
=
False
):
# Call to __new__ bypasses __init__ constructor
cdef
UnitCell
cell
=
UnitCell
.
__new__
(
UnitCell
)
cell
.
_ptr
=
ptr
cell
.
ptr_owner
=
True
return
cell
@
classmethod
def
from_parameters
(
cls
,
double
a
,
double
b
,
double
c
,
double
alpha
,
double
beta
,
double
gamma
):
cdef
crystfel
.
UnitCell
*
ptr
=
crystfel
.
cell_new_from_parameters
(
a
,
b
,
c
,
alpha
,
beta
,
gamma
,
)
return
UnitCell
.
from_ptr
(
ptr
,
owner
=
True
)
@
property
def
lengths
(
self
):
cdef
:
double
a
,
b
,
c
,
alpha
,
beta
,
gamma
crystfel
.
cell_get_parameters
(
self
.
_ptr
,
&
a
,
&
b
,
&
c
,
&
alpha
,
&
beta
,
&
gamma
)
return
np
.
array
([
a
,
b
,
c
])
pycrystfel/crystfel.pxd
View file @
6b1d2e45
...
...
@@ -120,3 +120,31 @@ cdef extern from "crystfel/peaks.h":
int
min_pix_count
,
int
max_pix_count
,
int
local_bg_radius
,
int
min_res
,
int
max_res
,
int
use_saturated
)
cdef
extern
from
"crystfel/cell.h"
:
cdef
struct
rvec
:
double
u
,
v
,
w
ctypedef
enum
LatticeType
:
L_TRICLINIC
,
L_MONOCLINIC
,
L_ORTHORHROMBIC
,
L_TETRAGONAL
,
L_RHOMBOHEDRAL
,
L_HEXAGONAL
,
L_CUBIC
,
ctypedef
struct
UnitCell
:
pass
# Opaque struct, used through functions
UnitCell
*
cell_new
()
UnitCell
*
cell_new_from_cell
(
const
UnitCell
*
orig
)
UnitCell
*
cell_new_from_parameters
(
double
a
,
double
b
,
double
c
,
double
alpha
,
double
beta
,
double
gamma
)
void
cell_free
(
UnitCell
*
cell
)
cell_set_parameters
(
UnitCell
*
cell
,
double
a
,
double
b
,
double
c
,
double
alpha
,
double
beta
,
double
gamma
)
int
cell_get_parameters
(
UnitCell
*
cell
,
double
*
a
,
double
*
b
,
double
*
c
,
double
*
alpha
,
double
*
beta
,
double
*
gamma
)
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