39 import scipy.special
as sp
63 B = sp.jn(0, sp.jn_zeros(0, n)[n - 1] * r)
65 B = sp.jn(m, sp.jn_zeros(m, n)[n - 1] * r) * np.sin(m * phi)
68 sp.jn_zeros(np.abs(m), n)[n - 1] * r) * np.cos(np.abs(m) * phi)
91 influ = np.zeros(xx.shape, dtype=np.float32)
100 r = np.sqrt(xx**2 + yy**2)
101 phi = np.arctan2(yy, xx)
105 0.3826, 0.5207, 0.2841, -0.0146, -0.1103, -0.0818, -0.0141, 0.0123, 0.0196,
108 am = [-0.0454, -0.1114, -0.1125, -0.0397, 0.0146, 0.0217, 0.0085, -0.0012, -0.0040]
109 a = [-0.0002, -0.0004, -0.0001, 0.0004, 0.0005, 0.0003, 0.0001, 0, 0]
116 if type_i == PatternType.HEXA
or type_i == PatternType.HEXAM4:
123 for i
in range(len(a0)):
124 btemp = (a0[i] *
besel_orth(0, i + 1, phi, r))
126 influ = influ + btemp
130 for i
in range(len(a)):
131 influ = influ + (a[i] *
besel_orth(sym, i + 1, phi, r))
135 for i
in range(len(am)):
136 influ = influ + (am[i] *
besel_orth(-sym, i + 1, phi, r))
142 def makeRigaut(pitch: float, coupling: float, x=
None, y=
None):
143 """ Compute 'Rigaut-like' influence function.
145 The arguments <pitch> and <x>, <y> must be in the same unit.
146 This unit shall be [pixels] if one expects that the returned value
147 <smallsize> is also in [pixels].
151 pitch: (float) : pitch of the DM expressed in pixels
153 coupling: (float) : coupling of the actuators
155 x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function
157 y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function
161 influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator
163 irc = 1.16136 + 2.97422 * coupling + \
164 (-13.2381) * coupling**2 + 20.4395 * coupling**3
166 p1 = 4.49469 + (7.25509 + (-32.1948 + 17.9493 * coupling) * coupling) * coupling
167 p2 = 2.49456 + (-0.65952 + (8.78886 - 6.23701 * coupling) * coupling) * coupling
169 tmp_c = 1.0 / np.abs(irc)
170 ccc = (coupling - 1. + tmp_c**p1) / (np.log(tmp_c) * tmp_c**p2)
172 smallsize = int(np.ceil(2 * irc * pitch + 10))
173 if (smallsize % 2 != 0):
176 if (x
is None or y
is None):
180 x = np.abs(x) / (irc * pitch)
181 y = np.abs(y) / (irc * pitch)
187 tmp = (1. - x**p1 + ccc * np.log(x) * x**p2) * \
188 (1. - y**p1 + ccc * np.log(y) * y**p2)
189 tmp = tmp * (x <= 1.0) * (y <= 1.0)
194 """ Compute radial Schwartz influence function
198 pitch: (float) : pitch of the DM expressed in pixels
200 coupling: (float) : coupling of the actuators
202 x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function
204 y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function
208 influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator
212 a = pitch / np.sqrt(k / (np.log(coupling) - k) + 1.)
213 smallsize = int(2 * np.ceil(a) + 2)
214 if (x
is None or y
is None):
217 r = (x * x + y * y) / (a * a)
219 sc = np.zeros(r.shape)
220 sc[ok] = np.exp((k / (r[ok] - 1.0)) + k)
226 """ Compute Square Schwartz influence function
230 pitch: (float) : pitch of the DM expressed in pixels
232 coupling: (float) : coupling of the actuators
234 x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function
236 y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function
240 influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator
244 a = pitch / np.sqrt(k / (np.log(coupling) - k) + 1.)
246 if (x
is None or y
is None):
247 smallsize = int(2 * np.ceil(a) + 2)
252 ok = np.where((xx < 1) * (yy < 1))
253 sc = np.zeros(xx.shape)
254 sc[ok] = np.exp((k / (xx[ok] - 1)) + k) * \
255 np.exp((k / (yy[ok] - 1)) + k)
259 def makeBlacknutt(pitch: float, coupling: float, x=
None, y=
None):
260 """ Compute Blacknutt influence function
261 Attention, ici on ne peut pas choisir la valeur de coupling.
262 La variable a ete laissee dans le code juste pour compatibilité avec les
263 autres fonctions, mais elle n'est pas utilisee.
267 pitch: (float): pitch of the DM expressed in pixels
269 coupling: (float) : coupling of the actuators
271 x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function
273 y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function
277 influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator
279 smallsize = int(np.ceil(4 * pitch + 1))
280 if (x
is None or y
is None):
286 a = np.array([0.355768, 0.487396, 0.144232, 0.012604], dtype=np.float32)
287 ok = np.where((np.abs(xx) < 1) * (np.abs(yy) < 1))
288 sc = np.zeros(xx.shape)
289 sc[ok] = (a[0] + a[1] * np.cos(np.pi * xx[ok]) +
290 a[2] * np.cos(2 * np.pi * xx[ok]) + a[3] * np.cos(3 * np.pi * xx[ok])) *\
291 (a[0] + a[1] * np.cos(np.pi * yy[ok]) +
292 a[2] * np.cos(2 * np.pi * yy[ok]) + a[3] * np.cos(3 * np.pi * yy[ok]))
297 def makeGaussian(pitch: float, coupling: float, x=
None, y=
None):
298 """ Compute Gaussian influence function. Coupling parameter is not taken into account
302 pitch: (float) : pitch of the DM expressed in pixels
304 coupling: (float) : coupling of the actuators
306 x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function
308 y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function
312 influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator
314 irc = 1.16136 + 2.97422 * coupling + \
315 (-13.2381) * coupling**2 + 20.4395 * coupling**3
316 tmp_c = 1.0 / np.abs(irc)
318 smallsize = int(np.ceil(2 * irc * pitch + 10))
319 if (smallsize % 2 != 0):
322 if (x
is None or y
is None):
325 sig = pitch / np.sqrt(-2 * np.log(coupling))
326 gauss = np.exp(-0.5 * ((x / sig)**2 + (y / sig)**2))
340 def makeBessel(pitch: float, coupling: float, x: np.ndarray =
None, y: np.ndarray =
None,
341 patternType: bytes = PatternType.SQUARE):
342 """ Compute Bessel influence function
346 pitch: (float) : pitch of the DM expressed in pixels
348 coupling: (float) : coupling of the actuators
350 x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function
352 y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function
356 influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator
358 smallsize = int(np.ceil(pitch * 3.2))
360 if (x
is None or y
is None):
367 influ_u =
bessel_influence(x / (1.6 * pitch), y / (1.6 * pitch), patternType)
368 influ_u = influ_u * (influ_u >= 0)
Numerical constants for shesha and config enumerations for safe-typing.
def makeRadialSchwartz(float pitch, float coupling, x=None, y=None)
Compute radial Schwartz influence function.
def makeBlacknutt(float pitch, float coupling, x=None, y=None)
Compute Blacknutt influence function Attention, ici on ne peut pas choisir la valeur de coupling.
def makeRigaut(float pitch, float coupling, x=None, y=None)
Compute 'Rigaut-like' influence function.
def besel_orth(m, n, phi, r)
TODO docstring.
def makeBessel(float pitch, float coupling, np.ndarray x=None, np.ndarray y=None, bytes patternType=PatternType.SQUARE)
Compute Bessel influence function.
def bessel_influence(xx, yy, type_i=PatternType.SQUARE)
TODO docstring.
def makeSquareSchwartz(float pitch, float coupling, x=None, y=None)
Compute Square Schwartz influence function.
def makeGaussian(float pitch, float coupling, x=None, y=None)
Compute Gaussian influence function.