def load_data(self, path, FileList=None, NameList=None): # nfiles = np.size(os.listdir(path)) if FileList is None: infile = glob(path + '*.plt') else: infile = FileList if NameList is None: # ext_name = os.path.splitext(infile) df = p2p.ReadAllINCAResults(path, FileName=infile) elif NameList == 'h5': df = pd.read_hdf(infile) else: df = p2p.ReadINCAResults(path, VarList=NameList, FileName=infile) df = df.drop_duplicates(keep='last') grouped = df.groupby(['x', 'y', 'z']) df = grouped.mean().reset_index() self._data_field = df
def load_3data(self, path, FileList=None, NameList=None): # nfiles = np.size(os.listdir(path)) if FileList is None: infile = glob(path + '*.plt') else: infile = FileList if NameList is None: df = p2p.ReadAllINCAResults(path, FileName=infile, SpanAve=None) elif NameList == 'h5': if np.size(FileList) == 1: df = pd.read_hdf(infile) else: num = np.size(FileList) df = pd.concat([pd.read_hdf(FileList[i]) for i in range(num)]) df.reset_index() else: df = p2p.ReadINCAResults(path, VarList=NameList, FileName=infile, SpanAve=False) # df = df.drop_duplicates(keep='last') self._data_field = df
'v', 'w', 'p', 'rho', 'vorticity_1', 'vorticity_2', 'vorticity_3', 'L2-criterion', 'T', ] start = time.time() volume = [(-100.0, 80.0), (0.0, 40.0), (-8, 8)] dxyz = [0.25, 0.125, 0.125] df0, stime = p2p.ReadINCAResults(pathin, VarList, SubZone=volume) xval = np.arange(volume[0][0], volume[0][1] + dxyz[0], dxyz[0]) yval = np.arange(volume[1][0], volume[1][1] + dxyz[1], dxyz[1]) zval = np.arange(volume[2][0], volume[2][1] + dxyz[2], dxyz[2]) df1 = df0[df0.x.isin(xval)] df2 = df1[df1.y.isin(yval)] df3 = df2[df2.z.isin(zval)] stime = np.around(stime, decimals=2) filename = "TP_data_" + str(stime) df3.to_hdf(pathout + filename + ".h5", 'w', format='fixed') # %% save to tecplot format # in front of the step df1 = df3.query("x<=0.0 & y>=0.0") p2p.frame2tec3d(df1, pathout, filename + 'A', zname=1, stime=time)
# %%############################################################################ """ Streamwise wavenumber and growth rate by spanwise-averaged data """ # %% extract probe data along spanwise VarList = [ 'x', 'y', 'z', 'u', 'v', 'w', 'p', 'vorticity_1', 'vorticity_2', 'vorticity_3', 'Q-criterion', 'L2-criterion', '|grad(rho)|', 'T', '|gradp|' ] path1 = path + "TP_data_01386484/" equ = ['{|gradp|}=sqrt(ddx({p})**2+ddy({p})**2+ddz({p})**2)'] p2p.ReadINCAResults(path1, VarList, SavePath=path, OutFile="SpanwiseFlow", Equ=equ) # %% extract probe data along spanwise pathSW = path + 'Spanwise/' x0 = np.arange(-40.0, 0.0 + 0.5, 0.5) y0 = 0.001953125 # 0.00390625 # fm = pd.read_hdf(pathSW + "SpanwiseFlow.h5") for j in range(np.size(x0)): filenm = pathSW + 'spanwise_' + str(x0[j]) + '.dat' var = fm.loc[(fm['x'] == x0[j]) & (fm['y'] == y0), ['z', 'u', 'p']].values df = pd.DataFrame(data=var, columns=['z', 'u', 'p']) df.to_csv(filenm, sep=' ', index=False, float_format='%1.8e') base = pd.read_csv(pathL + 'baseline_' + yloc + '.dat', sep=' ',
'{vx} = ddx({v})', '{vy} = ddy({v})', '{vz} = ddz({v})', '{wx} = ddx({w})', '{wy} = ddy({w})', '{wz} = ddz({w})', '{rhox} = ddx({rho})', '{rhoy} = ddy({rho})', '{rhoz} = ddz({rho})', '{px} = ddx({p})', '{py} = ddy({p})', '{pz} = ddz({p})', ] FoldPath = "/media/weibo/VID2/BFS_M1.7TS1/bubble/" # TS/Slice/TP_2D_S_10/" OutFolder = "/media/weibo/VID2/BFS_M1.7TS1/" # TS/Slice/TP_2D_S_10/" subzone = [(-40.0, 30.0), (-3.0, 2.0)] # subzone = [(-10.0, 30.0), (-3.0, 1.0)] dirs = os.listdir(FoldPath) for i in range(np.size(dirs)): # files = pd.read_csv(OutFolder + 'ZoomZone1.dat', header=None)[0] # infiles = [os.path.join(filedir, name) for name in files] filedir = FoldPath + dirs[i] + '/' outfile = 'TP_data' with timer("Read " + dirs[i]): DataFrame, time = \ p2p.ReadINCAResults(filedir, VarList, SubZone=subzone, Equ=equ, SavePath=OutFolder, OutFile=outfile) # p2p.ReadINCAResults(FoldPath, VarList, FileName=FoldPath + 'TP_912.plt', # Equ=equ, SavePath=OutFolder, OutFile='TP_912')
OutFolder3 = "/media/weibo/Data1/BFS_M1.7L_0505/Slice/5C/" OutFolder4 = "/media/weibo/Data1/BFS_M1.7L_0505/Slice/5D/" OutFolder5 = "/media/weibo/Data1/BFS_M1.7L_0505/Slice/5E/" OutFolder6 = "/media/weibo/Data1/BFS_M1.7L_0505/Slice/5F/" NoBlock = 606 # dirs1 = os.listdir(FoldPath) subzone = [(-40.0, 70.0), (-3.0, 10.0)] dirs = os.scandir(FoldPath) for folder in dirs: # path = FoldPath+folder.name+"/" file = FoldPath + folder.name outfile = os.path.splitext(folder.name)[0] with timer("Read " + folder.name + " data"): DataFrame, time = \ p2p.ReadINCAResults(FoldPath, VarList, FileName=file, SubZone=subzone, SavePath=OutFolder, OutFile=outfile, Equ=equ) #DataFrame.to_hdf(OutFolder + "SolTime" + "%0.2f"%time + '.h5', # 'w', format='fixed') #df1 = p2p.SaveSlice(DataFrame, time, 2.0, OutFolder1) #df2 = p2p.SaveSlice(DataFrame, time, 1.5, OutFolder1) #df3 = p2p.SaveSlice(DataFrame, time, 1.0, OutFolder1) #df4 = p2p.SaveSlice(DataFrame, time, 0.5, OutFolder1) #df5 = p2p.SaveSlice(DataFrame, time, 0.0, OutFolder1) #df6 = p2p.SaveSlice(DataFrame, time, -2.0, OutFolder1) #DataFrame.to_csv(FoldPath + "MeanFlow.dat", sep="\t", index=False, # header=VarList, float_format='%.10e') # %% Extract Data for 3D DMD VarList = ['x', 'y', 'z', 'u', 'v', 'w', 'p', '|gradp|']
VarList = [ 'x', 'y', 'z', 'u', 'v', 'w', 'p', 'rho', 'vorticity_1', 'vorticity_2', 'vorticity_3', 'T', ] df, time = p2p.ReadINCAResults(path1, VarList) df.to_hdf(path2 + "TP_data_" + str(time) + ".h5", 'w', format='fixed') # df = pd.read_hdf(path2 + "TP_data_901.h5") df2 = df.groupby(['x', 'y']).transform(lambda x: (x - x.mean())) df1 = pd.concat([df[['x', 'y']], df2], axis=1) df1.to_hdf(path2 + 'ZFluctuation_' + str(time) + '.h5', 'w', format='fixed') cube = [(-10.0, 20.0), (-3.0, 30.0), (-8, 8)] df_zone = p2p.extract_zone(path1, cube, filename=path + "ZoneInfo1.dat") p2p.save_tec_index(df, df_zone, filename=path + "ReadList1.dat") # %% Save fluctuations flow as tecplot .dat varname = [ 'u', 'v', 'w', 'p',