def main(): # Loading any data in the # phase space from the appropriate folder fname = "out_fil.h5" base = "/work/jiff26/jiff2611/PROJECTS/effective/Jobs/170731-Active_Diffusion/rotation_data/aspect_ratio_10.0/" density = [0.4] pa = [1.0] pp = [0.0] folders = [] for di in density: for pai in pa: for ppi in pp: folders.append(base + 'density_' + str(di) + '/pa_' + str(pai) + '/pp_' + str(ppi) + '/') # all functions here, iterate parameter set by set for folder in folders: fils, sim = read_data(folder, fname) traj(fils) plt.show() return
def main(): # Loading any data in the # phase space from the appropriate folder fname = "out_fil.h5" base = "/work/jiff26/jiff2611/PROJECTS/effective/Jobs/170731-Active_Diffusion/rotation_data/aspect_ratio_10.0/" density = [0.4] pa = [0.4, 0.6, 0.8, 1.0] pp = [0.0] folders = [] for di in density: for pai in pa: for ppi in pp: folders.append(base + 'density_' + str(di) + '/pa_' + str(pai) + '/pp_' + str(ppi) + '/') # all functions here, iterate parameter set by set for pai, folder in zip(pa, folders): fils, sim = read_data(folder, fname) for i, t in enumerate([0.3]): #traj_distance(fils,t=t) #traj_time(fils,t=t) sigma = 50 #traj(fils) traj_time_vel_corr(fils, t=0.3, sigma=50, pai=pai) traj_distance_vel_corr(fils, t=0.3, sigma=50) #traj(fils,t=t,sigma=sigma) #traj_distance(fils,t=t, sigma=sigma) #traj_time(fils,t=t, sigma=sigma) plt.show() return
def main(): # Loading any data in the # phase space from the appropriate folder fname="out_fil.h5" base ="/work/jiff26/jiff2611/PROJECTS/effective/Jobs/170731-Active_Diffusion/rotation_data/aspect_ratio_10.0/" density=[0.4]; pa=[1.0]; pp=[0.0]; folders=[] for di in density: for pai in pa: for ppi in pp: folders.append(base+'density_'+str(di)+'/pa_'+str(pai)+'/pp_'+str(ppi)+'/') # all functions here, iterate parameter set by set for folder in folders: fils, sim = read_data(folder, fname) data = fils.xi.transpose(2,1,0) # Adopt Guglielmo's convention here to avoid confusion pkl.dump(data, open('com.pkl','wb')) data = fils.ori.transpose(2,1,0) # Adopt Guglielmo's convention here to avoid confusion pkl.dump(data, open('ori.pkl','wb')) return
def disp(fname): base = "/work/jiff26/jiff2611/PROJECTS/effective/Jobs/170731-Active_Diffusion/rotation_data/aspect_ratio_10.0/" density = [0.4] pa = [1.0] pp = [0.0] folders = [] for di in density: for pai in pa: for ppi in pp: folders.append(base + 'density_' + str(di) + '/pa_' + str(pai) + '/pp_' + str(ppi) + '/') for folder in folders: cells, sim = read_data(folder, fname) rodids = [0, 10] f, (ax1, ax2) = plt.subplots(1, 2) for rodid in rodids: traj = cells.xi[5000:, :, rodid] print(traj.shape) disp = traj - traj[0] disp2 = np.sqrt(np.square(disp[:, 0]) + np.square(disp[:, 1])) ax1.plot(disp2) ax2.plot(traj[:, 0], traj[:, 1]) ax2.set_aspect('equal')
def main(): ### get the data folder parser = argparse.argumentparser() parser.add_argument("-sdfl", "--simdatafolder", \ help="folder containing the simulation data") parser.add_argument("-dfl", "--datafolder", \ help="folder containing analysis data") parser.add_argument("-sfl", "--savefolder", \ help="folder to save the resulting analysis data inside") parser.add_argument("-figfl", "--figfolder", \ help="folder to save the figures inside") parser.add_argument("-ti", "--inittime", nargs="?", const=10, \ type=int, help="initial time step") parser.add_argument("-tf", "--fintime", nargs="?", const=100, \ type=int, help="final timestep") parser.add_argument("-s","--savepdf", action="store_true", \ help="decide whether to save in pdf or not") args = parser.parse_args() ### read the data and general information from the folder beads, sim = read_write.read_data(args.simdatafolder) beads.calc_img_pos(sim.lx) rcut = 15. # size of the interrogation circle dcut = 0.1 # defect strength cut dcrit = 9. # clustering distance threshold criteria ncrit = 15 # clustering size threshold criteria for step in range(args.inittime, args.fintime): print 'step / last_step: ', step, args.fintime ### load the possible defect points sfilepath = args.datafolder + 'possible_defect_pts_cpp_' + str( step) + '.h5' possible_defect_pts = read_write.load_h5_data(sfilepath) ### cluster the possible defect points and plot the cluster xcm, ycm = cluster_analysis(possible_defect_pts, dcrit, ncrit, sim, step, \ beads.xi[step, 0, :], beads.xi[step, 1, :], beads.cid) ### for each of the defect points found by clustering # calculate the defect strength and plot each point defect_pts = find_defects.recompute_defects(\ xcm, ycm, beads, sim, rcut, dcut, step, args.figfolder) ### save the ultimate defect points sfilepath = args.savefolder + 'defect_pts_' + str(step) + '.txt' read_write.save_data(defect_pts, sfilepath) return
def disp(fname): base = "/work/jiff26/jiff2611/PROJECTS/effective/Jobs/170731-Active_Diffusion/rotation_data/aspect_ratio_10.0/" density = [0.4] pa = [1.0] pp = [0.0] folders = [] for di in density: for pai in pa: for ppi in pp: folders.append(base + 'density_' + str(di) + '/pa_' + str(pai) + '/pp_' + str(ppi) + '/') for folder in folders: rodids = [0] f, (ax1, ax2, ax3) = plt.subplots(3, 1) for rodid in rodids: cells, sim = read_data(folder, fname) traj = cells.xi[5000:, :, rodid] print(traj.shape) disp = traj - traj[0] disp2 = np.sqrt(np.square(disp[:, 0]) + np.square(disp[:, 1])) ax3.plot(traj[:1000, 0], traj[:1000, 1], c='b') ax3.plot(traj[1000:2000, 0], traj[1000:2000, 1], c='y') ax3.plot(traj[2000:3000, 0], traj[2000:3000, 1], c='g') ax3.plot(traj[3000:4000, 0], traj[3000:4000, 1], c='r') ax3.plot(traj[4000:5000, 0], traj[4000:5000, 1], c='k') ax3.set_aspect('equal') lag = 100 thresh = 10 slope = disp2[:-lag] - disp2[lag:] ax1.plot(np.abs(slope)) #ax2.plot(np.abs(slope)) ax2.plot(np.abs(slope) > thresh) plotter = slope plotter[np.abs(slope) > thresh] = 1 plotter[np.abs(slope) < thresh] = 0
def gug(fname): base = "/work/jiff26/jiff2611/PROJECTS/effective/Jobs/170731-Active_Diffusion/rotation_data/aspect_ratio_10.0/" density = [0.4] pa = [1.0] pp = [0.0] folders = [] for di in density: for pai in pa: for ppi in pp: folders.append(base + 'density_' + str(di) + '/pa_' + str(pai) + '/pp_' + str(ppi) + '/') for folder in folders: cells, sim = read_data(folder, fname) traj = cells.xi[:, :, :50] fp = open('./gug.pkl', 'wb') pkl.dump(traj, fp) fp.close()
def vacf(fname): base = "/work/jiff26/jiff2611/PROJECTS/effective/Jobs/170731-Active_Diffusion/rotation_data/aspect_ratio_10.0/" density = [0.4] pa = [1.0] pp = [0.0] folders = [] for di in density: for pai in pa: for ppi in pp: folders.append(base + 'density_' + str(di) + '/pa_' + str(pai) + '/pp_' + str(ppi) + '/') lag = 1 plotter0 = np.zeros((50, 2)) plotter1 = np.zeros((50, 2)) for fi, folder in enumerate(folders): cells, sim = read_data(folder, fname) lags_v = [int(l) for l in np.logspace(0, np.log10(len(cells.xi)), 100)] plotter = np.zeros((len(lags_v), 2)) traj = cells.xi[:, :, :] v = traj[:-lag] - traj[lag:] for i, lagv in enumerate(lags_v): v_corr = np.sum(v[:-lagv] * v[lagv:], axis=1) plotter[i, 0] = lagv if len(v_corr) > 0: plotter[i, 1] = v_corr.mean() else: plotter[i, 1] = 0 x, y = lags_v, plotter[:, 1] plt.loglog(x, y)
def levy(fname): base = "/work/jiff26/jiff2611/PROJECTS/effective/Jobs/170731-Active_Diffusion/rotation_data/aspect_ratio_10.0/" density = [0.4] pa = [0.2, 1.0] pp = [0.0] powerlaw = lambda x, amp, index: amp * (x**index) folders = [] for di in density: for pai in pa: for ppi in pp: folders.append(base + 'density_' + str(di) + '/pa_' + str(pai) + '/pp_' + str(ppi) + '/') for folder in folders: rodids = [153] #lags = (10, 100, 500) lags = (100, ) long_time = 10 for lag in lags: for rodid in rodids: cells, sim = read_data(folder, fname) traj = cells.xi[5000:, :, :] dr = traj[:-lag] - traj[lag:] disps = np.sqrt(np.square(dr[:, 0]) + np.square(dr[:, 1])) hist, be = np.histogram(disps / 10, bins=100, normed=True) bw = be[1] - be[0] bc = be[1:] - bw / 2 popt, pcov = curve_fit(powerlaw, bc[long_time:], hist[long_time:]) plt.loglog(bc, hist) plt.loglog(bc[long_time:], powerlaw(bc[long_time:], *popt), c='k') print(*popt)
if sent[hyphen_index - 1] != " ": answer += " " answer += sent[hyphen_index] + " " else: answer += sent[hyphen_index] start = hyphen_index + 1 answer += sent[start:] return answer if __name__ == "__main__": model = build_model( configs.morpho_tagger.UD2_0.morpho_ru_syntagrus_pymorphy_lemmatize, download=True) ud_model = udModel.load(ud_model_path) sents, answers = read_data(train_path) symbols = sorted(set(a for sent in sents for a in sent)) # with open("dump/symbols.out", "w", encoding="utf8") as fout: # fout.write("\n".join(symbols)) # sys.exit() sents = [sanitize(sent) for sent in sents] # print("Tagging...") # tokenized_data = tokenizer.process("\n\n".join(sents)) # data = parse_ud_output(tokenized_data) # source = [[elem[1] for elem in sent] for sent in data] # tagged_data = call_model(model, sents, batch_size=64) if tokenize: tokenized_data, for_tagging = "", [] tokenizer = Pipeline(ud_model, "tokenize", Pipeline.NONE, Pipeline.NONE, "conllu") for start in range(0, len(sents), 40):
def prepare_data(train_file, parse_file, max_sents=-1, **kwargs): (source, answers) = read_data(train_file, max_sents=max_sents) sents = read_parse_file(parse_file, max_sents=max_sents, parse=False) return _prepare_data(source, sents, answers, **kwargs)