Commit 2f63ee67 authored by bliss administrator's avatar bliss administrator
Browse files

radiation_damage PositionManager exception tracking

parent ab6025fb
......@@ -136,8 +136,14 @@ class PositionManager:
for i, pos in enumerate(self._positions[pname]):
if pos == (px,py):
return i
raise ValueError(f"cannot find the position {(px, py)} in '{pname}' positions")
try:
# to check (rounding / positioning precision)
tups = np.array(self._positions[pname])
i = np.argmin(np.linalg.norm(np.abs(np.array(tups)-np.array(px, py)),axis=1))-1
return i
except:
raise ValueError(f"cannot find the position {(px, py)} in '{pname}' positions")
def set_index(self, pname, index):
nbr_pos = len(self._positions[pname])
if index>=0 and index<nbr_pos:
......@@ -262,11 +268,21 @@ class PositionManager:
def remove_pattern(self, pname):
if self._last_index.get(pname) is not None:
#self._last_index[pname] = None #removes key:value in redis (del works too)
del self._last_index[pname]
del self._positions[pname]
del self._counts[pname]
del self._exposure_times[pname]
#self._last_index[pname] = None #removes key:value in redis (del works too)
try:
del self._last_index[pname] # because we know it is there
self._positions.pop(pname, None)
self._counts.pop(pname, None)
self._exposure_times.pop(pname, None)
except:
print('pattern \'{:s}\' does not exist! Nothing removed.'.format(pname))
def remove_all_patterns(self):
all_pattern_names = self.get_pattern_list()
for pname in all_pattern_names:
print('removing pattern \'{:s}\''.format(pname))
self.remove_pattern(pname)
def has_pattern(self, pname):
if self._last_index.get(pname) is not None:
......
Supports Markdown
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