Пример #1
0
    # Load a 3D object
    beta = dxchange.read_tiff(
        'data/test-beta-128.tiff').astype('float32')[::2, ::2, ::2]
    delta = dxchange.read_tiff(
        'data/test-delta-128.tiff').astype('float32')[::2, ::2, ::2]

    # Create object.
    obj = objects.Object(beta, delta, voxelsize)
    # Create probe
    prb = objects.Probe(objects.gaussian(15, rin=0.8, rout=1.0), maxint=maxint)
    # Detector parameters
    det = objects.Detector(63, 63)
    # Define rotation angles
    theta = np.linspace(0, 2*np.pi, 400).astype('float32')
    # Scanner positions
    scanax, scanay = objects.scanner3(theta, beta.shape, 10, 10, margin=[
        prb.size, prb.size], offset=[0, 0], spiral=1)
    # tomography data shape
    tomoshape = [len(theta), obj.shape[0], obj.shape[2]]

    # Class solver
    slv = solver_gpu.Solver(prb, scanax, scanay,
                            theta, det, voxelsize, energy, tomoshape)

    def signal_handler(sig, frame):
        print('Remove class and free gpu memory')
        slv = []
        sys.exit(0)
    signal.signal(signal.SIGINT, signal_handler)
    signal.signal(signal.SIGTSTP, signal_handler)

    # Compute data  |FQ(exp(i\nu R x))|^2,
Пример #2
0
    # Load a 3D object
    beta0 = dxchange.read_tiff('data/beta-pad2-256.tiff')[42:42+16]#[32:32+16*bbin:bbin,::bbin,::bbin]#:2,::2,::2]
    delta0 = -dxchange.read_tiff('data/delta-pad2-256.tiff')[42:42+16]#[32:32+16*bbin:bbin,::bbin,::bbin]#:2,::2,::2]
    beta = np.zeros([2*prbsize+beta0.shape[0],beta0.shape[1],beta0.shape[2]],dtype='float32')
    delta = np.zeros([2*prbsize+beta0.shape[0],beta0.shape[1],beta0.shape[2]],dtype='float32')    
    beta[prbsize:-prbsize] = beta0
    delta[prbsize:-prbsize] = delta0
    # print(beta.shape)

    maxint = maxinta[igpu]
    if(maxint>0.9):
        noise = False
    obj = cp.array(delta+1j*beta)
    prb = cp.array(objects.probe(prbsize, maxint))#,rout=1.03))
    theta = cp.linspace(0, np.pi, ntheta).astype('float32')
    scan = cp.array(objects.scanner3(theta, obj.shape, prbshift,
                                    prbshift, prbsize, spiral=0, randscan=True, save=False)) 
    tomoshape = [len(theta), obj.shape[0], obj.shape[2]]

    # Class gpu solver 
    slv = solver.Solver(prb, scan, theta, det, voxelsize, energy, tomoshape, ptheta)
    # Free gpu memory after SIGINT, SIGSTSTP
    def signal_handler(sig, frame):
        slv = []
        sys.exit(0)
    signal.signal(signal.SIGINT, signal_handler)
    signal.signal(signal.SIGTSTP, signal_handler)

    # Compute data
    psi = slv.exptomo(slv.fwd_tomo(obj))
    data = np.zeros(slv.ptychoshape, dtype='float32')
    for k in range(0, ptheta):  # angle partitions in ptyocgraphy
Пример #3
0
    delta = dxchange.read_tiff('data/DELTA256.tiff')[32:64]

    for imaxint in range(0, len(maxinta)):
        for inoise in range(0, len(noisea)):
            maxint = maxinta[imaxint]
            noise = noisea[inoise]

            # Create object, probe, angles, scan positions
            obj = cp.array(delta + 1j * beta)
            prb = cp.array(objects.probe(prbsize, maxint))
            theta = cp.linspace(0, np.pi, ntheta).astype('float32')
            scan = cp.array(
                objects.scanner3(theta,
                                 obj.shape,
                                 prbshift,
                                 prbshift,
                                 prbsize,
                                 spiral=0,
                                 randscan=True,
                                 save=True))
            tomoshape = [len(theta), obj.shape[0], obj.shape[2]]

            # Class gpu solver
            slv = solver.Solver(prb, scan, theta, det, voxelsize, energy,
                                tomoshape)

            # Free gpu memory after SIGINT, SIGSTSTP
            def signal_handler(sig, frame):
                slv = []
                sys.exit(0)

            signal.signal(signal.SIGINT, signal_handler)