Commit 247e7017 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Check return value of cell_get_parameters, add angles property

parent fc9ac5e1
......@@ -7,3 +7,4 @@ from pycrystfel.bindings import UnitCell
cell = UnitCell.from_parameters(79e-10, 79e-10, 38e-10, np.pi/2, np.pi/2, np.pi/2)
print("Retrieved lengths:", cell.lengths)
print("Retrieved angles:", cell.angles)
......@@ -148,7 +148,14 @@ cdef class UnitCell:
@property
def lengths(self):
cdef:
double a, b, c, alpha, beta, gamma
crystfel.cell_get_parameters(self._ptr, &a, &b, &c, &alpha, &beta, &gamma)
cdef double a, b, c, alpha, beta, gamma
if crystfel.cell_get_parameters(self._ptr, &a, &b, &c, &alpha, &beta, &gamma):
raise Exception("Could not retrieve cell parameters")
return np.array([a, b, c])
@property
def angles(self):
cdef double a, b, c, alpha, beta, gamma
if crystfel.cell_get_parameters(self._ptr, &a, &b, &c, &alpha, &beta, &gamma):
raise Exception("Could not retrieve cell parameters")
return np.array([alpha, beta, gamma])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment