COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
mcao.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 
11 def init(tao_settings ,sup,*,n_filt=0,wfs="all",dm_use_tt=False):
12  """Initialize the MOAO mode
13 
14  compute meta matrix of interaction / command and write parameter files
15 
16  Args:
17  tao_settings : (dict) : tao settings variables
18 
19  sup : (CompassSupervisor) : compass supervisor
20 
21  Kwargs
22  n_filt : (int) : number of Imat eigenvalues to filter out
23 
24  wfs : (str) : (optional), default "all" wfs used by tao ( among "all", "lgs", "ngs")
25 
26  dm_use_tt : (bool) :(optional), default False DM compensating TT
27  """
28 
29 
30  #compute meta imat
31  meta_D = imats.get_metaD(sup)
32  #get svd of (D.T*D)
33  SVD = cmats.svd_for_cmat(meta_D)
34  #plt.plot(SVD[1])
35  meta_Dx = cmats.get_cmat(meta_D, nfilt=n_filt, svd=SVD)
36 
37  #write MOAO pipeline inputs
38  data_path = tao_settings["INPUT_PATH"]
39 
40  lgs_filter_cst = 0.1
41  if(dm_use_tt):
42  lgs_filter_cst = 0.
43  writer.generate_files(sup, path=data_path, single_file=True,
44  dm_use_tt=dm_use_tt,wfs=wfs, lgs_filter_cst=lgs_filter_cst)
45  writer.write_meta_Dx(meta_Dx, nTS=sup.config.NTS, path=data_path)
46 
47 
48 def reconstructor(tao_settings, *,apply_log="./log"):
49  """Initialize the LTAO mode
50 
51  compute meta matrix of interaction / command and write parameter files
52 
53  Args:
54  tao_settings : (dict) : tao settings variables
55 
56  Kwargs:
57  apply_log : (str) : (optional), default "./log" tao log file name
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 
66  apply_cmd=flags+" "+tao_path+"/mcao_reconstructor --sys_path="+data_path+" --atm_path="+data_path+" --ncores=1 --gpuIds="+gpus+" --ts="+tile_size+" --sync=1 --warmup=0 >"+apply_log+" 2>&1"
67 
68  os.system(apply_cmd)
69  return fits.open("./M_mcao.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: mcao.py:58
def init(tao_settings, sup, *n_filt=0, wfs="all", dm_use_tt=False)
Initialize the MOAO mode.
Definition: mcao.py:27