COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
closed_loop.py
1 #!/usr/bin/env python
2 
3 
39 """
40 script test to simulate a closed loop
41 
42 Usage:
43  closed_loop.py <parameters_filename> [options]
44 
45 with 'parameters_filename' the path to the parameters file
46 
47 Options:
48  -h --help Show this help message and exit
49  --brahma Distribute data with brahma
50  --bench For a timed call
51  -i --interactive keep the script interactive
52  -d --devices devices Specify the devices
53  -n --niter niter Number of iterations
54  -g --generic Use generic controller
55  -f --fast Compute PSF only during monitoring
56 """
57 from shesha.config import ParamConfig
58 from docopt import docopt
59 
60 if __name__ == "__main__":
61  arguments = docopt(__doc__)
62 
63  param_file = arguments["<parameters_filename>"]
64  compute_tar_psf = not arguments["--fast"]
65 
66  config = ParamConfig(param_file)
67 
68  # Get parameters from file
69  if arguments["--bench"]:
70  from shesha.supervisor.benchSupervisor import BenchSupervisor as Supervisor
71  elif arguments["--brahma"]:
72  from shesha.supervisor.canapassSupervisor import CanapassSupervisor as Supervisor
73  else:
74  from shesha.supervisor.compassSupervisor import CompassSupervisor as Supervisor
75 
76  if arguments["--devices"]:
77  config.p_loop.set_devices([
78  int(device) for device in arguments["--devices"].split(",")
79  ])
80 
81  if arguments["--generic"]:
82  config.p_controllers[0].set_type("generic")
83  print("Using GENERIC controller...")
84 
85  if arguments["--niter"]:
86  config.p_loop.set_niter(int(arguments["--niter"]))
87 
88  supervisor = Supervisor(config)
89 
90  supervisor.loop(supervisor.config.p_loop.niter, compute_tar_psf=compute_tar_psf)
91 
92  if arguments["--interactive"]:
93  from shesha.util.ipython_embed import embed
94  from os.path import basename
95  embed(basename(__file__), locals())
Shesha parameters configuration class.
Definition: pconfig.py:51
void split(std::vector< std::string > &tokens, const std::string &text, char sep)
Definition: carma_utils.h:71
Parameter classes for COMPASS.
Initialization and execution of a Bench supervisor.
Initialization and execution of a CANAPASS supervisor.
Initialization and execution of a COMPASS supervisor.