COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
common/dm.py
1 import numpy as np
2 import json
3 
4 def get_actu_pos_pixel(dm):
5  """return the coordinates in pixel of a given DM actuators
6 
7  Args:
8  dm : (Param_dm) : Dm to get the actuators position from
9 
10  Returns:
11  xpos : (np.ndarray[ndim=1, dtype=np.float32]) : actuators positions along axis x
12 
13  ypos : (np.ndarray[ndim=1, dtype=np.float32]) : actuators positions along axis y
14  """
15 
16  return dm._xpos+1, dm._ypos+1
17 
18 
19 def get_actu_pos_meter(sup, dm_id):
20  """return the coordinates in meters of a given DM actuators
21 
22  Args:
23  sup : (compasSSupervisor) : supervisor
24 
25  dm_id : (int) : index of the DM
26 
27  Returns:
28  xpos : (np.ndarray[ndim=1, dtype=np.float32]) : actuators positions along axis x
29 
30  ypos : (np.ndarray[ndim=1, dtype=np.float32]) : actuators positions along axis y
31  """
32 
33  config = sup.config
34  dm=config.p_dms[dm_id]
35  geom = config.p_geom
36  valid_X = ( dm._xpos - geom.get_cent() ) * geom.get_pixsize()
37  valid_Y = ( dm._ypos - geom.get_cent() ) * geom.get_pixsize()
38  return valid_X, valid_Y
39 
40 
41 def dm_to_json(dm, geom):
42  """return a json description of a dm
43 
44  Args:
45  dm : (Param_dm) : dm to represent as json
46  """
47  dm_json = {
48  "n_actu" : dm.get_nact(),
49  "h" : dm.get_alt(),
50  "coupling" : dm.get_coupling(),
51  "shift_x" : dm.get_dx() * geom.get_pixsize(),
52  "shift_y" : dm.get_dy() * geom.get_pixsize(),
53  "theta" : dm.get_theta()
54  }
55  return dm_json
def get_actu_pos_meter(sup, dm_id)
return the coordinates in meters of a given DM actuators
Definition: common/dm.py:31
def dm_to_json(dm, geom)
return a json description of a dm
Definition: common/dm.py:46
def get_actu_pos_pixel(dm)
return the coordinates in pixel of a given DM actuators
Definition: common/dm.py:14