COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
valid_roket_files.py
1 import h5py
2 import numpy as np
3 import glob
4 
5 
6 def validfile(filename):
7  f = h5py.File(filename)
8  if (list(f.attrs.keys()).count("target.Lambda")):
9  Lambda = f.attrs["target.Lambda"][0]
10  else:
11  Lambda = 1.65
12  nactus = f["noise"][:].shape[0]
13  niter = f["noise"][:].shape[1]
14  P = f["P"][:]
15  nmodes = P.shape[0]
16  data = np.zeros((nmodes, niter))
17  error_list = [
18  "noise", "aliasing", "tomography", "filtered modes", "bandwidth",
19  "non linearity"
20  ]
21 
22  for i in error_list:
23  data += np.dot(P, f[i][:])
24 
25  data = np.var(data, axis=1)
26  data = np.sum(data)
27  data = np.exp(-data * (2 * np.pi / Lambda)**2)
28  data *= np.exp(-f["fitting"].value)
29 
30  SR2 = f["SR2"].value
31  SR = f["SR"].value
32 
33  if (np.abs(data - SR) < 0.05 or np.abs(data - SR2) < 0.05):
34  f.attrs["validity"] = True
35 
36 
37 datapath = "/home/fferreira/Data/correlation/"
38 filenames = glob.glob(datapath + "roket_8m*.h5")
39 l = len(filenames)
40 ind = 0
41 for f in filenames:
42  validfile(f)
43  ind += 1
44  print(" reading : %d/%d\r" % (ind, l), end=' ')
45 print("read")
valid_roket_files.validfile
def validfile(filename)
Definition: valid_roket_files.py:6