COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
scripts/script_roket.py
1 """script for ROKET
2 
3 Usage:
4  script_roket.py <parameters_filename> [options]
5 
6 with 'parameters_filename' the path to the parameters file
7 
8 Options:
9  -h --help Show this help message and exit
10  -s, --savefile savename Set the name of the ouput h5 file that will be saved in $DATA_GUARDIAN
11  -d, --diam diam Set the telescope diameter [m]
12  --niter niter Set the number of iterations
13  --nssp nxsub Set the number of subapertures of the WFS. Number of actuators is actualized to nxsub+1
14  --npix npix Set the number of pixels per subap.
15  --pixsize pixsize Set the WFS pixel size [arcsec]
16  --nfilt nfilt Set the number of filtered modes
17  --winddir winddir Set the wind direction
18  --windspeed windspeed Set the wind speed
19  --noise noise Set the noise value
20  --gain gain Set the loop gain
21  --devices devices Specify the devices to use
22  --gamma gamma Set the value of the centroid gain
23  --seeds seeds Set the turbulence seeds
24  --alt alt Set the layer altitude
25 
26 Usage with Ipython: ipython [-i] script_roket.py -- [options]
27 """
28 
29 from docopt import docopt
30 
31 import sys
32 import os
33 from guardian.roket import Roket
34 
35 arguments = docopt(__doc__)
36 param_file = arguments["<parameters_filename>"]
37 print(arguments)
38 # Get parameters from file
39 if arguments["--savefile"]:
40  savefile = arguments["--savefile"]
41 else:
42  savefile = "roket_default.h5"
43 
44 gamma = 1.0
45 if arguments["--gamma"]:
46  gamma = 1 / float(arguments["--gamma"])
47 roket = Roket(param_file, gamma=gamma)
48 
49 if arguments["--diam"]:
50  roket.config.p_tel.set_diam(float(arguments["--diam"]))
51 if arguments["--niter"]:
52  roket.config.p_loop.set_niter(int(arguments["--niter"]))
53 if arguments["--nssp"]:
54  roket.config.p_wfss[0].set_nxsub(int(arguments["--nssp"]))
55  roket.config.p_dms[0].set_nact(int(arguments["--nssp"]) + 1)
56 if arguments["--npix"]:
57  roket.config.p_wfss[0].set_npix(int(arguments["--npix"]))
58 if arguments["--pixsize"]:
59  roket.config.p_wfss[0].set_pixsize(float(arguments["--pixsize"]))
60 if arguments["--nfilt"]:
61  roket.config.p_controllers[0].set_maxcond(float(arguments["--nfilt"]))
62 if arguments["--windspeed"]:
63  roket.config.p_atmos.set_windspeed([float(arguments["--windspeed"])])
64 if arguments["--winddir"]:
65  roket.config.p_atmos.set_winddir([float(arguments["--winddir"])])
66 if arguments["--noise"]:
67  roket.config.p_wfss[0].set_noise(float(arguments["--noise"]))
68 if arguments["--gain"]:
69  roket.config.p_controllers[0].set_gain(float(arguments["--gain"]))
70 if arguments["--seeds"]:
71  roket.config.p_atmos.set_seeds([int(arguments["--seeds"])])
72 if arguments["--alt"]:
73  roket.config.p_atmos.set_alt([float(arguments["--alt"])])
74 
75 if arguments["--devices"]:
76  devices = []
77  for k in range(len(arguments["--devices"])):
78  devices.append(int(arguments["--devices"][k]))
79  roket.config.p_loop.set_devices(devices)
80 
81 roket.init_config()
82 roket.loop()
83 roket.save_in_hdf5(savefile)