sum_frames=True, sum_axis=1, plot_colorbar=True, reciprocal_space=False, vmin=0, vmax=np.nan, is_orthogonal=True, ) gu.savefig( savedir=savedir, figure=fig, axes=axs, tick_width=tick_width, tick_length=tick_length, tick_labelsize=14, xlabels=axs.get_xlabel(), ylabels=axs.get_ylabel(), titles=axs.get_title(), label_size=16, filename=f"roi{roi}" + comment, ) comment = comment + f"_{angular_step}deg" result = {} ######################################################### # 3D case (BCDI): loop over thresholds first # # (the threshold needs to be applied before projecting) # ######################################################### if ndim == 3:
plot_nb += 1 if cuts_limits is not None: ax.set_xlim(left=cuts_limits[0], right=cuts_limits[1]) ax.set_ylim(bottom=cuts_limits[2], top=cuts_limits[3]) legend = False if plot_nb < 15: legend = True gu.savefig(savedir=savedir, figure=fig, axes=ax, tick_width=tick_width, tick_length=tick_length, tick_labelsize=16, xlabels='width (nm)', ylabels='modulus', label_size=20, legend=legend, legend_labelsize=14, filename='cuts' + comment, only_labels=False) ################################################################################# # calculate the evolution of the width of the object depending on the threshold # ################################################################################# idx_point = 0 for key, value in result.items(): # loop over the linecuts fit = interp1d(value['distance'], value['cut']) dist_interp = np.linspace(value['distance'].min(), value['distance'].max(),
gu.savefig( savedir=savedir, figure=fig, axes=ax, tick_width=2, tick_length=10, tick_labelsize=14, label_size=16, xlabels="q (1/nm)", ylabels="PRTF", filename=f"S{scan}_prtf" + comment, text={ 0: { "x": 0.15, "y": 0.30, "s": "Scan " + str(scan) + comment, "fontsize": 16 }, 1: { "x": 0.15, "y": 0.25, "s": f"q at PRTF=1/e: {q_resolution:.5f} (1/nm)", "fontsize": 16, }, 2: { "x": 0.15, "y": 0.20, "s": f"resolution d = {2*np.pi / q_resolution:.3f} nm", "fontsize": 16, }, }, )
extent=[q_range[4], q_range[5], q_range[3], q_range[2]], ) ax0.invert_yaxis() # qz is pointing up ax0.xaxis.set_major_locator(ticker.MultipleLocator(tick_spacing[2])) ax0.yaxis.set_major_locator(ticker.MultipleLocator(tick_spacing[1])) gu.colorbar(plt0, numticks=numticks_colorbar, pad=cbar_pad) gu.savefig( savedir=savedir, figure=fig, axes=ax0, tick_width=tick_width, tick_length=tick_length, tick_direction=tick_direction, label_size=16, xlabels=labels[2], ylabels=labels[1], filename=sample_name + str(scan) + comment + "_fromrec_qyqz", labelbottom=draw_ticks, labelleft=draw_ticks, labelright=False, labeltop=False, left=draw_ticks, right=draw_ticks, bottom=draw_ticks, top=draw_ticks, ) ############################ # plot views in QyQx plane # ############################ if save_qyqx: fig, ax0 = plt.subplots(1, 1, figsize=(9, 6))
scale=plot_scale, vmin=vmin, vmax=vmax, reciprocal_space=False, is_orthogonal=is_orthogonal, plot_colorbar=True, ) gu.savefig( savedir=savedir, figure=fig, axes=ax, tick_width=tick_width, tick_length=tick_length, tick_labelsize=16, xlabels=labels[0][0], ylabels=labels[0][1], label_size=20, titles=fname + " central slice in " + labels[0][2], title_size=20, legend_labelsize=14, filename=fname + "_centralslice_z" + comment, ) fig, ax, _ = gu.imshow_plot( dataset[:, cen_y, :], sum_frames=False, width_v=2 * width[0], width_h=2 * width[2], scale=plot_scale, vmin=vmin,
iterator=idx, x_axis=fit_x_axis, distribution='gaussian') line, = axes_dict[idx][0].plot(fit_x_axis, y_fit, 'b-') sig_name = f'sig_{idx+1}' line.set_label( f'fit, FWHM={2*np.sqrt(2*np.log(2))*minimization.params[sig_name].value:.2f}nm' ) gu.savefig(savedir=savedir, figure=fig, axes=(ax0, ax1, ax2), tick_width=tick_width, tick_length=tick_length, tick_labelsize=16, xlabels='width (nm)', ylabels='psf (a.u.)', label_size=20, legend=True, legend_labelsize=14, filename=f'cuts_{rl_iterations}' + comment, only_labels=False) ################ # save the psf # ################ np.savez_compressed(savedir + f'psf_{rl_iterations}' + comment + '.npz', psf=psf_partial_coh, nb_iter=rl_iterations, isosurface_threshold=isosurface_threshold, upsampling_factor=upsampling_factor)
gu.savefig(savedir=detector.savedir, figure=fig, axes=ax, tick_width=2, tick_length=10, tick_labelsize=14, label_size=16, xlabels='q (1/nm)', ylabels='PRTF', filename=f'S{scan}_prtf' + comment, text={ 0: { 'x': 0.15, 'y': 0.30, 's': "Scan " + str(scan) + comment, 'fontsize': 16 }, 1: { 'x': 0.15, 'y': 0.25, 's': f"q at PRTF=1/e: {q_resolution:.5f} (1/nm)", 'fontsize': 16 }, 2: { 'x': 0.15, 'y': 0.20, 's': f"resolution d = {2*np.pi / q_resolution:.3f} nm", 'fontsize': 16 } })
if plot_sem == 'fill': title = f"fill between SEM_thres {sem_dict['threshold'][0]} and {sem_dict['threshold'][-1]}" else: title = '' legend = False if len(thres_bcdi) < 10: legend = True gu.savefig(savedir=savedir, figure=fig, axes=ax0, tick_width=tick_width, tick_length=tick_length, label_size=16, xlabels='angle (deg)', ylabels='width (nm)', filename='compa_width_vs_ang' + comment, titles=title, legend=legend, legend_labelsize=12) ############################################################################################################## # Plot the evolution of the Pearson correlation coefficient and squared residuals depending on the threshold # ############################################################################################################## min_thres_idx = np.unravel_index(residuals.argmin(), shape=residuals.shape)[0] fig, ax0 = plt.subplots(nrows=1, ncols=1, figsize=(12, 9)) ax0.plot(thres_bcdi, correlation, color='b', marker='.',
obj[np.isnan(obj)] = 0 # remove nans fig, axs, _ = gu.imshow_plot(array=obj, sum_frames=True, sum_axis=1, plot_colorbar=True, reciprocal_space=False, vmin=0, vmax=np.nan, is_orthogonal=True) gu.savefig(savedir=savedir, figure=fig, axes=axs, tick_width=tick_width, tick_length=tick_length, tick_labelsize=14, xlabels=axs.get_xlabel(), ylabels=axs.get_ylabel(), titles=axs.get_title(), label_size=16, filename=f'roi{roi}' + comment) comment = comment + f'_{angular_step}deg' result = dict() #################################################################################################### # 3D case (BCDI): loop over thresholds first (the threshold needs to be applied before projecting) # #################################################################################################### if ndim == 3: # remove the voxel size along the projection axis voxel_size = list(voxel_size)
if cuts_limits is not None: ax.set_xlim(left=cuts_limits[0], right=cuts_limits[1]) ax.set_ylim(bottom=cuts_limits[2], top=cuts_limits[3]) legend = False if plot_nb < 15: legend = True gu.savefig( savedir=savedir, figure=fig, axes=ax, tick_width=tick_width, tick_length=tick_length, tick_labelsize=16, xlabels="width (nm)", ylabels="modulus", label_size=20, legend=legend, legend_labelsize=14, filename="cuts" + comment, only_labels=False, ) ################################################################################# # calculate the evolution of the width of the object depending on the threshold # ################################################################################# idx_point = 0 for key, value in result.items(): # loop over the linecuts fit = interp1d(value["distance"], value["cut"]) dist_interp = np.linspace(value["distance"].min(),
title = (f"fill between SEM_thres {sem_dict['threshold'][0]} " f"and {sem_dict['threshold'][-1]}") else: title = "" legend = False if len(thres_bcdi) < 10: legend = True gu.savefig( savedir=savedir, figure=fig, axes=ax0, tick_width=tick_width, tick_length=tick_length, label_size=16, xlabels="angle (deg)", ylabels="width (nm)", filename="compa_width_vs_ang" + comment, titles=title, legend=legend, legend_labelsize=12, ) ############################################################# # Plot the evolution of the Pearson correlation coefficient # # and squared residuals depending on the threshold # ############################################################# min_thres_idx = np.unravel_index(residuals.argmin(), shape=residuals.shape)[0] fig, ax0 = plt.subplots(nrows=1, ncols=1, figsize=(12, 9)) ax0.plot( thres_bcdi,