コード例 #1
0
# define surface gradient using a conjugate support #
#####################################################
# this support is 1 outside, 0 inside so that the gradient points towards exterior
support = np.ones((nz, ny, nx))
support[abs(amp) > support_threshold * abs(amp).max()] = 0
zCOM, yCOM, xCOM = center_of_mass(support)
print("COM at (z, y, x): (", str('{:.2f}'.format(zCOM)), ',', str('{:.2f}'.format(yCOM)), ',',
      str('{:.2f}'.format(xCOM)), ')')
gradz, grady, gradx = np.gradient(support, 1)  # support

############################################
# define the support, surface layer & bulk #
############################################
support = np.zeros(amp.shape)
support[abs(amp) > support_threshold * abs(amp).max()] = 1
coordination_matrix = pu.calc_coordination(support, kernel=np.ones((3, 3, 3)), debugging=False)
surface = np.copy(support)
surface[coordination_matrix > 22] = 0  # remove the bulk 22
bulk = support - surface
del coordination_matrix
gc.collect()

########################################################
# define edges using the coordination number of voxels #
########################################################
edges = pu.calc_coordination(support, kernel=np.ones((9, 9, 9)), debugging=False)
edges[support == 0] = 0
if debug:
    gu.multislices_plot(edges, invert_yaxis=True, vmin=0, title='Coordination matrix')
edges[edges > edges_coord] = 0  # remove facets and bulk
edges[np.nonzero(edges)] = 1  # edge support
コード例 #2
0
        voxel_size)  # q is along x after rotating the crystal
elif ref_axis_outplane == "y":
    _, strain, _ = np.gradient(
        planar_dist / (2 * np.pi) * phase,
        voxel_size)  # q is along y after rotating the crystal
elif ref_axis_outplane == "z":
    strain, _, _ = np.gradient(
        planar_dist / (2 * np.pi) * phase,
        voxel_size)  # q is along y after rotating the crystal
else:  # default is ref_axis_outplane = "y"
    _, strain, _ = np.gradient(
        planar_dist / (2 * np.pi) * phase,
        voxel_size)  # q is along y after rotating the crystal

# remove the outer layer of support for saving, because strain is undefined there
coordination_matrix = pu.calc_coordination(support, debugging=debug)
surface = np.copy(support)
surface[coordination_matrix > 23] = 0  # remove the bulk 22
bulk = support - surface
bulk[np.nonzero(bulk)] = 1

if debug and not flat_phase:
    gu.multislices_plot(
        surface,
        sum_frames=False,
        plot_colorbar=False,
        width_z=200,
        width_y=200,
        width_x=200,
        vmin=0,
        vmax=1,
コード例 #3
0
######################################
# define the support, surface & bulk #
######################################
support = np.zeros(amp.shape)
support[amp > support_threshold * amp.max()] = 1

# gu.multislices_plot(support, sum_frames=False, is_orthogonal=True, reciprocal_space=False)
# thres = 0.65
# support2 = np.zeros(amp.shape)
# support2[amp > thres*amp.max()] = 1
# print(f"Number of voxel excluded with thres={thres}: {(support - support2).sum()}")
# gu.multislices_plot(support - support2, sum_frames=False, is_orthogonal=True, reciprocal_space=False)

coordination_matrix = pu.calc_coordination(support=support,
                                           kernel=np.ones((3, 3, 3)),
                                           debugging=debug)
surface = np.copy(support)
surface[coordination_matrix > 22] = 0  # remove the bulk 22
bulk = support - surface
nb_surface = len(np.nonzero(surface)[0])
nb_bulk = len(np.nonzero(bulk)[0])
print("Number of surface points = ", str(nb_surface))
print("Number of bulk points = ", str(nb_bulk))
if debug:
    gu.multislices_plot(surface,
                        sum_frames=False,
                        plot_colorbar=True,
                        cmap=my_cmap,
                        title='Surface layer',
                        scale='linear',