df, filenames = ut.analysis.get_data_daq(fname, daq_labels, sacla_converter, t0=0, selection=sel) # get laser on/off tags is_laser_on_tags = df[df.is_laser == 1].index.tolist() is_laser_off_tags = df[df.is_laser == 0].index.tolist() # get spectra from Von Hamos, using laser on / off tags #roi = [[0, 1024], [325, 335]] # X, Y ap = ImagesProcessor(facility="SACLA") ap.add_analysis('get_projection', args={"axis": 1}) ap.add_analysis('get_mean_std') ap.set_dataset('/run_%s/detector_2d_1' % run) ap.add_preprocess("set_thr", args={"thr_low": 65}) # get the total spectra results_on = ap.analyze_images(fname, tags=is_laser_on_tags) spectrum_on = results_on["get_projection"]["spectra"].sum(axis=0) results_off = ap.analyze_images(fname, tags=is_laser_off_tags) spectrum_off = results_off["get_projection"]["spectra"].sum(axis=0) spectrum_off = spectrum_off / spectrum_off.sum() spectrum_on = spectrum_on / spectrum_on.sum() # this is the average image from the Von Hamos sum_image_on = results_on["get_mean_std"]["images_mean"] # Plot! plt.subplot(1, 2, 1) plt.imshow(sum_image_on) plt.subplot(1, 2, 2) plt.plot(spectrum_off, label="laser off")
# add analysis an.add_analysis("get_projection", args={'axis': 1, 'thr_low': thr,}) an.add_analysis("get_mean_std", args={'thr_low': thr}) bins = np.arange(-150, 300, 5) an.add_analysis("get_histo_counts", args={'bins': bins}) an.add_analysis(get_line_histos, args={'axis': 0, 'bins': bins}) # set the dataset an.set_dataset(dataset_name) # add preprocess steps #an.add_preprocess("image_set_roi", args={'roi': roi}) #an.add_preprocess("image_set_thr", thr_low=thr) # run the analysis results = an.analyze_images(fname, n=1000) # plot plt.figure(figsize=(7, 7)) plt.plot(np.nansum(results["spectra"], axis=0), label="ADU > " + str(thr)) plt.legend(loc='best') #plt.show() plt.figure(figsize=(7, 7)) plt.bar(bins[:-1], results["histo_counts"], log=True, width=5) #plt.show() plt.figure(figsize=(15, 10)) plt.subplot(121) plt.imshow(results["histo_counts_line"], vmin=0, vmax=3,