A couple of final edits suggested in review

This commit is contained in:
Julian Stirling 2025-12-02 09:54:27 +00:00
parent 9b58f4d59e
commit 5017fea9d1
2 changed files with 4 additions and 2 deletions

View file

@ -585,7 +585,7 @@ class AutofocusThing(lt.Thing):
supplied by LabThings dependency injection supplied by LabThings dependency injection
:param stack_parameters: A StackParams object containing the required :param stack_parameters: A StackParams object containing the required
parameters to run a stack. parameters to run a stack.
:param save_on_failure: Whether to save an image even if the capture failed :param save_on_failure: Whether to save an image even if no focus was found.
:param check_turning_points: Whether to check the number of turning points in :param check_turning_points: Whether to check the number of turning points in
the sharpnesses of the images in the stack is exactly 1. (May fail with the sharpnesses of the images in the stack is exactly 1. (May fail with
thick samples) thick samples)
@ -876,11 +876,13 @@ def _get_peak_turning_point(sharpnesses: np.ndarray) -> float:
# Fit the peak # Fit the peak
x = range(len(sharpnesses)) x = range(len(sharpnesses))
coeffs, cov = np.polyfit(x, sharpnesses, deg=2, cov=True) coeffs, cov = np.polyfit(x, sharpnesses, deg=2, cov=True)
# a in the equation a*x^2 + bx + c
a = float(coeffs[0]) a = float(coeffs[0])
fit_func = np.poly1d(coeffs) fit_func = np.poly1d(coeffs)
# find the peaks's x-position # find the peaks's x-position
turning = float(fit_func.deriv().roots[0]) turning = float(fit_func.deriv().roots[0])
# sigma_a the standard error of a
sigma_a = float(np.sqrt(cov[0, 0])) sigma_a = float(np.sqrt(cov[0, 0]))
# Estimate the upper 95% confidence bound for the x^2 term # Estimate the upper 95% confidence bound for the x^2 term
ci_high = a + 2 * sigma_a ci_high = a + 2 * sigma_a

View file

@ -777,7 +777,7 @@ class StreamingPiCamera2(BaseCamera):
self.calibrate_lens_shading() self.calibrate_lens_shading()
for _i in range(3): for _i in range(3):
try: try:
time.sleep(1) time.sleep(self._sensor_info.long_pause)
self.set_background(portal) self.set_background(portal)
# Return if background is set # Return if background is set
return return