Skip to content
Snippets Groups Projects
Commit 42c528bf authored by Valerio Mariani's avatar Valerio Mariani
Browse files

Fixed bug in load_crystfel_geometry

parent 3818901c
No related branches found
No related tags found
No related merge requests found
...@@ -91,7 +91,17 @@ def _set_dim_structure_entry(key, value, panel): ...@@ -91,7 +91,17 @@ def _set_dim_structure_entry(key, value, panel):
else: else:
dim = [] dim = []
dim_index = int(key[3]) try:
dim_index = int(key[3])
except IndexError:
raise RuntimeError(
"'dim' must be followed by a number, e.g. 'dim0')"
)
except ValueError:
raise RuntimeError(
"Invalid dimension number {}".format(key[3])
)
if dim_index > len(dim) - 1: if dim_index > len(dim) - 1:
for _ in range(len(dim), dim_index + 1): for _ in range(len(dim), dim_index + 1):
dim.append(None) dim.append(None)
...@@ -593,8 +603,8 @@ def load_crystfel_geometry(filename): ...@@ -593,8 +603,8 @@ def load_crystfel_geometry(filename):
panel['name'] panel['name']
) )
) )
elif entry == 'ss': elif entry == 'ss':
found_ss += 1
if found_ss != 1: if found_ss != 1:
raise RuntimeError( raise RuntimeError(
"Exactly one slow scan dim coordinate is needed " "Exactly one slow scan dim coordinate is needed "
...@@ -603,10 +613,8 @@ def load_crystfel_geometry(filename): ...@@ -603,10 +613,8 @@ def load_crystfel_geometry(filename):
panel['name'] panel['name']
) )
) )
else:
found_ss += 1
elif entry == 'fs': elif entry == 'fs':
found_fs += 1
if found_fs != 1: if found_fs != 1:
raise RuntimeError( raise RuntimeError(
"Exactly one fast scan dim coordinate is needed " "Exactly one fast scan dim coordinate is needed "
...@@ -615,10 +623,8 @@ def load_crystfel_geometry(filename): ...@@ -615,10 +623,8 @@ def load_crystfel_geometry(filename):
panel['name'] panel['name']
) )
) )
else:
found_fs += 1
elif entry == '%': elif entry == '%':
found_placeholder += 1
if found_placeholder != 1: if found_placeholder != 1:
raise RuntimeError( raise RuntimeError(
"Only one placeholder dim coordinate is allowed." "Only one placeholder dim coordinate is allowed."
...@@ -628,8 +634,6 @@ def load_crystfel_geometry(filename): ...@@ -628,8 +634,6 @@ def load_crystfel_geometry(filename):
panel['name'] panel['name']
) )
) )
else:
found_placeholder += 1
if dim_length is None: if dim_length is None:
dim_length = len(panel['dim_structure']) dim_length = len(panel['dim_structure'])
...@@ -746,6 +750,6 @@ def load_crystfel_geometry(filename): ...@@ -746,6 +750,6 @@ def load_crystfel_geometry(filename):
# The code of this function is synced with the code of the function # The code of this function is synced with the code of the function
# 'get_detector_geometry_2' in CrystFEL at commit # 'get_detector_geometry_2' in CrystFEL at commit
# 92f2ebfd11d0ccd91ab299f95ffb2d99a457643d # dabbe320ff1d54d8ad24954b1e391f1b58ec0866
return detector return detector
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment