38 x = (-1.0)**(np.arange(width) - width//2)
39 y = (-1.0)**(np.arange(height) - height//2)
42 probe[15:19, 6:10] = np.outer(x, y)
43 probe[15:19, 6:10] = np.outer(y, x)
44 if direction ==
'right':
55 x = (-1.0)**(np.arange(width) - width//2)
56 y = (-1.0)**(np.arange(height) - height//2)
59 probe[8:12, 15:19] = np.outer(y, x)
60 probe[8:12, 15:19] = np.outer(x, y)
61 probe = np.sign(probe)
74def wait_for_state(client, indi_property, value, wait_time=1, tolerance=None):
76 while not (client[indi_property] == value):
80 while not abs(client[indi_property] - value) < tolerance:
84def calibrate_indi_device(client, device_name, device_property, delta_pertubation, camera, measurement_function, num_stack=50, do_wait=False):
85 client.get_properties(
'{:s}'.format(device_name))
87 property_current =
'{:s}.{:s}.current'.format(device_name, device_property)
88 property_target =
'{:s}.{:s}.target'.format(device_name, device_property)
89 current_position = client[property_current]
90 print(
"Probe to {:f} +- {:f}".format(current_position, delta_pertubation))
93 client[property_target] = current_position + s * delta_pertubation
95 wait_for_state(client, property_current, current_position + s * delta_pertubation, tolerance=0.1 * delta_pertubation)
101 im = camera.grab_stack(num_stack)
103 measurement = measurement_function(im)
104 slope += s * measurement / (2 * delta_pertubation)
106 client[property_target] = current_position
108 wait_for_state(client, property_current, current_position, tolerance=0.1 * delta_pertubation)
calibrate_indi_device(client, device_name, device_property, delta_pertubation, camera, measurement_function, num_stack=50, do_wait=False)