1 from importlib
import reload
3 from astropy.io
import fits
19 TAO_SETTINGS={
"SCHED":
"dmdas",
22 "TILE_SIZE":TILE_SIZE,
29 """Checks that variable are initialized
33 if (
not isinstance(TAO_SETTINGS[
"SCHED"], str)):
34 print(
"you must select a scheduler (dmda,dmdas,dmdar...)\n\tex: TAO_SETTINGS[\"SCHED\"]=\"dmdas\"")
37 print(
"you must select a scheduler (dmda,dmdas,dmdar...)\n\tex: TAO_SETTINGS[\"SCHED\"]=\"dmdas\"")
40 if(
not isinstance(TAO_SETTINGS[
"GPU_IDS"], str)):
41 print(
"you must define the GPUs to use as a string \n\tex:TAO_SETTINGS[\"GPU_IDS\"]=\"1,2\"")
44 print(
"you must define the GPUs to use as a string \n\tex:TAO_SETTINGS[\"GPU_IDS\"]=\"1,2\"")
47 if(
not isinstance(TAO_SETTINGS[
"INPUT_PATH"], str)):
48 print(
"you must define the location of the system parameters \n\tex: TAO_SETTINGS[\"INPUT_PATH\"]=\"~/workspace/compass/params\"")
51 print(
"you must define the location of the system parameters \n\tex: TAO_SETTINGS[\"INPUTPATH\"]=\"~/workspace/compass/params\"")
54 if(
not isinstance(TAO_SETTINGS[
"TAO_PATH"], str)):
55 print(
"you must define the location of the tao executables \n\tex: TAO_SETTINGS[\"TAO_PATH\"]=\"~/workspace/tao/install/bin\"")
58 print(
"you must define the location of the tao executables \n\tex: TAO_SETTINGS[\"TAOPATH\"]=\"~/workspace/tao/install/bin\"")
61 TAO_SETTINGS[
"STARPU_FLAGS"]
63 TAO_SETTINGS[
"STARPU_FLAGS"]=
""
68 def init(sup, mod, *,wfs="all", dm_use_tt=False, n_filt=None):
69 """ Set up the compass loop
71 set the interaction matrix, loop gain and write parameter files for TAO
75 sup : (CompassSupervisor) : current supervisor
77 mod : (module) : AO mode requested (among: ltao , mcao)
80 wfs : (str) : (optional), default "all" wfs used by tao ( among "all", "lgs", "ngs")
82 dm_use_tt : (bool) :(optional), default False using a TT DM
84 n_filt : (int) : (optional), default None number of meta interaction matrix singular values filtered out
88 sup.rtc._rtc.d_control[0].set_polc(
True)
91 mod.init(TAO_SETTINGS, sup, dm_use_tt=dm_use_tt, wfs=wfs)
93 mod.init(TAO_SETTINGS, sup, dm_use_tt=dm_use_tt, wfs=wfs, n_filt=n_filt)
96 """ Compute the TAO reconstructor for a given AO mode
99 mod : (module) : AO mode requested (among: ltao , mcao)
101 return mod.reconstructor(TAO_SETTINGS)
104 def run(sup, mod, *, n_iter=1000, initialisation=True, reset=True, wfs="all",
105 dm_use_tt=False, n_filt=None):
106 """ Computes a tao reconstructor and run a compass loop with it
109 sup : (CompassSupervisor) : current supervisor
111 mod : (module) : AO mode requested (among: ltao , mcao)
114 n_iter : (int) : (optional), default 1000 number of iteration of the ao loop
116 initialisation : (bool) : (optional), default True initialise tao (include comptation of meta matrices of interaction/command)
118 reset : (bool) : (optional), default True reset the supervisor before the loop
120 wfs : (str) : (optional), default "all" wfs used by tao ( among "all", "lgs", "ngs")
122 dm_use_tt : (bool) :(optional), default False using a TT DM
124 n_filt : (int) : (optional), default None number of meta interaction matrix singular values filtered out
129 sup.rtc._rtc.d_control[0].set_polc(
True)
132 if(np.abs(np.array(sup.rtc._rtc.d_control[0].d_imat)).max()==0):
134 sup.rtc._rtc.d_control[0].set_imat(sup.config.p_controllers[0]._imat)
136 sup.rtc._rtc.set_gain(0,sup.config.p_controllers[0].gain)
139 init(sup, mod, wfs=wfs, dm_use_tt=dm_use_tt, n_filt=n_filt)
143 cmat_shape=sup.rtc.get_command_matrix(0).shape
144 if(M.shape[0] != cmat_shape[0]
or M.shape[1] != cmat_shape[1]):
145 print(
"ToR shape is not valid:\n\twaiting for:",cmat_shape,
"\n\tgot :",M.shape)
147 sup.rtc.set_command_matrix(0,M)
Python package for AO operations on COMPASS simulation.
def reconstructor(mod)
Compute the TAO reconstructor for a given AO mode.
def check()
Checks that variable are initialized.
def init(sup, mod, *wfs="all", dm_use_tt=False, n_filt=None)
Set up the compass loop.
def run(sup, mod, *n_iter=1000, initialisation=True, reset=True, wfs="all", dm_use_tt=False, n_filt=None)
Computes a tao reconstructor and run a compass loop with it.