def getSliceData_Ny_sowfa(dir, jobName, slice, var, varD, trs_para, tInd, xInd, zInd): """ extract velocity data of specified slice_Nz """ readDir = dir + '/data/' readName = slice fr = open(readDir + readName, 'rb') data = pickle.load(fr) fr.close() slc = sdc.Slice(data, 1) del data # 2 means z-axis tSeq = slc.data['time'] tSeq = tSeq[tInd[0]:tInd[1]] Y = slc.N_location # height of this plane O, alpha = trs_para[0], trs_para[1] varSeq = [] for t_ind in range(tInd[0], tInd[1]): print('processing: ' + str(t_ind) + ' ...') tmp = slc.data[var][t_ind] tmp = funcs.trs(tmp, O, alpha) tmp1 = slc.meshITP_Ny(xInd, zInd, tmp[:, varD], 0, method_='linear') xSeq, zSeq, varSeq_ = tmp1[0], tmp1[1], tmp1[2] varSeq.append(varSeq_) varSeq = np.array(varSeq) return tSeq, xSeq, zSeq, Y, varSeq
def getSliceData_Nz_sowfa(jobDir, slice, var, varD, trs_para, tInd, xcoor, ycoor): """ Extract data from specified slice_Nz INPUT jobDir: job directory, e.g. '/scratch/sowfadata/pp/tutorials/example_nbl' slice: the name of the slice, e.g. 'Nz2' var: name of the target variable, e.g. 'U' varD: the dimension of which the target vector variable will be outputted trs_para: coordinate transform parameters, e.g. ((0,0,0),30.0), the origin and the conterclockwise rotation degree tInd: a tuple containing the start time index and end time index of the output data (not including the end tInd) xcoor: a tuple containing the start x, end x and x.size of the output data ycoor: a tuple containing the start y, end y and y.size of the output data OUTPUT tSeq: 1D array of times ySeq: 1D array of y positions xSeq: 1D array of x positions H: the height of the slice varSeq: 3D array of the target variable, 1st dim time, 2nd dim y, 3rd x """ readDir = jobDir + '/data/' readName = slice fr = open(readDir + readName, 'rb') data = pickle.load(fr) fr.close() slc = sdc.Slice(data, 2) del data # 2 means z-axis tSeq = slc.data['time'] tSeq = tSeq[tInd[0]:tInd[1]] H = slc.N_location # height of this plane O, alpha = trs_para[0], trs_para[1] varSeq = [] for t_ind in range(tInd[0], tInd[1]): print('processing: ' + str(t_ind) + ' ...') tmp = slc.data[var][t_ind] tmp = funcs.trs(tmp, O, alpha) tmp1 = slc.meshITP_Nz(xcoor, ycoor, tmp[:, varD], method_='linear') xSeq, ySeq, varSeq_ = tmp1[0], tmp1[1], tmp1[2] varSeq.append(varSeq_) varSeq = np.array(varSeq) return tSeq, xSeq, ySeq, H, varSeq
'Nz5', 'Nz6', 'Nz7', ] sliceNum = len(sliceList) var = 'U' varD = 0 # u:0, v:1, w:2 varNameDict = {0: 'u', 1: 'v', 2: 'w'} readDir = ppDir + '/data/' readName = sliceList[0] fr = open(readDir + readName, 'rb') data_org = pickle.load(fr) fr.close() slc = sdc.Slice(data_org, 2) tSeq = slc.data['time'] tInd = -1 # index of time step plotDataList = [] HList = [] for slice in sliceList: readDir = ppDir + '/data/' readName = slice fr = open(readDir + readName, 'rb') data_org = pickle.load(fr) fr.close() slc = sdc.Slice(data_org, 2) H = slc.N_location # height of this plane
jobName = 'pcr_NBL_U10' ppDir = '/scratch/sowfadata/pp/' + jobName sliceList = ['Ny0'] sliceNum = len(sliceList) var = 'U' varD = 0 # u:0, v:1, w:2 varNameDict = {0: 'u', 1: 'v', 2: 'w'} readDir = ppDir + '/data/' readName = sliceList[0] fr = open(readDir + readName, 'rb') data_org = pickle.load(fr) fr.close() slc = sdc.Slice(data_org, 1) tSeq = slc.data['time'] tInd = -1 # index of time step plotDataList = [] YList = [] for slice in sliceList: readDir = ppDir + '/data/' readName = slice fr = open(readDir + readName, 'rb') data_org = pickle.load(fr) fr.close() slc = sdc.Slice(data_org, 1) Y = slc.N_location # height of this plane
import pickle import sliceDataClass as sdc import matplotlib.pyplot as plt # the directory where the wake data locate prjDir = '/scratch/sowfadata/JOBS' jobName = 'pcr_NBL_U10' ppDir = '/scratch/sowfadata/pp/' + jobName + '/data' readDir = ppDir + '/' readName = 'Ny0' fr = open(readDir + readName, 'rb') data_org = pickle.load(fr) fr.close() test = sdc.Slice(data_org, 1) plotdata = test.meshITP_Ny((0, 2000, 200), (0, 960, 48), test.data['U'][-1][:, 0]) fig, axs = plt.subplots(figsize=(8, 8)) cbreso = 100 # resolution of colorbar CS = axs.contourf(plotdata[0], plotdata[1], plotdata[2], cbreso, cmap='coolwarm') cbar = plt.colorbar(CS, ax=axs, shrink=1.0) cbar.ax.set_ylabel('u (m/s)') # xaxis_min = xseq # xaxis_max = 2