def test_scanFocus_correctness_01(self): const = 0 mot = VirtualMotorTest(self.image) cam = VirtualCameraTest(mot, const=const, mode="scan") pos = (-11, 11, 2) focus = af.Focus(motor_pv=mot, camera_pv=cam, positions=pos, method="scan") res = focus.focus() assert res == -1 + const or res == 1 + const
def test_hillclimbFocus_correctness_01(self): const = 0 mot = VirtualMotorTest(self.image) mot.mv(10) cam = VirtualCameraTest(mot, const=const, mode="hillclimb") focus = af.Focus(motor_pv=mot, camera_pv=cam, positions=None, method="hillclimb") res = focus.focus() # As it stands the result simply doesnt equal 0. This doesnt mean it isnt # working so first find out what res ends up as then go from there. assert res == 0
# const = 2 # mot = VirtualMotorTest(image) # cam = VirtualCameraTest(mot, const=const) # pos = (-19, 19, 2) # focus = af.Focus(motor_pv=mot, camera_pv=cam, positions=pos, method="scan") # # ipdb.set_trace() # a = focus.focus() # pprint(focus._focuses) const = 0 mot = VirtualMotorTest(image) mot.mv(.01) cam = VirtualCameraTest(mot, const=const, mode="hillclimb") focus = af.Focus(motor_pv=mot, camera_pv=cam, positions=None, method="hillclimb") #import ipdb; ipdb.set_trace() methods = [ "Powell", "CG", "L-BFGS-B", "trust-ncg", "dogleg", "COBYLA", "TNC" "BFGS", "Nelder-Mead" ] methods_scalar = ["Brent", "Bounded", "Golden"] for method in methods: try: res = focus.focus(hc_method="brent") print(method, res.x) except: print("Failed for {0}".format(method))