Skip to content

Commit

Permalink
restricts returned optimal position to be within desired and physical…
Browse files Browse the repository at this point in the history
… range
  • Loading branch information
gadamc committed Feb 3, 2023
1 parent 42bb58a commit 378df7b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/qt3utils/datagenerators/piezoscanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def optimize_position(self, axis, center_position, width = 2, step_size = 0.25):
try:
coeff, var_matrix = scipy.optimize.curve_fit(gauss, axis_vals, data, p0=params)
optimal_position = coeff[1]
# ensure that the optimal position is within the scan range
optimal_position = np.max([min_val, optimal_position])
optimal_position = np.min([max_val, optimal_position])
except RuntimeError as e:
print(e)

Expand Down

0 comments on commit 378df7b

Please sign in to comment.