point=psf_cen, direction=(0, 0, 1), voxel_size=voxel_size) linecuts_dict = OrderedDict([('width_z', width_z), ('width_y', width_y), ('width_x', width_x), ('cut_z', cut_z), ('cut_y', cut_y), ('cut_x', cut_x)]) # define the maximum identical length that can share the linecuts (we need to concatenate them) width_length = min(width_z.size, width_y.size, width_x.size) linecuts = np.empty( (6, width_length )) # rows 0:3 for the widths, rows 3:6 for the corresponding cuts idx = 0 for key in linecuts_dict.keys(): # order is maintained in OrderedDict linecuts[idx, :] = pu.crop_pad_1d( linecuts_dict[key], output_length=width_length) # implicit crop from the center idx += 1 # create nb_fit sets of parameters, one per data set fit_params = Parameters() for idx in range( 3): # 3 linecuts in orthogonal directions to be fitted by a gaussian fit_params.add('amp_%i' % (idx + 1), value=1, min=0.1, max=100) fit_params.add('cen_%i' % (idx + 1), value=linecuts[idx, :].mean(), min=linecuts[idx, :].min(), max=linecuts[idx, :].max()) fit_params.add('sig_%i' % (idx + 1), value=5, min=0.1, max=100) # run the global fit to all the data sets
################################ # optionally load the q values # ################################ if load_qvalues: file_path = filedialog.askopenfilename(initialdir=datadir, title="Select the q values", filetypes=[("NPZ", "*.npz")]) q_values = np.load(file_path) qx = q_values['qx'] qz = q_values['qz'] qy = q_values['qy'] print('Loaded: qx shape:', qx.shape, 'qz shape:', qz.shape, 'qy shape:', qy.shape) assert (*qx.shape, *qz.shape, *qy.shape) == data.shape, 'q values and data shape are incompatible' # crop the q values to the region of interest used in plots qx = pu.crop_pad_1d(array=qx, output_length=plot_range[0] + plot_range[1], crop_center=zcom) qz = pu.crop_pad_1d(array=qz, output_length=plot_range[2] + plot_range[3], crop_center=ycom) qy = pu.crop_pad_1d(array=qy, output_length=plot_range[4] + plot_range[5], crop_center=xcom) print('Cropped: qx shape:', qx.shape, 'qz shape:', qz.shape, 'qy shape:', qy.shape) q_range = (qx.min(), qx.max(), qz.min(), qz.max(), qy.min(), qy.max()) else: # crop the q values to the region of interest used in plots q_range = (0, plot_range[0] + plot_range[1], 0, plot_range[2] + plot_range[3], 0, plot_range[4] + plot_range[5]) print('q range:', [f'{val:.4f}' for val in q_range]) ############################################################# # define the positions of the axes ticks and colorbar ticks # ############################################################# # use 5 ticks by default if tick_spacing is None for the axis
initialdir=root_folder, title="Select original q values", filetypes=[("NPZ", "*.npz")]) q_values = np.load(file_path) qx = q_values['qx'] # 1D array qy = q_values['qy'] # 1D array qz = q_values['qz'] # 1D array # crop q to accomodate a shape change of the original array (e.g. cropping to fit FFT shape requirement) if qvalues_binned: assert len(qx) >= pynx_shape[ 0], 'qx declared binned, its length should be >= pynx_shape[0]' assert len(qy) >= pynx_shape[ 2], 'qy declared binned, its length should be >= pynx_shape[2]' assert len(qz) >= pynx_shape[ 1], 'qz declared binned, its length should be >= pynx_shape[1]' qx = pu.crop_pad_1d(qx, pynx_shape[0]) # qx along z qy = pu.crop_pad_1d(qy, pynx_shape[2]) # qy along x qz = pu.crop_pad_1d(qz, pynx_shape[1]) # qz along y else: assert len(qx) >= unbinned_shape[ 0], 'qx declared unbinned, its length should be >= unbinned_shape[0]' assert len(qy) >= unbinned_shape[ 2], 'qy declared unbinned, its length should be >= unbinned_shape[2]' assert len(qz) >= unbinned_shape[ 1], 'qz declared unbinned, its length should be >= unbinned_shape[1]' qx = pu.crop_pad_1d(qx, unbinned_shape[0]) # qx along z qy = pu.crop_pad_1d(qy, unbinned_shape[2]) # qy along x qz = pu.crop_pad_1d(qz, unbinned_shape[1]) # qz along y print('Length(q_original)=', len(qx), len(qz), len(qy), '(qx, qz, qy)') voxelsize_z = 2 * np.pi / (qx.max() - qx.min()) # qx along z