Example #1
0
# load the data #
#################
plt.ion()
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename(initialdir=datadir,
                                       filetypes=[("NPZ", "*.npz"),
                                                  ("NPY", "*.npy"),
                                                  ("CXI", "*.cxi"),
                                                  ("HDF5", "*.h5"),
                                                  ("all files", "*.*")])

_, ext = os.path.splitext(file_path)
if ext in {'.png', '.jpg', '.tif'}:
    obj = util.image_to_ndarray(filename=file_path,
                                convert_grey=True,
                                cmap='gray',
                                debug=False)
else:
    obj, _ = util.load_file(file_path)
ndim = obj.ndim

#########################
# check some parameters #
#########################
valid_name = 'bcdi_line_profile'
if ndim not in {2, 3}:
    raise ValueError(f'Number of dimensions = {ndim}, expected 2 or 3')

valid.valid_container(direction,
                      container_types=(list, tuple, np.ndarray),
                      length=ndim,
Example #2
0
plt.ion()
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename(
    initialdir=datadir,
    filetypes=[
        ("NPZ", "*.npz"),
        ("NPY", "*.npy"),
        ("CXI", "*.cxi"),
        ("HDF5", "*.h5"),
        ("all files", "*.*"),
    ],
)
_, ext = os.path.splitext(file_path)
if ext in {".png", ".jpg", ".tif"}:
    obj = util.image_to_ndarray(filename=file_path, convert_grey=True)
else:
    obj, _ = util.load_file(file_path)

obj = abs(obj)
ndim = obj.ndim
if isinstance(voxel_size, Real):
    voxel_size = (voxel_size, ) * ndim

print(f"Object shape = {obj.shape}, voxel size = {voxel_size}")
if upsampling_factor > 1:
    obj, voxel_size = fu.upsample(
        array=obj,
        upsampling_factor=upsampling_factor,
        voxelsizes=voxel_size,
        title="modulus",