def analyzeCDM_motion(rNo, procList): """ load data and images """ procFile = [] set = 2 for ii in range(len(rNo)): str = '%d.dat' % rNo[ii] procFile.append([s for s in procList if str in s]) str = ''.join(procFile[ii]) df = pd.read_table(str, usecols=[0, 1, 9, 20]) if not 'imgs' in locals(): imgs = fem.getPilatusImgs(df, rNo[ii], set) else: imgs = imgs + fem.getPilatusImgs(df, rNo[ii], set) """ calculate angles for each pixels of each images """ E = 7 alpha = 0.5 pilH = 2.75 # [mm] pilV = -47.5 # [mm] xdb = 21.6 - 414. * 0.170 # [mm] ydb = -58.03 - 188. * 0.17 # [mm] d = 74 img_range = [12, 10] delta, gamma, images = fem.getPixelsAngles(imgs, pilH, pilV, xdb, ydb, d, img_range) E = 7 alpha = 0.5 N = np.array([-1, -1, 2]) omega = -63.66 omega_offset = 0 # offset with respect to the UB matrix rot = np.array(df['# top rotation']) - omega_offset a = np.array([5.39, 5.40, 7.61]) aa = np.array([90, 90, 90.07]) U, B = tldiff.UBmat(a, aa, N) """ find center of mass of the peak """ CDMidx, CDMmaxidx = tlimg.centerOfMass(images) idxup = np.ceil(CDMidx) idxdown = np.floor(CDMidx) CDM_omega = np.interp(CDMidx[0], np.array([idxdown[0], idxup[0]]), np.array([rot[idxdown[0]], rot[idxup[0]]])) omegaMax = rot[CDMmaxidx[0]] CDM_delta = np.interp( CDMidx[0], np.array([idxdown[0], idxup[0]]), np.array([delta[idxdown[1], idxdown[2]], delta[idxup[1], idxup[2]]])) CDM_gamma = np.interp( CDMidx[0], np.array([idxdown[0], idxup[0]]), np.array([gamma[idxdown[1], idxdown[2]], gamma[idxup[1], idxup[2]]])) CDMhkl, CDMQ = tldiff.hklFromAngles(E, CDM_delta, CDM_gamma, CDM_omega, alpha, U, B) images = np.sum(images, axis=0) return images, CDMhkl, CDM_omega, CDM_delta, CDM_gamma, procFile, omegaMax
sys.path.append('Z:/Data1') procList = glob.glob('Z:\Data1\*\proc\proc*.dat') procFile = [] dfList = [] set = 2 count = 0 for ii in range(rNo_all.shape[0]): for jj in range(rNo_all.shape[1]): rNo = rNo_all[ii, jj] string = '%d.dat' % rNo procFile.append([s for s in procList if string in s]) string = ''.join(procFile[count]) temp = pd.read_table(string, usecols=[0, 1, 9, 20, 39]) dfList.append(temp) imgs_temp, uimgs_temp = fem.getPilatusImgs(dfList[count], set) imgs_all[ii, :, :, :] = imgs_all[ii, :, :, :] + imgs_temp uimgs_all[ii, :, :, :] = uimgs_all[ii, :, :, :] + uimgs_temp count += 1 del (imgs_temp) del (uimgs_temp) peakPix = [155, 92] # pixels position of the peak [x,y] roi = np.array([[peakPix[0] - 22, peakPix[0] + 22], [peakPix[1] - 20, peakPix[1] + 20]]) # [[xmin,xmax][ymin,ymax]] imgs_all = imgs_all[:, :, roi[1][0]:roi[1][1], roi[0][0]:roi[0][1]] # line = y, column = x uimgs_all = uimgs_all[:, :, roi[1][0]:roi[1][1], roi[0][0]:roi[0][1]] # line = y, column = x #d = 74 # distance sample - detector [mm]
if not 'data_pilgate' in locals(): data_pilgate = dict() data_pilgate_ave = dict() count = 0 for ii in range(len(rNo_pilgate)): print('pilgate ii = %d' % ii) data_pilgate[ii] = pd.DataFrame() for jj in range(rNo_pilgate[ii].size): rNo = rNo_pilgate[ii][jj] string = '%d.dat' %rNo procFile_pilgate.append( [s for s in procList if string in s] ) string = ''.join(procFile_pilgate[count]) temp = pd.read_table(string,usecols=[0,1,9,18,20]) imgs_temp, uimgs_temp = fem.getPilatusImgs(temp, set) int_roi = np.zeros(imgs_temp.shape[0]) int_bkg = np.zeros(imgs_temp.shape[0]) total_int = np.zeros(131) for kk in range(imgs_temp.shape[0]): # roi = [[0,178],[0,212]] # [[xmin, xmax], [ymin, ymax]] roi = [[94-20,94+20],[165-25,165+25]] # [[xmin, xmax], [ymin, ymax]] # note: the import routine create an array from the images, which invert the axis bkgroi = np.add(roi , [[-30,30],[-30,30]] ) temp_int_roi, temp_int_bkg = imgana.roi_bkgRoi(imgs_temp[kk], roi, bkgroi) int_roi[kk] = temp_int_roi int_bkg[kk] = temp_int_bkg # if kk % 10 == 0: