1 from tqdm
import trange
2 import matplotlib.pyplot
as plt
6 def testNoise(noise=0.9, niter=100, close_loop=True):
8 s1 = np.zeros(((niter, int(wao.sim.config.p_controller0.nvalid * 2))))
9 s2 = np.zeros(((niter, int(wao.sim.config.p_controller0.nvalid * 2))))
10 sub1 = np.zeros(((niter, int(wao.sim.config.p_controller0.nvalid))))
11 sub2 = np.zeros(((niter, int(wao.sim.config.p_controller0.nvalid))))
12 dimim = wao.sim.wfs.get_pyrimg(0).shape[0]
13 dimimHR = wao.sim.wfs.get_pyrimghr(0).shape[0]
14 dimscreen = wao.sim.atm.get_screen(0).shape[0]
15 im1 = np.zeros(((niter, dimim, dimim)))
16 im2 = np.zeros(((niter, dimim, dimim)))
19 screen1 = np.zeros(((niter, dimscreen, dimscreen)))
20 screen2 = np.zeros(((niter, dimscreen, dimscreen)))
22 wao.sim.rtc.set_open_loop(0, 1)
23 wao.sim.atm.set_seed(0, 1234)
24 wao.sim.atm.refresh_screen(0)
25 wao.sim.wfs.set_noise(0, noise)
26 wao.sim.dms.resetdm(b
"pzt", 0.)
27 wao.sim.dms.resetdm(b
"tt", 0.)
29 wao.sim.rtc.set_open_loop(0, 0)
32 for k
in trange(niter):
34 s1[k, :] = wao.sim.rtc.get_centroids(0)
35 sub1[k, :] = wao.sim.rtc.get_intensities(0)
37 im1[k, :, :] = wao.sim.wfs.get_pyrimg(0)
39 screen1[k, :, :] = wao.sim.atm.get_screen(0)
40 wao.sim.rtc.set_open_loop(0, 1)
41 wao.sim.atm.set_seed(0, 1234)
42 wao.sim.atm.refresh_screen(0)
43 wao.sim.wfs.set_noise(0, noise)
44 wao.sim.dms.resetdm(b
"pzt", 0.)
45 wao.sim.dms.resetdm(b
"tt", 0.)
47 wao.sim.rtc.set_open_loop(0, 0)
50 for k
in trange(niter):
52 s2[k, :] = wao.sim.rtc.get_centroids(0)
53 sub2[k, :] = wao.sim.rtc.get_intensities(0)
54 im2[k, :, :] = wao.sim.wfs.get_pyrimg(0)
55 screen2[k, :, :] = wao.sim.atm.get_screen(0)
58 screenErr = np.abs(screen2 - screen1).max() / screen1.max()
59 imagesErr = np.abs(im2 - im1).max() / im1.max()
60 subErr = np.abs(sub2 - sub1).max() / sub1.max()
63 slopesErr = np.abs(s2 - s1).max() / s1.max()
64 print(
"Screen Error =" + str(screenErr))
66 print(
"Images Error =" + str(imagesErr))
67 print(
"Slopes Error =" + str(slopesErr))
68 print(
"Subsum Error =" + str(subErr))
73 return screenErr, imagesErr, imagesHRErr, slopesErr, subErr
87 errscreen, imagesErr, imagesHRErr, slopesErr, subErr =
testNoise(0.5, 200,
True)
88 errscreenList.append(errscreen)
89 imagesErrList.append(imagesErr)
90 imagesHRErrList.append(imagesHRErr)
91 slopesErrList.append(slopesErr)
92 subErrList.append(subErr)
96 plt.plot(errscreenList)
97 plt.title(
"Screen Error")
101 plt.plot(imagesErrList)
102 plt.title(
"images Error")
106 plt.plot(slopesErrList)
107 plt.title(
"slopes Error")
111 plt.plot(imagesHRErrList)
112 plt.title(
"images HR Error")