COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
script_dminit.py
1 # -*- coding: utf-8 -*-
2 """
3 Created on Wed Nov 9 14:03:29 2016
4 
5 @author: sdurand
6 """
7 
8 # import min
9 import sys
10 import os
11 sys.path.insert(0, os.environ["SHESHA_ROOT"] + "/widgets/")
12 import carmaWrap as ch
13 import shesha as ao
14 
15 print("TEST SHESHA_dm\n")
16 
17 # read param file :
18 param_file = sys.argv[1]
19 if (param_file.split('.')[-1] == b"py"):
20  filename = param_file.split('/')[-1]
21  param_path = param_file.split(filename)[0]
22  sys.path.insert(0, param_path)
23  exec("import %s as config" % filename.split(".py")[0])
24 else:
25  raise ValueError("Parameter file extension must be .py or .h5")
26 
27 print("param_file is", param_file)
28 
29 #initialisation:
30 # context : gpu 0
31 gpudevice = 0
32 c = ch.carmaWrap_context(gpudevice)
33 
34 
35 # fonction for init dm and geometry
36 def initSimuDM(config):
37 
38  # init geom
39  print("->geom")
40  ao.Param_geom.geom_init(config.p_geom, config.p_tel, config.p_geom.pupdiam,
41  config.p_geom.apod) #apod = apodizer
42  # init dm
43  print("->dm")
44  dms = ao.dm_init_standalone(config.p_dms, config.p_geom, config.p_tel.diam,
45  config.p_tel.cobs)
46 
47  # Print DM information
48  print("====================")
49  print("init done")
50  print("====================")
51  print("objects initialzed on GPU:")
52  print("--------------------------------------------------------")
53 
54  print(dms)
55 
56  return dms
57 
58 
59 # use init function
60 dms = initSimuDM(config) # Init Simu
script_dminit.initSimuDM
def initSimuDM(config)
Definition: script_dminit.py:36