diff --git a/standalone_scripts/5kHz.py b/standalone_scripts/5kHz.py index 16ae7f4..66f0968 100755 --- a/standalone_scripts/5kHz.py +++ b/standalone_scripts/5kHz.py @@ -3,20 +3,20 @@ import numpy as np run = eval(sys.argv[1]) -ds = DataSource(exp='rixx45619',run=run) +ds = DataSource(exp="rixx45619", run=run) myrun = next(ds.runs()) -det = myrun.Detector('epixhr') -timing = myrun.Detector('timing') +det = myrun.Detector("epixhr") +timing = myrun.Detector("timing") -print('pedestal means, 7 modes:',det.calibconst['pedestals'][0].mean(axis=(1,2,3))) -print('pedestal maxes, 7 modes:',det.calibconst['pedestals'][0].max(axis=(1,2,3))) +print("pedestal means, 7 modes:", det.calibconst["pedestals"][0].mean(axis=(1, 2, 3))) +print("pedestal maxes, 7 modes:", det.calibconst["pedestals"][0].max(axis=(1, 2, 3))) fl = [] n = 0 n20 = [] -desiredCode = {'120Hz':272, '4kHz':273, '5kHz':274} +desiredCode = {"120Hz": 272, "4kHz": 273, "5kHz": 274} lastEventWas120Hz = False nFoo = 0 @@ -26,35 +26,35 @@ if lastEventWas120Hz: ## do something pass - if not allcodes[desiredCode['120Hz']]: -## print("found", allcodes, "not", desiredCode) -## print("no 120Hz") + if not allcodes[desiredCode["120Hz"]]: + ## print("found", allcodes, "not", desiredCode) + ## print("no 120Hz") mean = det.raw.raw(evt).mean() - print("mean for event %d after 120Hz %0.3f" %(nFoo, mean)) + print("mean for event %d after 120Hz %0.3f" % (nFoo, mean)) - np.save("not120_%d.npy" %(nFoo), det.raw.raw(evt)) + np.save("not120_%d.npy" % (nFoo), det.raw.raw(evt)) if lastEventWas120Hz: - print("mean for event after 120Hz %0.3f" %(mean)) - np.save("lastEventWas120Hz_%d.npy" %(n120s-1), det.raw.raw(evt)) + print("mean for event after 120Hz %0.3f" % (mean)) + np.save("lastEventWas120Hz_%d.npy" % (n120s - 1), det.raw.raw(evt)) nFoo += 1 lastEventWas120Hz = False continue else: - print("found 120Hz after %d, %0.3f" %(nFoo, mean)) + print("found 120Hz after %d, %0.3f" % (nFoo, mean)) mean = det.raw.raw(evt).mean() - np.save("thisEventWas120Hz_%d.npy" %(n120s), det.raw.raw(evt)) - print("mean now %0.3f" %(mean)) + np.save("thisEventWas120Hz_%d.npy" % (n120s), det.raw.raw(evt)) + print("mean now %0.3f" % (mean)) nFoo = 0 n120s += 1 lastEventWas120Hz = True -##136 means NEH got the beam + ##136 means NEH got the beam rawFrames = det.raw.raw(evt) frames = det.raw.calib(evt) - n20.append((frames>20).sum()) + n20.append((frames > 20).sum()) fl.append(frames) n += 1 - if n%1000 == 0: + if n % 1000 == 0: print(n) fl = np.array(fl) print(n) diff --git a/standalone_scripts/DamageCounter.py b/standalone_scripts/DamageCounter.py index b85deaf..54fb43f 100644 --- a/standalone_scripts/DamageCounter.py +++ b/standalone_scripts/DamageCounter.py @@ -1,47 +1,49 @@ from psana import DataSource import os import numpy as np -os.environ['PS_SMD_N_EVENTS'] = '50' -os.environ['PS_SRV_NODES']='1' - -ds = DataSource(exp='rixc00121', run=32, intg_det='epixhr') -smd = ds.smalldata(filename='ts.h5') + +os.environ["PS_SMD_N_EVENTS"] = "50" +os.environ["PS_SRV_NODES"] = "1" + +ds = DataSource(exp="rixc00121", run=32, intg_det="epixhr") +smd = ds.smalldata(filename="ts.h5") myrun = next(ds.runs()) -epix = myrun.Detector('epixhr') -timeObj = myrun.Detector('timing') -nevt=0 +epix = myrun.Detector("epixhr") +timeObj = myrun.Detector("timing") +nevt = 0 nBeam = 0 -for nevt,evt in enumerate(myrun.events()): +for nevt, evt in enumerate(myrun.events()): if evt is None: continue ec = timeObj.raw.eventcodes(evt) if not ec[281]: continue nBeam += 1 - + frames = epix.raw.raw(evt) if frames is None: continue smd.event(evt, ts=evt.datetime().timestamp(), nBeam=nBeam, nevt=nevt) - + ##if smd.summary: ## smd.save_summary(step_av) # this method accepts either a dictionary or kwargs smd.done() import matplotlib.pyplot as plt import h5py + a = h5py.File("ts.h5") -mona_ts = a['timestamp'][()] -ts = a['ts'][()] -print(False in (ts ==mona_ts)) -counter=np.arange(10000) +mona_ts = a["timestamp"][()] +ts = a["ts"][()] +print(False in (ts == mona_ts)) +counter = np.arange(10000) ##plt.plot(counter[:400], ts[:400]) ##plt.xlabel("entry") ##plt.ylabel("timestamp") ##plt.show() -nBeam = a['nBeam'][()] +nBeam = a["nBeam"][()] print("nBeam max:", nBeam.max()) -nevt = a['nevt'][()] +nevt = a["nevt"][()] print("nevt max:", nevt.max()) diff --git a/standalone_scripts/MapCompEnOn.py b/standalone_scripts/MapCompEnOn.py index b060950..fb5b626 100644 --- a/standalone_scripts/MapCompEnOn.py +++ b/standalone_scripts/MapCompEnOn.py @@ -8,7 +8,7 @@ import os import math -if len(sys.argv) != 3 or sys.argv[1] != '-f': +if len(sys.argv) != 3 or sys.argv[1] != "-f": print("Usage: python MapCompEnOn.py -f filename") sys.exit(1) @@ -17,7 +17,7 @@ base_filename = os.path.splitext(os.path.basename(file_name))[0] # Open the HDF5 file -with h5py.File(file_name, 'r') as file: +with h5py.File(file_name, "r") as file: # Define the name of the group containing the datasets group_name = "slice" # Change this to the actual group name dataset_names = list(file[group_name].keys()) @@ -36,82 +36,85 @@ # Access and plot a specific slice from the combined data (e.g., the first slice) slice_to_display = combined_data[2, :, :] -#plt.imshow(slice_to_display, cmap='viridis') # Adjust the colormap as needed -#plt.colorbar() # Add a colorbar for reference -#plt.show() +# plt.imshow(slice_to_display, cmap='viridis') # Adjust the colormap as needed +# plt.colorbar() # Add a colorbar for reference +# plt.show() timeVec = [float(x) * 1 for x in dataset_names] +rowsNum = combined_data.shape[1] +colsNum = combined_data.shape[2] -rowsNum=combined_data.shape[1] -colsNum=combined_data.shape[2] +X1 = np.zeros((rowsNum, colsNum)) +Y1 = np.zeros((rowsNum, colsNum)) +X2 = np.zeros((rowsNum, colsNum)) +Y2 = np.zeros((rowsNum, colsNum)) +X3 = np.zeros((rowsNum, colsNum)) +Y3 = np.zeros((rowsNum, colsNum)) -X1=np.zeros((rowsNum, colsNum)) -Y1=np.zeros((rowsNum, colsNum)) -X2=np.zeros((rowsNum, colsNum)) -Y2=np.zeros((rowsNum, colsNum)) -X3=np.zeros((rowsNum, colsNum)) -Y3=np.zeros((rowsNum, colsNum)) +Xinterp = np.linspace(min(timeVec), max(timeVec), 5000) -Xinterp=np.linspace(min(timeVec),max(timeVec),5000) - -AvAll=np.mean(combined_data,axis=(1,2)) +AvAll = np.mean(combined_data, axis=(1, 2)) -#for ir in range(0,rowsNum): +# for ir in range(0,rowsNum): # for ic in range(0,colsNum): -minir=0 -maxir=rowsNum -minic=0 -maxic=colsNum -for ir in range(minir,maxir): - for ic in range(minic,maxic): - # print('row :',ir) - # print('col :',ic) - -#for ir in range(10,11): -# for ic in range(30,31): - timelineToDisplay=combined_data[:,ir,ic] - f = interp1d(timeVec, timelineToDisplay, kind='linear') +minir = 0 +maxir = rowsNum +minic = 0 +maxic = colsNum +for ir in range(minir, maxir): + for ic in range(minic, maxic): + # print('row :',ir) + # print('col :',ic) + + # for ir in range(10,11): + # for ic in range(30,31): + timelineToDisplay = combined_data[:, ir, ic] + f = interp1d(timeVec, timelineToDisplay, kind="linear") y_new = f(Xinterp) - y_new_2ndpart = f(Xinterp[Xinterp>(np.mean(timeVec))]) - thediff=np.diff(y_new) - thediff_2ndpart=np.diff(y_new_2ndpart) + y_new_2ndpart = f(Xinterp[Xinterp > (np.mean(timeVec))]) + thediff = np.diff(y_new) + thediff_2ndpart = np.diff(y_new_2ndpart) window_size = 150 polynomial_order = 1 # Apply Savitzky-Golay filtering smoothed_data = savgol_filter(thediff, window_size, polynomial_order) - differencialfiltered=np.array(smoothed_data) - + differencialfiltered = np.array(smoothed_data) + smoothed_data_2ndpart = savgol_filter(thediff_2ndpart, window_size, polynomial_order) - differencialfiltered_2ndpart=np.array(smoothed_data_2ndpart) - X=Xinterp[0:-1] - Y=smoothed_data - X1[ir,ic]=Xinterp[np.argmax(smoothed_data)] - Y1[ir,ic]=y_new[np.argmax(smoothed_data)] - X2[ir,ic]=Xinterp[np.argmin(smoothed_data)] - Y2[ir,ic]=y_new[np.argmin(smoothed_data)] - X3[ir,ic]=min(X[Y==min(Y[len(Y)//2:-1])]) - Y3[ir,ic]=y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data)//2):-1])] + differencialfiltered_2ndpart = np.array(smoothed_data_2ndpart) + X = Xinterp[0:-1] + Y = smoothed_data + X1[ir, ic] = Xinterp[np.argmax(smoothed_data)] + Y1[ir, ic] = y_new[np.argmax(smoothed_data)] + X2[ir, ic] = Xinterp[np.argmin(smoothed_data)] + Y2[ir, ic] = y_new[np.argmin(smoothed_data)] + X3[ir, ic] = min(X[Y == min(Y[len(Y) // 2 : -1])]) + Y3[ir, ic] = y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data) // 2) : -1])] if False: - plt.subplot(3,1,1) - plt.plot(Xinterp,y_new,'k') - plt.plot(Xinterp[np.argmin(smoothed_data)],y_new[np.argmin(smoothed_data)],'r*') - plt.plot(Xinterp[np.argmax(smoothed_data)],y_new[np.argmax(smoothed_data)],'b*') - plt.plot(min(X[Y==min(Y[len(Y)//2:-1])]),y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data)//2):-1])],'y*') - - plt.subplot(3,1,2) - plt.hist(y_new,100) - plt.subplot(3,1,3) - - plt.plot(thediff,'b.') - plt.plot(smoothed_data,'r') + plt.subplot(3, 1, 1) + plt.plot(Xinterp, y_new, "k") + plt.plot(Xinterp[np.argmin(smoothed_data)], y_new[np.argmin(smoothed_data)], "r*") + plt.plot(Xinterp[np.argmax(smoothed_data)], y_new[np.argmax(smoothed_data)], "b*") + plt.plot( + min(X[Y == min(Y[len(Y) // 2 : -1])]), + y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data) // 2) : -1])], + "y*", + ) + + plt.subplot(3, 1, 2) + plt.hist(y_new, 100) + plt.subplot(3, 1, 3) + + plt.plot(thediff, "b.") + plt.plot(smoothed_data, "r") plt.show() - + # print(X1[ir,ic]) # print(X2[ir,ic]) # print(X3[ir,ic]) @@ -119,96 +122,97 @@ # print(Y2[ir,ic]) # print(Y3[ir,ic]) # print('%%%%%%%%%%%%%%%%%%%%%%') - + fig = plt.figure() -#fig, axs = plt.subplots(nrows=3, ncols=1, figsize=(4, 12)) # Adjust figsize as needed +# fig, axs = plt.subplots(nrows=3, ncols=1, figsize=(4, 12)) # Adjust figsize as needed plt.suptitle("Click on figure to see the timeline of a pixel", fontsize=12) plt.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9) -plt.subplot(3,1,1) -#plt.imshow(X3,vmin=X3.min(),vmax=X3.max()) -plt.imshow(X3,vmin=(np.mean(X3)-1*(np.std(X3))),vmax=(np.mean(X3)+1*(np.std(X3)))) -plt.title('Onset transfer function') +plt.subplot(3, 1, 1) +# plt.imshow(X3,vmin=X3.min(),vmax=X3.max()) +plt.imshow(X3, vmin=(np.mean(X3) - 1 * (np.std(X3))), vmax=(np.mean(X3) + 1 * (np.std(X3)))) +plt.title("Onset transfer function") plt.colorbar() -#plt.tight_layout() +# plt.tight_layout() -plt.subplot(3,1,2) -plt.imshow(X2,vmin=X2.min(),vmax=X2.max()) -plt.imshow(X2,vmin=(np.mean(X2)-1*(np.std(X2))),vmax=(np.mean(X2)+1*(np.std(X2)))) -plt.title('Onset CompEnOn') +plt.subplot(3, 1, 2) +plt.imshow(X2, vmin=X2.min(), vmax=X2.max()) +plt.imshow(X2, vmin=(np.mean(X2) - 1 * (np.std(X2))), vmax=(np.mean(X2) + 1 * (np.std(X2)))) +plt.title("Onset CompEnOn") plt.colorbar() -#plt.tight_layout() - -plt.subplot(3,1,3) -#plt.imshow(X3[minir:maxir,minic:maxic]-X1[minir:maxir,minic:maxic]) -X4=X3-X1 -#plt.imshow(X3-X1,vmin=(X3-X1).min(),vmax=(X3-X1).max()) -plt.imshow(X4,vmin=(np.mean(X4)-1*(np.std(X4))),vmax=(np.mean(X4)+1*(np.std(X4)))) -plt.title('Length transfer function') +# plt.tight_layout() + +plt.subplot(3, 1, 3) +# plt.imshow(X3[minir:maxir,minic:maxic]-X1[minir:maxir,minic:maxic]) +X4 = X3 - X1 +# plt.imshow(X3-X1,vmin=(X3-X1).min(),vmax=(X3-X1).max()) +plt.imshow(X4, vmin=(np.mean(X4) - 1 * (np.std(X4))), vmax=(np.mean(X4) + 1 * (np.std(X4)))) +plt.title("Length transfer function") plt.colorbar() -#plt.tight_layout() - -#fig = plt.figure() -#plt.imshow(X2,vmin=X2.min(),vmax=X2.max()) -#plt.imshow(X2,vmin=(np.mean(X2)-1*(np.std(X2))),vmax=(np.mean(X2)+1*(np.std(X2)))) -#plt.title('Onset CompEnOn') -#plt.colorbar() -#plt.tight_layout() +# plt.tight_layout() +# fig = plt.figure() +# plt.imshow(X2,vmin=X2.min(),vmax=X2.max()) +# plt.imshow(X2,vmin=(np.mean(X2)-1*(np.std(X2))),vmax=(np.mean(X2)+1*(np.std(X2)))) +# plt.title('Onset CompEnOn') +# plt.colorbar() +# plt.tight_layout() # Save the plotted image to a PNG file with the filename save_path = "/sdf/data/lcls/ds/rix/rixx1003721/results/scan/{}_plot.png".format(base_filename) plt.savefig(save_path) + def onclick(event): ix, iy = event.xdata, event.ydata - colsel= math.trunc(ix) - rowsel=math.trunc(iy) - #print(f'x = {ix}, y = {iy}') + colsel = math.trunc(ix) + rowsel = math.trunc(iy) + # print(f'x = {ix}, y = {iy}') - timelineToDisplay=combined_data[:,rowsel,colsel] - f = interp1d(timeVec, timelineToDisplay, kind='linear') + timelineToDisplay = combined_data[:, rowsel, colsel] + f = interp1d(timeVec, timelineToDisplay, kind="linear") y_new = f(Xinterp) - y_new_2ndpart = f(Xinterp[Xinterp>(np.mean(timeVec))]) - thediff=np.diff(y_new) - thediff_2ndpart=np.diff(y_new_2ndpart) + y_new_2ndpart = f(Xinterp[Xinterp > (np.mean(timeVec))]) + thediff = np.diff(y_new) + thediff_2ndpart = np.diff(y_new_2ndpart) window_size = 150 polynomial_order = 1 - # Apply Savitzky-Golay filtering + # Apply Savitzky-Golay filtering smoothed_data = savgol_filter(thediff, window_size, polynomial_order) - differencialfiltered=np.array(smoothed_data) - + differencialfiltered = np.array(smoothed_data) + smoothed_data_2ndpart = savgol_filter(thediff_2ndpart, window_size, polynomial_order) - differencialfiltered_2ndpart=np.array(smoothed_data_2ndpart) - X=Xinterp[0:-1] - Y=smoothed_data - X1[ir,ic]=Xinterp[np.argmax(smoothed_data)] - Y1[ir,ic]=y_new[np.argmax(smoothed_data)] - X2[ir,ic]=Xinterp[np.argmin(smoothed_data)] - Y2[ir,ic]=y_new[np.argmin(smoothed_data)] - X3[ir,ic]=min(X[Y==min(Y[len(Y)//2:-1])]) - Y3[ir,ic]=y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data)//2):-1])] -# plt.figure(10) -# plt.close(10) -# plt.subplots_adjust(left=0.2, bottom=0.2, right=1.0, top=1.0) + differencialfiltered_2ndpart = np.array(smoothed_data_2ndpart) + X = Xinterp[0:-1] + Y = smoothed_data + X1[ir, ic] = Xinterp[np.argmax(smoothed_data)] + Y1[ir, ic] = y_new[np.argmax(smoothed_data)] + X2[ir, ic] = Xinterp[np.argmin(smoothed_data)] + Y2[ir, ic] = y_new[np.argmin(smoothed_data)] + X3[ir, ic] = min(X[Y == min(Y[len(Y) // 2 : -1])]) + Y3[ir, ic] = y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data) // 2) : -1])] + # plt.figure(10) + # plt.close(10) + # plt.subplots_adjust(left=0.2, bottom=0.2, right=1.0, top=1.0) plt.figure(10) plt.ion() plt.clf() plt.show(block=False) - plt.plot(Xinterp,y_new,'k') - plt.plot(Xinterp[np.argmin(smoothed_data)],y_new[np.argmin(smoothed_data)],'r*') - plt.plot(Xinterp[np.argmax(smoothed_data)],y_new[np.argmax(smoothed_data)],'b*') - plt.plot(min(X[Y==min(Y[len(Y)//2:-1])]),y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data)//2):-1])],'y*') - plt.title(f'Pixel:{colsel},{rowsel}') + plt.plot(Xinterp, y_new, "k") + plt.plot(Xinterp[np.argmin(smoothed_data)], y_new[np.argmin(smoothed_data)], "r*") + plt.plot(Xinterp[np.argmax(smoothed_data)], y_new[np.argmax(smoothed_data)], "b*") + plt.plot( + min(X[Y == min(Y[len(Y) // 2 : -1])]), + y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data) // 2) : -1])], + "y*", + ) + plt.title(f"Pixel:{colsel},{rowsel}") plt.show() - #print('Do you get there????') -cid = fig.canvas.mpl_connect('button_press_event', onclick) + # print('Do you get there????') +cid = fig.canvas.mpl_connect("button_press_event", onclick) plt.show() - - - diff --git a/standalone_scripts/MapCompEnOnThreshold.py b/standalone_scripts/MapCompEnOnThreshold.py index 0d7068f..e0a8bcd 100644 --- a/standalone_scripts/MapCompEnOnThreshold.py +++ b/standalone_scripts/MapCompEnOnThreshold.py @@ -8,7 +8,7 @@ import os import math -if len(sys.argv) != 3 or sys.argv[1] != '-f': +if len(sys.argv) != 3 or sys.argv[1] != "-f": print("Usage: python MapCompEnOn.py -f filename") sys.exit(1) @@ -17,7 +17,7 @@ base_filename = os.path.splitext(os.path.basename(file_name))[0] # Open the HDF5 file -with h5py.File(file_name, 'r') as file: +with h5py.File(file_name, "r") as file: # Define the name of the group containing the datasets group_name = "slice" # Change this to the actual group name dataset_names = list(file[group_name].keys()) @@ -36,77 +36,76 @@ # Access and plot a specific slice from the combined data (e.g., the first slice) slice_to_display = combined_data[2, :, :] -#plt.imshow(slice_to_display, cmap='viridis') # Adjust the colormap as needed -#plt.colorbar() # Add a colorbar for reference -#plt.show() +# plt.imshow(slice_to_display, cmap='viridis') # Adjust the colormap as needed +# plt.colorbar() # Add a colorbar for reference +# plt.show() timeVec = [float(x) * 1 for x in dataset_names] +rowsNum = combined_data.shape[1] +colsNum = combined_data.shape[2] -rowsNum=combined_data.shape[1] -colsNum=combined_data.shape[2] +X1 = np.zeros((rowsNum, colsNum)) +Y1 = np.zeros((rowsNum, colsNum)) +X2 = np.zeros((rowsNum, colsNum)) +Y2 = np.zeros((rowsNum, colsNum)) +X3 = np.zeros((rowsNum, colsNum)) +Y3 = np.zeros((rowsNum, colsNum)) -X1=np.zeros((rowsNum, colsNum)) -Y1=np.zeros((rowsNum, colsNum)) -X2=np.zeros((rowsNum, colsNum)) -Y2=np.zeros((rowsNum, colsNum)) -X3=np.zeros((rowsNum, colsNum)) -Y3=np.zeros((rowsNum, colsNum)) +Xinterp = np.linspace(min(timeVec), max(timeVec), 5000) -Xinterp=np.linspace(min(timeVec),max(timeVec),5000) - -AvAll=np.mean(combined_data,axis=(1,2)) +AvAll = np.mean(combined_data, axis=(1, 2)) -#for ir in range(0,rowsNum): +# for ir in range(0,rowsNum): # for ic in range(0,colsNum): -minir=0 -maxir=rowsNum -minic=0 -maxic=colsNum -for ir in range(minir,maxir): - for ic in range(minic,maxic): - # print('row :',ir) - # print('col :',ic) - -#for ir in range(10,11): -# for ic in range(30,31): - timelineToDisplay=combined_data[:,ir,ic] - f = interp1d(timeVec, timelineToDisplay, kind='linear') +minir = 0 +maxir = rowsNum +minic = 0 +maxic = colsNum +for ir in range(minir, maxir): + for ic in range(minic, maxic): + # print('row :',ir) + # print('col :',ic) + + # for ir in range(10,11): + # for ic in range(30,31): + timelineToDisplay = combined_data[:, ir, ic] + f = interp1d(timeVec, timelineToDisplay, kind="linear") y_new = f(Xinterp) - y_new_2ndpart = f(Xinterp[Xinterp>(np.mean(timeVec))]) - thediff=np.diff(y_new) - thediff_2ndpart=np.diff(y_new_2ndpart) + y_new_2ndpart = f(Xinterp[Xinterp > (np.mean(timeVec))]) + thediff = np.diff(y_new) + thediff_2ndpart = np.diff(y_new_2ndpart) window_size = 150 polynomial_order = 1 # Apply Savitzky-Golay filtering smoothed_data = savgol_filter(thediff, window_size, polynomial_order) - differencialfiltered=np.array(smoothed_data) - + differencialfiltered = np.array(smoothed_data) + smoothed_data_2ndpart = savgol_filter(thediff_2ndpart, window_size, polynomial_order) - differencialfiltered_2ndpart=np.array(smoothed_data_2ndpart) - X=Xinterp[0:-1] - Y=smoothed_data - xx=Xinterp - yy=y_new - X1[ir,ic]=xx[np.argmax(smoothed_data)] - Y1[ir,ic]=yy[np.argmax(smoothed_data)] - X2[ir,ic]=xx[np.argmin(smoothed_data)] - Y2[ir,ic]=yy[np.argmin(smoothed_data)] - X3[ir,ic]=min(xx[yy<(np.min(yy)+(np.mean(yy)-np.min(yy))/2)]) - Y3[ir,ic]=yy[xx==min(xx[yy<(np.min(yy)+(np.mean(yy)-np.min(yy))/2)])] + differencialfiltered_2ndpart = np.array(smoothed_data_2ndpart) + X = Xinterp[0:-1] + Y = smoothed_data + xx = Xinterp + yy = y_new + X1[ir, ic] = xx[np.argmax(smoothed_data)] + Y1[ir, ic] = yy[np.argmax(smoothed_data)] + X2[ir, ic] = xx[np.argmin(smoothed_data)] + Y2[ir, ic] = yy[np.argmin(smoothed_data)] + X3[ir, ic] = min(xx[yy < (np.min(yy) + (np.mean(yy) - np.min(yy)) / 2)]) + Y3[ir, ic] = yy[xx == min(xx[yy < (np.min(yy) + (np.mean(yy) - np.min(yy)) / 2)])] if True: - plt.plot(xx,yy,'k') - plt.plot(np.mean(xx),np.mean(yy)+(np.max(yy)-np.mean(yy))/2,'r*') - #plt.plot(np.mean(xx),np.min(yy)+(np.mean(yy)-np.min(yy))/2,'g*') - plt.plot(X3[ir,ic],Y3[ir,ic],'g*') + plt.plot(xx, yy, "k") + plt.plot(np.mean(xx), np.mean(yy) + (np.max(yy) - np.mean(yy)) / 2, "r*") + # plt.plot(np.mean(xx),np.min(yy)+(np.mean(yy)-np.min(yy))/2,'g*') + plt.plot(X3[ir, ic], Y3[ir, ic], "g*") plt.show() - - + + # print(X1[ir,ic]) # print(X2[ir,ic]) # print(X3[ir,ic]) @@ -114,96 +113,97 @@ # print(Y2[ir,ic]) # print(Y3[ir,ic]) # print('%%%%%%%%%%%%%%%%%%%%%%') - + fig = plt.figure() -#fig, axs = plt.subplots(nrows=3, ncols=1, figsize=(4, 12)) # Adjust figsize as needed +# fig, axs = plt.subplots(nrows=3, ncols=1, figsize=(4, 12)) # Adjust figsize as needed plt.suptitle("Click on figure to see the timeline of a pixel", fontsize=12) plt.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9) -plt.subplot(3,1,1) -#plt.imshow(X3,vmin=X3.min(),vmax=X3.max()) -plt.imshow(X3,vmin=(np.mean(X3)-1*(np.std(X3))),vmax=(np.mean(X3)+1*(np.std(X3)))) -plt.title('Onset transfer function') +plt.subplot(3, 1, 1) +# plt.imshow(X3,vmin=X3.min(),vmax=X3.max()) +plt.imshow(X3, vmin=(np.mean(X3) - 1 * (np.std(X3))), vmax=(np.mean(X3) + 1 * (np.std(X3)))) +plt.title("Onset transfer function") plt.colorbar() -#plt.tight_layout() +# plt.tight_layout() -plt.subplot(3,1,2) -plt.imshow(X2,vmin=X2.min(),vmax=X2.max()) -plt.imshow(X2,vmin=(np.mean(X2)-1*(np.std(X2))),vmax=(np.mean(X2)+1*(np.std(X2)))) -plt.title('Onset CompEnOn') +plt.subplot(3, 1, 2) +plt.imshow(X2, vmin=X2.min(), vmax=X2.max()) +plt.imshow(X2, vmin=(np.mean(X2) - 1 * (np.std(X2))), vmax=(np.mean(X2) + 1 * (np.std(X2)))) +plt.title("Onset CompEnOn") plt.colorbar() -#plt.tight_layout() - -plt.subplot(3,1,3) -#plt.imshow(X3[minir:maxir,minic:maxic]-X1[minir:maxir,minic:maxic]) -X4=X3-X1 -#plt.imshow(X3-X1,vmin=(X3-X1).min(),vmax=(X3-X1).max()) -plt.imshow(X4,vmin=(np.mean(X4)-1*(np.std(X4))),vmax=(np.mean(X4)+1*(np.std(X4)))) -plt.title('Length transfer function') +# plt.tight_layout() + +plt.subplot(3, 1, 3) +# plt.imshow(X3[minir:maxir,minic:maxic]-X1[minir:maxir,minic:maxic]) +X4 = X3 - X1 +# plt.imshow(X3-X1,vmin=(X3-X1).min(),vmax=(X3-X1).max()) +plt.imshow(X4, vmin=(np.mean(X4) - 1 * (np.std(X4))), vmax=(np.mean(X4) + 1 * (np.std(X4)))) +plt.title("Length transfer function") plt.colorbar() -#plt.tight_layout() - -#fig = plt.figure() -#plt.imshow(X2,vmin=X2.min(),vmax=X2.max()) -#plt.imshow(X2,vmin=(np.mean(X2)-1*(np.std(X2))),vmax=(np.mean(X2)+1*(np.std(X2)))) -#plt.title('Onset CompEnOn') -#plt.colorbar() -#plt.tight_layout() +# plt.tight_layout() +# fig = plt.figure() +# plt.imshow(X2,vmin=X2.min(),vmax=X2.max()) +# plt.imshow(X2,vmin=(np.mean(X2)-1*(np.std(X2))),vmax=(np.mean(X2)+1*(np.std(X2)))) +# plt.title('Onset CompEnOn') +# plt.colorbar() +# plt.tight_layout() # Save the plotted image to a PNG file with the filename save_path = "/sdf/data/lcls/ds/rix/rixx1003721/results/scan/{}_plot.png".format(base_filename) plt.savefig(save_path) + def onclick(event): ix, iy = event.xdata, event.ydata - colsel= math.trunc(ix) - rowsel=math.trunc(iy) - #print(f'x = {ix}, y = {iy}') + colsel = math.trunc(ix) + rowsel = math.trunc(iy) + # print(f'x = {ix}, y = {iy}') - timelineToDisplay=combined_data[:,rowsel,colsel] - f = interp1d(timeVec, timelineToDisplay, kind='linear') + timelineToDisplay = combined_data[:, rowsel, colsel] + f = interp1d(timeVec, timelineToDisplay, kind="linear") y_new = f(Xinterp) - y_new_2ndpart = f(Xinterp[Xinterp>(np.mean(timeVec))]) - thediff=np.diff(y_new) - thediff_2ndpart=np.diff(y_new_2ndpart) + y_new_2ndpart = f(Xinterp[Xinterp > (np.mean(timeVec))]) + thediff = np.diff(y_new) + thediff_2ndpart = np.diff(y_new_2ndpart) window_size = 150 polynomial_order = 1 - # Apply Savitzky-Golay filtering + # Apply Savitzky-Golay filtering smoothed_data = savgol_filter(thediff, window_size, polynomial_order) - differencialfiltered=np.array(smoothed_data) - + differencialfiltered = np.array(smoothed_data) + smoothed_data_2ndpart = savgol_filter(thediff_2ndpart, window_size, polynomial_order) - differencialfiltered_2ndpart=np.array(smoothed_data_2ndpart) - X=Xinterp[0:-1] - Y=smoothed_data - X1[ir,ic]=Xinterp[np.argmax(smoothed_data)] - Y1[ir,ic]=y_new[np.argmax(smoothed_data)] - X2[ir,ic]=Xinterp[np.argmin(smoothed_data)] - Y2[ir,ic]=y_new[np.argmin(smoothed_data)] - X3[ir,ic]=min(X[Y==min(Y[len(Y)//2:-1])]) - Y3[ir,ic]=y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data)//2):-1])] -# plt.figure(10) -# plt.close(10) -# plt.subplots_adjust(left=0.2, bottom=0.2, right=1.0, top=1.0) + differencialfiltered_2ndpart = np.array(smoothed_data_2ndpart) + X = Xinterp[0:-1] + Y = smoothed_data + X1[ir, ic] = Xinterp[np.argmax(smoothed_data)] + Y1[ir, ic] = y_new[np.argmax(smoothed_data)] + X2[ir, ic] = Xinterp[np.argmin(smoothed_data)] + Y2[ir, ic] = y_new[np.argmin(smoothed_data)] + X3[ir, ic] = min(X[Y == min(Y[len(Y) // 2 : -1])]) + Y3[ir, ic] = y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data) // 2) : -1])] + # plt.figure(10) + # plt.close(10) + # plt.subplots_adjust(left=0.2, bottom=0.2, right=1.0, top=1.0) plt.figure(10) plt.ion() plt.clf() plt.show(block=False) - plt.plot(Xinterp,y_new,'k') - plt.plot(Xinterp[np.argmin(smoothed_data)],y_new[np.argmin(smoothed_data)],'r*') - plt.plot(Xinterp[np.argmax(smoothed_data)],y_new[np.argmax(smoothed_data)],'b*') - plt.plot(min(X[Y==min(Y[len(Y)//2:-1])]),y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data)//2):-1])],'y*') - plt.title(f'Pixel:{colsel},{rowsel}') + plt.plot(Xinterp, y_new, "k") + plt.plot(Xinterp[np.argmin(smoothed_data)], y_new[np.argmin(smoothed_data)], "r*") + plt.plot(Xinterp[np.argmax(smoothed_data)], y_new[np.argmax(smoothed_data)], "b*") + plt.plot( + min(X[Y == min(Y[len(Y) // 2 : -1])]), + y_new_2ndpart[np.argmin(smoothed_data[(len(smoothed_data) // 2) : -1])], + "y*", + ) + plt.title(f"Pixel:{colsel},{rowsel}") plt.show() - #print('Do you get there????') -cid = fig.canvas.mpl_connect('button_press_event', onclick) + # print('Do you get there????') +cid = fig.canvas.mpl_connect("button_press_event", onclick) plt.show() - - - diff --git a/standalone_scripts/OpenXav.py b/standalone_scripts/OpenXav.py index 27a3d38..20617d0 100644 --- a/standalone_scripts/OpenXav.py +++ b/standalone_scripts/OpenXav.py @@ -1,15 +1,14 @@ import matplotlib.pyplot as plt import h5py -file_name = '../scan/TimeScanParallel_c0_r286_n1.h5' # Update with your file name +file_name = "../scan/TimeScanParallel_c0_r286_n1.h5" # Update with your file name -with h5py.File(file_name, 'r') as file: - dataset = file['dataset_name'] # Replace 'dataset_name' with the actual dataset name +with h5py.File(file_name, "r") as file: + dataset = file["dataset_name"] # Replace 'dataset_name' with the actual dataset name data = dataset[:] # Load the dataset into a NumPy array # Assuming 'data' is a 2D image -plt.imshow(data, cmap='viridis') # Adjust cmap and other parameters as needed +plt.imshow(data, cmap="viridis") # Adjust cmap and other parameters as needed plt.colorbar() plt.show() - diff --git a/standalone_scripts/cfg_utils.py b/standalone_scripts/cfg_utils.py index 52c914f..f8b4355 100644 --- a/standalone_scripts/cfg_utils.py +++ b/standalone_scripts/cfg_utils.py @@ -1,32 +1,32 @@ import numpy -def dumpvars(prefix,c): - for key,val in vars(c).items(): - name = prefix+'.'+key - if (isinstance(val,int) or - isinstance(val,float) or - isinstance(val,str) or - isinstance(val,list)): - print('{:} {:}'.format(name,val)) - elif isinstance(val,numpy.ndarray): - print('{:}[{:}] {:}'.format(name,val.shape,val)) - elif hasattr(val,'value'): - print('{:} {:}'.format(name,val.names[val.value])) + +def dumpvars(prefix, c): + for key, val in vars(c).items(): + name = prefix + "." + key + if isinstance(val, int) or isinstance(val, float) or isinstance(val, str) or isinstance(val, list): + print("{:} {:}".format(name, val)) + elif isinstance(val, numpy.ndarray): + print("{:}[{:}] {:}".format(name, val.shape, val)) + elif hasattr(val, "value"): + print("{:} {:}".format(name, val.names[val.value])) else: try: - dumpvars(name,val) + dumpvars(name, val) except: - print('Error dumping {:} {:}'.format(name,type(val))) + print("Error dumping {:} {:}".format(name, type(val))) + + +def dump_seg(seg, cfg): + print("-- segment {:} --".format(seg)) + dumpvars("config", cfg.config) -def dump_seg(seg,cfg): - print('-- segment {:} --'.format(seg)) - dumpvars('config',cfg.config) -def dump_det_config(det,name): +def dump_det_config(det, name): for config in det._configs: if not name in config.__dict__: - print('Skipping config {:}'.format(config.__dict__)) + print("Skipping config {:}".format(config.__dict__)) continue - scfg = getattr(config,name) - for seg,segcfg in scfg.items(): - dump_seg(seg,segcfg) + scfg = getattr(config, name) + for seg, segcfg in scfg.items(): + dump_seg(seg, segcfg) diff --git a/standalone_scripts/compareConfigs.py b/standalone_scripts/compareConfigs.py index 7940474..db3d42d 100644 --- a/standalone_scripts/compareConfigs.py +++ b/standalone_scripts/compareConfigs.py @@ -1,27 +1,30 @@ import sys -c0 = open(sys.argv[1], 'r') -c1 = open(sys.argv[2], 'r') +c0 = open(sys.argv[1], "r") +c1 = open(sys.argv[2], "r") lines0 = c0.readlines() lines1 = c1.readlines() for l0 in lines0: - if not l0.startswith('config'): continue - if l0.startswith('step 1'): break + if not l0.startswith("config"): + continue + if l0.startswith("step 1"): + break try: r0, v0 = l0.split() except: -## print(l0) + ## print(l0) continue for l1 in lines1: - if not l1.startswith('config'): continue - if l1.startswith('step 1'): break + if not l1.startswith("config"): + continue + if l1.startswith("step 1"): + break try: r1, v1 = l1.split() except: continue if r1 == r0 and v1 != v0: - print("%s: %s -> %s" %(r0, v0, v1)) - + print("%s: %s -> %s" % (r0, v0, v1)) diff --git a/standalone_scripts/dumbBandPlotter.py b/standalone_scripts/dumbBandPlotter.py index bd39bc9..feb1e37 100644 --- a/standalone_scripts/dumbBandPlotter.py +++ b/standalone_scripts/dumbBandPlotter.py @@ -7,10 +7,9 @@ col = eval(sys.argv[3]) a = np.load(dataFile) -plt.plot(np.arange(a.shape[0]), a[:,row, col],'.', ms=1) +plt.plot(np.arange(a.shape[0]), a[:, row, col], ".", ms=1) plt.xlabel("event") plt.ylabel("Raw") -title = "pixel %d,%d in %s" %(row, col, dataFile) +title = "pixel %d,%d in %s" % (row, col, dataFile) plt.title(title) -plt.savefig(title.replace(" ","_") + ".png") - +plt.savefig(title.replace(" ", "_") + ".png") diff --git a/standalone_scripts/dumpPVs.py b/standalone_scripts/dumpPVs.py index 90c413f..3a04800 100644 --- a/standalone_scripts/dumpPVs.py +++ b/standalone_scripts/dumpPVs.py @@ -4,10 +4,10 @@ exp = sys.argv[1] run = eval(sys.argv[2]) -pvList = sys.argv[3].split(',') -allNames = pvList.join('_') +pvList = sys.argv[3].split(",") +allNames = pvList.join("_") -detList = [DataSource(exp=exp,run=run,intg_det=pv) for pv in pvList] +detList = [DataSource(exp=exp, run=run, intg_det=pv) for pv in pvList] data = [[]] * len(pvList) myrun = next(ds.runs()) while True: @@ -17,5 +17,4 @@ for n, ds in enumerate(dsList): data[n].append(det(evt)) -np.save("%s_r%d_PVs_%s.npy" %(exp, run, allNames), np.array(data)) - +np.save("%s_r%d_PVs_%s.npy" % (exp, run, allNames), np.array(data)) diff --git a/standalone_scripts/nonBasicScript.py b/standalone_scripts/nonBasicScript.py index 338d679..72438d8 100644 --- a/standalone_scripts/nonBasicScript.py +++ b/standalone_scripts/nonBasicScript.py @@ -7,15 +7,15 @@ try: special = sys.argv[3] except: - special = '' + special = "" -ds = DataSource(exp=exp,run=run,intg_det='epixhr') +ds = DataSource(exp=exp, run=run, intg_det="epixhr") myrun = next(ds.runs()) -det = myrun.Detector('epixhr') +det = myrun.Detector("epixhr") try: - digIn = myrun.Detector('ePixHR_Dig_in') - anaIn = myrun.Detector('ePixHR_Ana_in') + digIn = myrun.Detector("ePixHR_Dig_in") + anaIn = myrun.Detector("ePixHR_Ana_in") except: digIn = anaIn = None @@ -38,26 +38,26 @@ pass try: - pedestals = det.calibconst['pedestals'][0] + pedestals = det.calibconst["pedestals"][0] lowPed = pedestals[2] print("pedestal:", pedestals) print("pedestal mean, std") print(lowPed.mean(), lowPed.std()) - if 'pedestal' in special: - np.save("pedestals_%d.npy" %(run), pedestals) - + if "pedestal" in special: + np.save("pedestals_%d.npy" % (run), pedestals) + except: print("no pedestal") try: - gains = det.calibconst['pixel_gain'][0] - print(gains.mean(axis=(1,2,3))) + gains = det.calibconst["pixel_gain"][0] + print(gains.mean(axis=(1, 2, 3))) except: print("no gain: pain") try: - print('dig:', digIn(evt)) - print('ana:', anaIn(evt)) + print("dig:", digIn(evt)) + print("ana:", anaIn(evt)) except: print("no PV") - + break diff --git a/standalone_scripts/plotWave8.py b/standalone_scripts/plotWave8.py index f889d1f..b88532d 100755 --- a/standalone_scripts/plotWave8.py +++ b/standalone_scripts/plotWave8.py @@ -2,19 +2,18 @@ import sys import matplotlib.pyplot as plt -data = np.load(sys.argv[1]) +data = np.load(sys.argv[1]) if True: - ######plot amplitude vs time yscale = data.max() - sumData = data.sum(axis=1)## right axis? + sumData = data.sum(axis=1) ## right axis? xavierOrder = [15, 8, 14, 13, 12, 9, 10, 11] xavierPosition = [1, 5, 21, 25, 8, 14, 18, 12] - t_s = range(data.shape[0])##right axis? - mksize=1 + t_s = range(data.shape[0]) ##right axis? + mksize = 1 for k in [1, 2, 3]: plt.figure(k) scale = yscale @@ -23,37 +22,33 @@ scale = 0.2 label = "Normalized " for i in range(8): - plt.subplot(5,5,xavierPosition[i]) - if k!=3: - plt.plot(t_s,data[:,xavierOrder[i]],'.b', markersize=mksize) + plt.subplot(5, 5, xavierPosition[i]) + if k != 3: + plt.plot(t_s, data[:, xavierOrder[i]], ".b", markersize=mksize) else: - plt.plot(sumData,data[:,xavierOrder[i]],'.b', markersize=mksize) - plt.title('Diode %d' %(xavierOrder[i])) - plt.ylim(0,scale) - if k!=3: - plt.suptitle('%sFlux Wave8 VS time (s)' %(label)) + plt.plot(sumData, data[:, xavierOrder[i]], ".b", markersize=mksize) + plt.title("Diode %d" % (xavierOrder[i])) + plt.ylim(0, scale) + if k != 3: + plt.suptitle("%sFlux Wave8 VS time (s)" % (label)) else: plt.suptitle("Flux Wave8 vs total") - - - plt.figure(4) - plt.plot(t_s, sumData,'.b', markersize=mksize) - plt.title('Sum of all Wave8 tiles VS event') -# plt.show() + plt.plot(t_s, sumData, ".b", markersize=mksize) + plt.title("Sum of all Wave8 tiles VS event") + # plt.show() plt.figure(5) for i in range(8): - plt.subplot(8,1,i+1) - plt.hist(data[:, i+8],100) - plt.ylabel('Diode %d' %(i+8)) + plt.subplot(8, 1, i + 1) + plt.hist(data[:, i + 8], 100) + plt.ylabel("Diode %d" % (i + 8)) plt.figure(6) for i in range(8): - plt.subplot(8,1,i+1) - plt.hist(data[:, i+8],1000) - plt.ylabel('Diode norm should not matter %d' %(i+8)) + plt.subplot(8, 1, i + 1) + plt.hist(data[:, i + 8], 1000) + plt.ylabel("Diode norm should not matter %d" % (i + 8)) plt.show() - diff --git a/standalone_scripts/roiCombinationExample.py b/standalone_scripts/roiCombinationExample.py index e1c6aa5..7f98fae 100755 --- a/standalone_scripts/roiCombinationExample.py +++ b/standalone_scripts/roiCombinationExample.py @@ -2,8 +2,7 @@ import copy a = np.load("roiFromSwitched_e550_rmfxx1005021.npy") -b = copy.copy(a)*0 +b = copy.copy(a) * 0 b[0, 150:250, 150:250] = 1 c = np.bitwise_and(a, b) np.save("maskedRoiFromSwitched_e550_rmfxx1005021.npy", c) - diff --git a/standalone_scripts/seabornTest.py b/standalone_scripts/seabornTest.py index dc2d7cc..6dc7083 100644 --- a/standalone_scripts/seabornTest.py +++ b/standalone_scripts/seabornTest.py @@ -12,23 +12,23 @@ if mode == 0: sns.regplot(x=x, y=y, x_bins=10, fit_reg=None) plt.show() -elif mode==1: +elif mode == 1: fig, ax = plt.subplots() sns.regplot(x=x, y=y, x_bins=10, fit_reg=None) plt.show() -elif mode==2: +elif mode == 2: fig, ax = plt.subplots() - sns.regplot(x=x, y=y, x_bins=10, fit_reg=None,ax=ax) + sns.regplot(x=x, y=y, x_bins=10, fit_reg=None, ax=ax) y = np.random.normal(x**2, np.abs(x) + 2) - sns.regplot(x=x, y=y, x_bins=10, fit_reg=None,ax=ax) + sns.regplot(x=x, y=y, x_bins=10, fit_reg=None, ax=ax) plt.show() -elif mode==3: +elif mode == 3: fig, ax = plt.subplots() sns.regplot(x=x, y=y, x_bins=10, ax=ax) y = np.random.normal(x**2, np.abs(x) + 2) sns.regplot(x=x, y=y, x_bins=10, ax=ax) plt.show() -elif mode==4: +elif mode == 4: fig, ax = plt.subplots() sns.regplot(x=x, y=y, x_bins=10, ax=ax) x = np.random.uniform(0, 2, 10000) diff --git a/standalone_scripts/simpler_epixhr.py b/standalone_scripts/simpler_epixhr.py index ad308a7..62fecfd 100644 --- a/standalone_scripts/simpler_epixhr.py +++ b/standalone_scripts/simpler_epixhr.py @@ -3,57 +3,60 @@ import numpy as np import sys + expt = sys.argv[1] run = eval(sys.argv[2]) -ds = DataSource(exp='%s' %(expt), run=run) +ds = DataSource(exp="%s" % (expt), run=run) myrun = next(ds.runs()) -det = myrun.Detector('epixhr') - +det = myrun.Detector("epixhr") from psmon import publish import psmon.plots as plots -from psmon.plotting import Histogram,LinePlot,Image -publish.local=True +from psmon.plotting import Histogram, LinePlot, Image + +publish.local = True publish.plot_opts.aspect = 1 print(ds) -tim = myrun.Detector('timing') +tim = myrun.Detector("timing") try: - scan = myrun.Detector('scan') + scan = myrun.Detector("scan") print(vars(scan)) except: pass -def dump1(arr,title,nx,start): - print(f'{title} [{nx}]') - s = '' - for i in range(start,start+nx): - s += ' {:04x}'.format(arr[i]) - if i%16==15: - s += '\n' + +def dump1(arr, title, nx, start): + print(f"{title} [{nx}]") + s = "" + for i in range(start, start + nx): + s += " {:04x}".format(arr[i]) + if i % 16 == 15: + s += "\n" print(s) - return start+nx + return start + nx + def dump2(arr): for i in range(arr.shape[0]): - s = '' + s = "" for j in range(arr.shape[1]): - s += ' {:04x}'.format(arr[i][j]) - if j%16==15: - s += '\n' + s += " {:04x}".format(arr[i][j]) + if j % 16 == 15: + s += "\n" print(s) + ppid = 0 -detName = 'epixhr' +detName = "epixhr" -for nstep,step in enumerate(myrun.steps()): +for nstep, step in enumerate(myrun.steps()): - for nevt,evt in enumerate(step.events()): - if nevt==0: - print(f'step {nstep}') + for nevt, evt in enumerate(step.events()): + if nevt == 0: + print(f"step {nstep}") dump_det_config(det, detName) - dump_det_config(det, detName+'hw') - + dump_det_config(det, detName + "hw")