Skip to content

Commit

Permalink
add error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Dalton committed Jul 19, 2024
1 parent dff3c28 commit a1e44a3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions reciprocalspaceship/io/crystfel.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ def calculate_average_unit_cell(self) -> gemmi.UnitCell:
with open(self.filename, "r") as f:
memfile = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
lines = regex.findall(memfile)
if len(lines) == 0:
raise ValueError(
f"No unit cell parameters were found in the header of {self.filename}"
)

cell = np.loadtxt(lines, usecols=[2, 3, 4, 6, 7, 8], dtype="float32").mean(0)
cell[:3] *= 10.0

Expand Down

0 comments on commit a1e44a3

Please sign in to comment.