コード例 #1
0
    p = ProgressPlot()
    errors = []
    for i in range(60):
        print(i)
        W, Pjlk, timing = M(W, data, Nl=Nl, ml=ml, beta=fudge,
                            nproc=24,
                            roll_center=CENTER)
        [print(k, '%.3f'%v) for k, v in timing.items()]
        W, error = C(W, envelope)
        errors.append(error)
        p.update(np.log10(W), Pjlk, errors, vmax=1)

        # expand the resolution now and then
        if i and (Nj<Nj_max) and (i % increase_every) == 0:
            W = np.pad(W, ((2,2),(0,0),(0,0)))
            Nj = W.shape[0]
            Q3 = dq3 * Nj
            envelope = generate_envelope(Nj, data.shape[-1], Q=(Q3, Q12, Q12), Dmax=(Dmax, 1, 1), theta=theta)
            print('increased Nj to %u and Q3 to %.2e'%(Nj, Q3))
        if i and (fudge < fudge_max) and (i % increase_every) == 0:
            fudge *= 2**(1/2)
            print('increased fudge to %e'%(fudge))

    # assuming that we now know the q-range, we can interpolate to qx, qy, qz
    # the outermost q3 slices contain everything that couldn't be assigned well.
    oldshape = W.shape[0]
    Q3 = W.shape[0] / oldshape * Q3
    W_ortho, Qnew = rectify_sample(W, (Q3, Q12, Q12), theta)

    np.savez('assembled_%u.npz'%subset, W=W, W_ortho=W_ortho, Pjlk=Pjlk, rolls=rolls, Q_ortho=Qnew, Q=(Q3, Q12, Q12))
コード例 #2
0
resolutions = (2, 5, 8, 10, 15, 12, 20, 30, 50)
a2.set_xticks([2 * np.pi / dr for dr in resolutions])
a2.set_xticklabels(resolutions)
a2.set_xlim(a1.get_xlim())
np.savez('validation.npz',
         q=x,
         fsc=fsc,
         nri=nri,
         fsc_cut=fsc_cut,
         fsc_mix=fsc_mix)
#a1.legend()

# rectify the full reconstruction, save and plot
p, mask = load(folder + 'modes_10.h5', N)
#p = np.flip(p, axis=0)
p, psize = rectify_sample(p, (dr3, dr1, dr2), 15.0, find_order=True)  # x z y
np.savez('rectified.npz', data=p, psize=psize)

# plot along all three axes to understand the aspect ratio
fig, ax = plt.subplots(ncols=3)
ext = np.array((-psize / 2 * N, psize / 2 * N, -psize / 2 * N,
                psize / 2 * N)) * 1e9  # valid after the operations below
# from the front
ax[0].imshow(np.abs(p).sum(axis=0), extent=ext)
plt.setp(ax[0],
         xlim=[-50, 50],
         ylim=[-50, 50],
         title='front view',
         xlabel='y',
         ylabel='z')
# from the top
コード例 #3
0
        av = np.mean(np.angle(data[com[0], com[1], com[2]]))
        data[:] *= np.exp(-1j * av)
        av = np.mean(
            np.angle(data[com[0] - 2:com[0] + 2, com[1] - 2:com[1] + 2,
                          com[2] - 2:com[2] + 2, ]))
        data[:] *= np.exp(-1j * av)

    # manually shift the particle if needed
    if WHAT == OUTPUT:
        data = np.roll(data, axis=(1, 2), shift=(0, -1))
        data *= np.exp(1j * .1)
    elif WHAT == REGULAR:
        data = np.roll(data, axis=(0, 1, 2), shift=(-1, -1, -1))

    # now resample on the orthogonal grid
    data, psize = rectify_sample(data, dr, theta, interp=1, find_order=False)

    # cut out the good part
    N = 18
    a, b, c = data.shape
    data = data[a // 2 - N // 2:a // 2 + N // 2,
                b // 2 - N // 2:b // 2 + N // 2,
                c // 2 - N // 2:c // 2 + N // 2, ]

    ### silx 3D plot
    if False:
        # Create a SceneWindow widget in an app
        app = qt.QApplication([])
        window = SceneWindow()

        # Get the SceneWidget contained in the window and set its colors