COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
shesha.util.influ_util Namespace Reference

Computation of the influence functions used by the DM. More...

Functions

def besel_orth (m, n, phi, r)
 TODO docstring. More...
 
def bessel_influence (xx, yy, type_i=PatternType.SQUARE)
 TODO docstring. More...
 
def makeRigaut (float pitch, float coupling, x=None, y=None)
 Compute 'Rigaut-like' influence function. More...
 
def makeRadialSchwartz (float pitch, float coupling, x=None, y=None)
 Compute radial Schwartz influence function. More...
 
def makeSquareSchwartz (float pitch, float coupling, x=None, y=None)
 Compute Square Schwartz influence function. More...
 
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. More...
 
def makeGaussian (float pitch, float coupling, x=None, y=None)
 Compute Gaussian influence function. More...
 
def makeBessel (float pitch, float coupling, np.ndarray x=None, np.ndarray y=None, bytes patternType=PatternType.SQUARE)
 Compute Bessel influence function. More...
 

Detailed Description

Computation of the influence functions used by the DM.

Author
COMPASS Team https://github.com/ANR-COMPASS
Version
5.0.0
Date
2020/05/18

This file is part of COMPASS https://anr-compass.github.io/compass/

Copyright (C) 2011-2019 COMPASS Team https://github.com/ANR-COMPASS All rights reserved. Distributed under GNU - LGPL

COMPASS is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

COMPASS: End-to-end AO simulation tool using GPU acceleration The COMPASS platform was designed to meet the need of high-performance for the simulation of AO systems.

The final product includes a software package for simulating all the critical subcomponents of AO, particularly in the context of the ELT and a real-time core based on several control approaches, with performances consistent with its integration into an instrument. Taking advantage of the specific hardware architecture of the GPU, the COMPASS tool allows to achieve adequate execution speeds to conduct large simulation campaigns called to the ELT.

The COMPASS platform can be used to carry a wide variety of simulations to both testspecific components of AO of the E-ELT (such as wavefront analysis device with a pyramid or elongated Laser star), and various systems configurations such as multi-conjugate AO.

COMPASS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with COMPASS. If not, see https://www.gnu.org/licenses/lgpl-3.0.txt.

Function Documentation

◆ besel_orth()

def shesha.util.influ_util.besel_orth (   m,
  n,
  phi,
  r 
)

TODO docstring.

   :parameters:

       m:

       n:

       phi:

       r:

   :return:
B

Definition at line 60 of file influ_util.py.

60  """
61  # fonction de bessel fourier orthogonale (BFOFS)
62  if (m == 0):
63  B = sp.jn(0, sp.jn_zeros(0, n)[n - 1] * r)
64  elif (m > 0):
65  B = sp.jn(m, sp.jn_zeros(m, n)[n - 1] * r) * np.sin(m * phi)
66  else:
67  B = sp.jn(np.abs(m),
68  sp.jn_zeros(np.abs(m), n)[n - 1] * r) * np.cos(np.abs(m) * phi)
69  return B
70 
71 
Here is the caller graph for this function:

◆ bessel_influence()

def shesha.util.influ_util.bessel_influence (   xx,
  yy,
  type_i = PatternType.SQUARE 
)

TODO docstring.

   :parameters:

       xx:

       yy:

type_i (optional)

:return:

    influ

Definition at line 86 of file influ_util.py.

86  """
87 
88  # base sur l article numerical model of the influence function of deformable mirrors based on bessel Fourier orthogonal functions
89  # corespond a 3.2pitch
90 
91  influ = np.zeros(xx.shape, dtype=np.float32)
92 
93  # construction des tableaux :
94 
95  # construction des coordonnée cartesienne
96  # x = np.arange(size)-middle # -->
97  # y = (np.arange(size)-middle)*-1 # -->
98  #xx,yy = np.meshgrid(x,y)
99  # passage en coordonnée polaire
100  r = np.sqrt(xx**2 + yy**2)
101  phi = np.arctan2(yy, xx) # +(np.pi/8.) #petite correction de rotation
102 
103  # coef for square IF
104  a0 = [
105  0.3826, 0.5207, 0.2841, -0.0146, -0.1103, -0.0818, -0.0141, 0.0123, 0.0196,
106  0.0037
107  ]
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]
110 
111  # search coef for hexagonal IF (m =0, 6, -6 --> 28 term)
112  # a0 ->10
113  # a6 ->9
114  # am6 ->9
115 
116  if type_i == PatternType.HEXA or type_i == PatternType.HEXAM4:
117  sym = 6
118 
119  else:
120  sym = 4
121 
122  # calcul pour m = 0
123  for i in range(len(a0)):
124  btemp = (a0[i] * besel_orth(0, i + 1, phi, r))
125 
126  influ = influ + btemp
127  #print("fin cas m=",0)
128 
129  # calcul pour m=6
130  for i in range(len(a)):
131  influ = influ + (a[i] * besel_orth(sym, i + 1, phi, r))
132  #print("fin cas m=",sym)
133 
134  # calcul pour m=-6
135  for i in range(len(am)):
136  influ = influ + (am[i] * besel_orth(-sym, i + 1, phi, r))
137  #print("fin cas m=",-sym)
138 
139  return influ
140 
141 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeBessel()

