COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
rtc_util.py
1 
37 
38 import numpy as np
39 
40 
41 def create_interp_mat(dimx: int, dimy: int):
42  """TODO doc
43 
44  :parameters:
45 
46  dimx: (int) :
47 
48  dimy: (int) :
49  """
50  n = max(dimx, dimy)
51  tmp2, tmp1 = np.indices((n, n))
52  tmp1 = tmp1[:dimx, :dimy] - (dimx // 2)
53  tmp2 = tmp2[:dimx, :dimy] - (dimy // 2)
54 
55  tmp = np.zeros((tmp1.size, 6), np.int32)
56  tmp[:, 0] = (tmp1**2).flatten()
57  tmp[:, 1] = (tmp2**2).flatten()
58  tmp[:, 2] = (tmp1 * tmp2).flatten()
59  tmp[:, 3] = tmp1.flatten()
60  tmp[:, 4] = tmp2.flatten()
61  tmp[:, 5] = 1
62 
63  return np.dot(np.linalg.inv(np.dot(tmp.T, tmp)), tmp.T).T
64 
65 
66 def centroid_gain(E, F):
67  """ Returns the mean centroid gain
68 
69  :parameters:
70 
71  E : (np.array(dtype=np.float32)) : measurements from WFS
72 
73  F : (np.array(dtype=np.float32)) : geometric measurements
74 
75  :return:
76 
77  cgain : (float) : mean centroid gain between the sets of WFS measurements and geometric ones
78  """
79  if E.ndim == 1:
80  cgains = np.polyfit(E, F, 1)[0]
81  elif E.ndim == 2:
82  cgains = np.zeros(E.shape[1])
83  for k in range(E.shape[1]):
84  cgains[k] = np.polyfit(E[:, k], F[:, k], 1)[0]
85  cgains = np.mean(cgains)
86  else:
87  raise ValueError("E and F must 1D or 2D arrays")
88 
89  return cgains
shesha.util.rtc_util.create_interp_mat
def create_interp_mat(int dimx, int dimy)
TODO doc.
Definition: rtc_util.py:49
shesha.util.rtc_util.centroid_gain
def centroid_gain(E, F)
Returns the mean centroid gain.
Definition: rtc_util.py:78