2 Created on Wed Oct 5 14:28:23 2016
9 import matplotlib.pyplot
as plt
12 from guardians
import gamora, drax
14 datapath =
"/home/fferreira/Data/"
15 fname_layers =
"roket_8m_12layers_gamma1.h5"
16 buferr_ref = drax.get_err(datapath + fname_layers)
17 f_layers = h5py.File(datapath + fname_layers)
18 nlayers = f_layers.attrs[
"_Param_atmos__nscreens"]
21 name =
"roket_8m_12layers"
22 for i
in range(nlayers):
23 fname_layer_i.append(name +
"_%d.h5" % (i))
26 for f
in fname_layer_i:
27 files.append(h5py.File(datapath + f))
29 print(
"--------------------------------------------")
30 print(
"file ", fname_layers,
" :")
31 print(
" nlayers : ", f_layers.attrs[
"_Param_atmos__nscreens"])
32 print(
" frac : ", f_layers.attrs[
"_Param_atmos__frac"])
33 print(
"--------------------------------------------")
35 nmodes = f_layers[
"P"][:].shape[0]
37 "tomography",
"bandwidth",
"non linearity",
"noise",
"filtered modes",
"aliasing"
39 Lambda_tar = f_layers.attrs[
"_Param_target__Lambda"][0]
40 fracs = f_layers.attrs[
"_Param_atmos__frac"]
41 alts = f_layers.attrs[
"_Param_atmos__alt"]
42 frac_per_layer = dict()
45 frac_per_layer[a] = fracs[i]
49 buferr_layers = drax.get_err(datapath + fname_layer_i[0]) * 0.
50 for k
in range(len(files)):
51 frac.append(frac_per_layer[files[k].attrs[
"_Param_atmos__alt"][0]])
52 buferr_layers += drax.get_err(datapath + fname_layer_i[k]) * np.sqrt(
53 frac_per_layer[files[k].attrs[
"_Param_atmos__alt"][0]])
55 C_layers = np.zeros((buferr_layers.shape[0], buferr_layers.shape[0]))
56 for k
in range(len(files)):
58 frac[k] * drax.get_covmat_contrib(datapath + fname_layer_i[k], contributors))
59 print(
"contributors : ", contributors)
62 err_layers = np.zeros((nmodes, 2))
64 err_layer_i = np.zeros((nmodes, 2 * nlayers))
66 err_layers[:, 0] = drax.variance(f_layers, contributors, method=
"Default")
67 err_layers[:, 1] = drax.variance(f_layers, contributors, method=
"Independence")
70 err_layer_i[:, l] = drax.variance(f, contributors, method=
"Default")
71 err_layer_i[:, l + 1] = drax.variance(f, contributors, method=
"Independence")
75 inderr = np.zeros(nmodes)
76 derr = np.zeros(nmodes)
77 for l
in range(nlayers):
78 inderr += frac[l] * err_layer_i[:, 2 * l + 1]
79 derr += frac[l] * err_layer_i[:, 2 * l]
81 otftel_ref, otf2_ref, psf_ref, gpu = gamora.psf_rec_Vii(datapath + fname_layers)
82 otftel_sum, otf2_sum, psf_sum, gpu = gamora.psf_rec_Vii(datapath + fname_layers,
88 plt.semilogy(err_layers[:, 1])
90 plt.legend([
"%d layers" % nlayers,
"Layers sum"])
92 plt.ylabel(
"Variance [mic^2]")
93 plt.title(
"Variance with independence assumption")
95 plt.plot(drax.cumulativeSR(err_layers[:, 1], Lambda_tar))
96 plt.plot(drax.cumulativeSR(inderr, Lambda_tar))
97 plt.legend([
"%d layers" % nlayers,
"Layers sum"])
100 plt.title(
"Resulting SR")
104 plt.semilogy(err_layers[:, 0])
106 plt.legend([
"%d layers" % nlayers,
"Layers sum"])
107 plt.xlabel(
"Modes #")
108 plt.ylabel(
"Variance [mic^2]")
109 plt.title(
"Variance with correlation")
111 plt.plot(drax.cumulativeSR(err_layers[:, 0], Lambda_tar))
112 plt.plot(drax.cumulativeSR(derr, Lambda_tar))
113 plt.legend([
"%d layers" % nlayers,
"Layers sum"])
114 plt.xlabel(
"Modes #")
116 plt.title(
"Resulting SR")
118 RASC = 180 / np.pi * 3600.
121 pixsize = Lambda_tar * 1e-6 / (psf_ref.shape[0] * 8. / 640) * RASC
122 x = (np.arange(psf_ref.shape[0]) - psf_ref.shape[0] / 2) * pixsize / (
123 Lambda_tar * 1e-6 / 8. * RASC)
124 font = {
'family':
'normal',
'weight':
'bold',
'size': 22}
126 matplotlib.rc(
'font', **font)
129 plt.semilogy(x, psf_ref[psf_ref.shape[0] / 2, :], color=
"blue")
130 plt.semilogy(x, psf_sum[psf_sum.shape[0] / 2, :], color=
"red")
131 plt.xlabel(
"Angle [units of lambda/D]")
132 plt.ylabel(
"Normalized intensity")
133 plt.legend([
"12-layers PSF",
"Sum of 12 layers PSF"])