COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
ltao.py
1 import os
2 import numpy as np
3 from astropy.io import fits
4 
5 from shesha.ao import imats
6 from shesha.ao import cmats
7 
8 from shesha.util.tao import writer
9 
10 def init(tao_settings,sup,*,n_filt=10, wfs="all", dm_use_tt=False):
11  """Initialize the LTAO mode
12 
13  compute meta matrix of interaction / command and write parameter files
14 
15  Args:
16  tao_settings : (dict) : tao settings variables
17 
18  sup : CompassSupervisor : compass supervisor
19 
20  Kwargs:
21  wfs : (str) : (optional), default "all" wfs used by tao ( among "all", "lgs", "ngs")
22 
23  n_filt : (int) : number of Imat eigenvalues to filter out
24 
25  dm_use_tt : (bool) : (optional), default False using a TT DM
26  """
27 
28  #compute meta imat
29  meta_D = imats.get_metaD(sup,0,0)
30  #get svd of (D.T*D)
31  SVD = cmats.svd_for_cmat(meta_D)
32  #plt.plot(SVD[1])
33  meta_Dx = cmats.get_cmat(meta_D,nfilt=n_filt,svd=SVD)
34 
35  #write MOAO pipeline inputs
36  data_path = tao_settings["INPUT_PATH"]
37  lgs_filter_cst=0.1
38  if(dm_use_tt):
39  lgs_filter_cst=0.
40  writer.generate_files(sup, path=data_path, single_file=True,
41  dm_use_tt=dm_use_tt, wfs=wfs, lgs_filter_cst=lgs_filter_cst)
42  writer.write_meta_Dx(meta_Dx,nTS=sup.config.NTS,path=data_path)
43 
44 
45 def reconstructor(tao_settings,*,apply_log="./log"):
46  """Initialize the LTAO mode
47 
48  compute meta matrix of interaction / command and write parameter files
49 
50  Args:
51  tao_settings : (dict) : tao settings variables
52 
53  Kwargs:
54  apply_log : (str) : tao log file name
55 
56  Returns:
57  tor : () : tomographic reconstructor
58  """
59 
60  flags = tao_settings["STARPU_FLAGS"]
61  tao_path = tao_settings["TAO_PATH"]
62  data_path = tao_settings["INPUT_PATH"]
63  gpus = tao_settings["GPU_IDS"]
64  tile_size = str( tao_settings["TILE_SIZE"])
65  apply_cmd = flags + " " + tao_path + "/ltao_reconstructor --sys_path=" \
66  + data_path + " --atm_path=" + data_path + " --ncores=1 --gpuIds=" \
67  + gpus + " --ts=" + tile_size + " --sync=1 --warmup=0 >" + apply_log \
68  +" 2>&1"
69  os.system(apply_cmd)
70  return fits.open("M_ltao_0.fits")[0].data.T
Python package for AO operations on COMPASS simulation.
Definition: ao/__init__.py:1
def reconstructor(tao_settings, *apply_log="./log")
Initialize the LTAO mode.
Definition: ltao.py:58
def init(tao_settings, sup, *n_filt=10, wfs="all", dm_use_tt=False)
Initialize the LTAO mode.
Definition: ltao.py:26