def shesha.util.influ_util.makeBessel ( float  pitch,
float  coupling,
np.ndarray   x = None,
np.ndarray   y = None,
bytes   patternType = PatternType.SQUARE 
)

Compute Bessel influence function.

:parameters:

pitch (float) : pitch of the DM expressed in pixels

coupling (float) : coupling of the actuators

x indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

:return:

influ (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

Definition at line 352 of file influ_util.py.

352  influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator
353  """
354  smallsize = int(np.ceil(pitch * 3.2))
355 
356  if (x is None or y is None):
357  return smallsize
358  else:
359  # size_pitch = smallsize/np.float32(p_dm._pitch) # size of influence fonction in pitch
360  # xdg= np.linspace(-1*(size_pitch/3.2),size_pitch/3.2, smallsize,dtype=np.float32)
361  # x = np.tile(xdg, (smallsize,1))
362  # y = x.T
363  influ_u = bessel_influence(x / (1.6 * pitch), y / (1.6 * pitch), patternType)
364  influ_u = influ_u * (influ_u >= 0)
365  return influ_u
Here is the call graph for this function:

◆ makeBlacknutt()

def shesha.util.influ_util.makeBlacknutt ( float  pitch,
float  coupling,
  x = None,
  y = None 
)

Compute Blacknutt influence function Attention, ici on ne peut pas choisir la valeur de coupling.

La variable a ete laissee dans le code juste pour compatibilité avec les autres fonctions, mais elle n'est pas utilisee.

:parameters:

pitch (float): pitch of the DM expressed in pixels

coupling (float) : coupling of the actuators

x indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

:return:

influ (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

Definition at line 274 of file influ_util.py.

274  """
275  smallsize = int(np.ceil(4 * pitch + 1))
276  if (x is None or y is None):
277  return smallsize
278  else:
279  cg = smallsize // 2
280  xx = x / float(cg)
281  yy = y / float(cg)
282  a = np.array([0.355768, 0.487396, 0.144232, 0.012604], dtype=np.float32)
283  ok = np.where((np.abs(xx) < 1) * (np.abs(yy) < 1))
284  sc = np.zeros(xx.shape)
285  sc[ok] = (a[0] + a[1] * np.cos(np.pi * xx[ok]) +
286  a[2] * np.cos(2 * np.pi * xx[ok]) + a[3] * np.cos(3 * np.pi * xx[ok])) *\
287  (a[0] + a[1] * np.cos(np.pi * yy[ok]) +
288  a[2] * np.cos(2 * np.pi * yy[ok]) + a[3] * np.cos(3 * np.pi * yy[ok]))
289 
290  return sc
291 
292 

◆ makeGaussian()

def shesha.util.influ_util.makeGaussian ( float  pitch,
float  coupling,
  x = None,
  y = None 
)

Compute Gaussian influence function.

Coupling parameter is not taken into account

:parameters:

pitch (float) : pitch of the DM expressed in pixels

coupling (float) : coupling of the actuators

x indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

:return:

influ (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

Definition at line 309 of file influ_util.py.

309  """
310  irc = 1.16136 + 2.97422 * coupling + \
311  (-13.2381) * coupling**2 + 20.4395 * coupling**3
312  tmp_c = 1.0 / np.abs(irc)
313 
314  smallsize = int(np.ceil(2 * irc * pitch + 10))
315  if (smallsize % 2 != 0):
316  smallsize += 1
317 
318  if (x is None or y is None):
319  return smallsize
320  else:
321  sig = pitch / np.sqrt(-2 * np.log(coupling))
322  gauss = np.exp(-0.5 * ((x / sig)**2 + (y / sig)**2))
323  # gauss /= gauss.max()
324  # xdg = np.linspace(-1, 1, smallsize, dtype=np.float32)
325  # x = np.tile(xdg, (smallsize, 1))
326  # y = x.T
327  # sig = 0.8
328  # gauss = 1 / np.cos(np.exp(-(x**2 / sig + y**2 / sig))**2)
329  # # Force value at zero on array limits
330  # gauss -= gauss[gauss.shape[0] // 2].min()
331  # gauss[gauss < 0.] = 0
332  # gauss /= gauss.max() # Normalize
333  return gauss
334 
335 

◆ makeRadialSchwartz()

def shesha.util.influ_util.makeRadialSchwartz ( float  pitch,
float  coupling,
  x = None,
  y = None 
)

Compute radial Schwartz influence function.

:parameters:

pitch (float) : pitch of the DM expressed in pixels

coupling (float) : coupling of the actuators

x indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

:return:

influ (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

Definition at line 205 of file influ_util.py.

205  """
206  k = 6 # order of the Schwartz function
207  #
208  a = pitch / np.sqrt(k / (np.log(coupling) - k) + 1.)
209  smallsize = int(2 * np.ceil(a) + 2)
210  if (x is None or y is None):
211  return smallsize
212  else:
213  r = (x * x + y * y) / (a * a)
214  ok = np.where(r < 1)
215  sc = np.zeros(r.shape)
216  sc[ok] = np.exp((k / (r[ok] - 1.0)) + k)
217  #influ[:,:,:] = sc[:,:,None] * np.ones(ntotact)[None,None,:]
218  return sc
219 
220 

◆ makeRigaut()

def shesha.util.influ_util.makeRigaut ( float  pitch,
float  coupling,
  x = None,
  y = None 
)

Compute 'Rigaut-like' influence function.

:parameters:

pitch (float) : pitch of the DM expressed in pixels

coupling (float) : coupling of the actuators

x indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

:return:

influ (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

Definition at line 158 of file influ_util.py.

158  """
159  irc = 1.16136 + 2.97422 * coupling + \
160  (-13.2381) * coupling**2 + 20.4395 * coupling**3
161 
162  p1 = 4.49469 + (7.25509 + (-32.1948 + 17.9493 * coupling) * coupling) * coupling
163  p2 = 2.49456 + (-0.65952 + (8.78886 - 6.23701 * coupling) * coupling) * coupling
164 
165  tmp_c = 1.0 / np.abs(irc)
166  ccc = (coupling - 1. + tmp_c**p1) / (np.log(tmp_c) * tmp_c**p2)
167 
168  smallsize = int(np.ceil(2 * irc * pitch + 10))
169  if (smallsize % 2 != 0):
170  smallsize += 1
171  # clip
172  if (x is None or y is None):
173  return smallsize
174  else:
175  # normalized coordiantes in local ref frame
176  x = np.abs(x) / (irc * pitch)
177  y = np.abs(y) / (irc * pitch)
178 
179  x[x < 1e-8] = 1e-8
180  x[x > 2] = 2.
181  y[y < 1e-8] = 1e-8
182  y[y > 2] = 2.
183  tmp = (1. - x**p1 + ccc * np.log(x) * x**p2) * \
184  (1. - y**p1 + ccc * np.log(y) * y**p2)
185  tmp = tmp * (x <= 1.0) * (y <= 1.0)
186  return tmp
187 
188 

◆ makeSquareSchwartz()

def shesha.util.influ_util.makeSquareSchwartz ( float  pitch,
float  coupling,
  x = None,
  y = None 
)

Compute Square Schwartz influence function.

:parameters:

pitch (float) : pitch of the DM expressed in pixels

coupling (float) : coupling of the actuators

x indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

:return:

influ (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

Definition at line 237 of file influ_util.py.

237  """
238  k = 6 # order of the Schwartz function
239  #
240  a = pitch / np.sqrt(k / (np.log(coupling) - k) + 1.)
241 
242  if (x is None or y is None):
243  smallsize = int(2 * np.ceil(a) + 2)
244  return smallsize
245  else:
246  xx = (x / a)**2
247  yy = (y / a)**2
248  ok = np.where((xx < 1) * (yy < 1))
249  sc = np.zeros(xx.shape)
250  sc[ok] = np.exp((k / (xx[ok] - 1)) + k) * \
251  np.exp((k / (yy[ok] - 1)) + k)
252  return sc
253 
254