Exemplo n.º 1
0
 def _determine_center_and_radius(data , manual=False, size=25):
     sh = np.concatenate([data.scan_dimensions,data.frame_dimensions])
     c = np.zeros((2,))
     c[:] = (sh[-1] // 2, sh[-2] // 2)
     c = cp.array(c)
     radius = cp.ones((1,)) * sh[-1] // 2
     inds = cp.array(data.indices[:size, :size].astype(cp.uint32))
     cts = cp.array(data.counts[:size, :size].astype(cp.uint32))
     dc_subset = sparse_to_dense_datacube_crop(inds,cts, (size,size), data.frame_dimensions, c, radius, bin=2)
     dcs = cp.sum(dc_subset, (0, 1))
     m1 = dcs.get()
     m = (gaussian(m1.astype(cp.float32),2) > m1.max() * 3e-1).astype(cp.float)
     r, y0, x0 = get_probe_size(m)
     return 2 * np.array([y0,x0]), r*2
def define_bf_disk(dp, proc_dict):
    #define bf disk
    #get threshold values
    if 'BF_thresh_low' in proc_dict:
        bf_thresh_low = proc_dict['BF_thresh_low']
    else:
        bf_thresh_low = 0.01

    if 'BF_thresh_high' in proc_dict:
        bf_thresh_high = proc_dict['BF_thresh_high']
    else:
        bf_thresh_high = 0.05

    #print(bf_thresh)
    #bf= fs.get_bf_disk(dp, sub = 20, threshold = bf_thresh, plot_me = True)
    #build PACBED from every 10th diff pattern
    PACBED = np.average(dp.data[::10, ::10, :, :], axis=(0, 1))
    r, x0, y0 = get_probe_size(PACBED,
                               thresh_lower=bf_thresh_low,
                               thresh_upper=bf_thresh_high)
    bf = [r, x0, y0]
    bf_exist = 1
    return bf, bf_exist
Exemplo n.º 3
0
power = 0.1

PACBED = np.average(dc.data4D[::10, ::10, :, :],axis=(0,1))

# Show
fig,ax = plt.subplots(figsize=(8,8,))
ax.matshow(PACBED**power)
plt.show()
#%%

thresh_lower = 0.01
thresh_upper =0.05#PACBED.mean() / PACBED.max() #  0.01
N = 100

r,x0,y0 = get_probe_size(PACBED, thresh_lower=thresh_lower, thresh_upper=thresh_upper, N=N)

# Show
fig,ax = plt.subplots(figsize=(8,8))
ax.matshow(PACBED**power)
ax.scatter(y0,x0,color='r',s=10)
circle = Circle((y0,x0),r,fill=False,edgecolor='r',linewidth=1)
ax.add_patch(circle)
plt.show()





# Get mask