def find_positionlaser(self, c, Nz, start=0, end=1): #, a=5, Nz=None): instantV = [] tV = [] print(start, end) a = 5 c = cine.Cine(c) # for (start,end) in instant: if (True): C = [] print(start) for j in range(start, end - 1): print("image : " + str(j)) im = c.get_frame(j) im1 = c.get_frame(j + 1) mean1 = np.mean(im, axis=(0, 1)) mean2 = np.mean(im1, axis=(0, 1)) std1 = np.std(im, axis=(0, 1)) std2 = np.std(im1, axis=(0, 1)) C.append( np.mean((im - mean1) * (im1 - mean2), axis=(0, 1)) / (std1 * std2)) maximum = [] minimum = [] for i in range(a, len(C) - a): print("deuxième partie : " + str(i)) window = slice(i - a, i + a + 1) if np.argmax(C[window]) == a + 1: maximum.append(i + 1) #plt.plot(i+1-maximum[0],C[i+1],'rx') if len(maximum) > 1 and len(minimum) > 0: # get which way we are scanning if (minimum[-1] - maximum[-2]) <= Nz / 2: startV = maximum[-2] + start endV = maximum[-1] + start else: startV = maximum[-1] + start endV = maximum[-2] + start instantV.append((startV, endV)) tV.append(c.get_time((startV + endV) // 2)) if np.argmin(C[window]) == a + 1: if len(maximum) > 0: minimum.append(i + 1) #if (minimum[-1]-maximum[-1])<=Nz/2: # plt.plot(i+1-maximum[0],C[i+1],'bo') #else: # plt.plot(i+1-maximum[0],C[i+1],'k*') #do a mirror symetry #plt.plot(C[maximum[0]:maximum[-1]]) #plt.axis([0,150,0.65,1]) return (instantV, tV, C)
def get_volume(self, i, start=None, end=None): #adresse, adresse_s): c = cine.Cine(self.data.fichier) L, H = c.get_frame(0).shape if start == None and end == None: start, end = (self.m['instantV'][i][0], self.m['instantV'][i][1]) tV = self.m['tV'][i] Nz = np.abs(start - end) + 1 Vol = np.zeros((Nz, L, H)) print(start, end) frames = np.arange(start, end + 1, np.sign(end - start)) for j, frame in enumerate(frames): Vol[j, ...] = c.get_frame(frame) return Vol, (start, end), tV
def volume_2d(self, nb_im=None, nmin=5, dtmax=10): """ :returns: Objet Volume contenant dans le dictionnaire m, un "instant" """ Dic = {} cinefile = self.data.fichier c = cine.Cine(cinefile) Dic['fps'] = int(self.data.param.fps) Dic['dtmin'] = nmin * Dic['fps'] Dic['dtmax'] = dtmax if (nb_im == None): Dic['N'] = len(c) else: Dic['N'] = nb_im instant = self.find_timejumps(c, Dic) self.m['instant'] = instant self.m.update(Dic) return self
def volume(self, nb_im=None, nmin=5, dtmax=10, instant=None): """ :returns: Objet Volume avec dans le dictionnaire m, "instantV", "tV", "CV" """ Dic = {} cinefile = self.data.fichier c = cine.Cine(cinefile) if (type(self.data.param.fps) in [int, float]): Dic['fps'] = int(self.data.param.fps) elif (self.data.param.fps[len(self.data.param.fps) - 1] == "k"): Dic['fps'] = (int(self.data.param.fps.rsplit("k", 1)[0]) * 1000) #detecte les débuts et fin de Volumes #ft = 1./40000 #should be given directly by Data.param.ft Dic['dtmin'] = nmin * Dic[ 'fps'] #we look for jumps at least 10 times Dt Dic['dtmax'] = dtmax #value in second if (nb_im == None): Dic['N'] = len(c) else: Dic['N'] = nb_im if instant == None: instant = self.find_timejumps(c, Dic) Dic['f'] = int(self.data.param.flaser) Dic['Nz'] = Dic['fps'] // Dic['f'] #we should find the number of images using framerate/f, see data.param, need lea's package #(instantV,tV) = find_positionlaser(c,instant,Nz=Nz) (instantV, tV, CV) = self.analysis_multi_proc(cinefile, instant, Dic, Nz=Dic['Nz']) self.m['instantV'] = instantV self.m['tV'] = tV self.m['CV'] = CV return self
def volume( self, folder, ): if sys.platform == 'win32': base = 'F:' if sys.platform == 'linux': base = '/media/stephane/DATA' if sys.platform == 'darwin': base = '/Volumes' date = '20181106' folder = base + '/Experimental_data/Turbulence3d/' + date + '/' l = glob.glob(folder + '*.cine') for i, name in enumerate(l): print(str(i) + ' : ' + os.path.basename(name)) #s = input() s = 3 try: i = int(s) except: print("cannot be converted to an integer") cinefile = l[i] c = cine.Cine(cinefile) #detecte les débuts et fin de Volumes ft = 1. / 40000 #should be given directly by Data.param.ft dtmin = 10 * ft #we look for jumps at least 10 times Dt dtmax = 10 #value in second instant = find_timejumps(c, dtmin, dtmax) N = len(c) Nz = 25 #we should find the number of images using framerate/f, see data.param, need lea's package #(instantV,tV) = find_positionlaser(c,instant,Nz=Nz) (instantV, tV) = analysis_multi_proc(c, instant)
base = '/media/stephane/DATA' if sys.platform == 'darwin': base = '/Volumes' date = '20181106' folder = base + '/Experimental_data/Turbulence3d/' + date + '/' l = glob.glob(folder + '*.cine') for i, name in enumerate(l): print(str(i) + ' : ' + os.path.basename(name)) #s = input() s = 3 try: i = int(s) except: print("cannot be converted to an integer") cinefile = l[i] c = cine.Cine(cinefile) #detecte les débuts et fin de Volumes ft = 1. / 40000 #should be given directly by Data.param.ft dtmin = 10 * ft #we look for jumps at least 10 times Dt dtmax = 10 #value in second instant = find_timejumps(c, dtmin, dtmax) N = len(c) Nz = 25 #we should find the number of images using framerate/f, see data.param, need lea's package #(instantV,tV) = find_positionlaser(c,instant,Nz=Nz) (instantV, tV) = analysis_multi_proc(c, instant)