Esempio n. 1
0
def testForward(args, imageDim):
    path = args.path
    if path is None:
        path = "forward"
    if not os.path.exists(path):
        os.makedirs(path)
    stencil = RTM(imageDim, args.order, dtype=args.dtype)
    stencil.setTime(args.time)

    stencil.setB(args.nxb, args.nzb)
    stencil.computeTaper(0.75)
    stencil.taperx.tofile(os.path.join(path, "taperx.bin"))
    stencil.taperz.tofile(os.path.join(path, "taperz.bin"))

    stencil.coefx.tofile(os.path.join(path, "coefx.bin"))
    stencil.coefz.tofile(os.path.join(path, "coefz.bin"))

    src = np.random.rand(args.time).astype(stencil.dtype)
    # src = stencil.ricker_wavelet(15)
    src.tofile(os.path.join(path, "src_s0.bin"))
    src.tofile(os.path.join(path, "src.bin"))
    #np.savetxt(os.path.join(path, "src.txt"),src,  delimiter=',', fmt='%.5e')
    stencil.setSrc(args.nzb, imageDim[1] // 2, src)

    # v2dt2 = np.ones(imageDim).astype(stencil.dtype)
    v2dt2 = stencil.randImg() * 1e6
    stencil.setV(v2dt2)
    np.transpose(stencil.v2dt2).tofile(os.path.join(path, "v2dt2.bin"))

    if args.verify != 0:
        snap0, snap1, upb = stencil.forward()
        np.transpose(snap0).tofile(os.path.join(path, "snap0.bin"))
        np.transpose(snap1).tofile(os.path.join(path, "snap1.bin"))
        np.transpose(upb, (0, 2, 1)).tofile(os.path.join(path, "upb.bin"))
Esempio n. 2
0
def testBackward(args, imageDim):
    path = args.path
    if path is None:
        path = "backward"
    if not os.path.exists(path):
        os.makedirs(path)
    stencil = RTM(imageDim, args.order, dtype=args.dtype)
    stencil.setTime(args.time)

    stencil.setB(args.nxb, args.nzb)
    stencil.computeTaper(0.75)
    stencil.taperx.tofile(os.path.join(path, "taperx.bin"))
    stencil.taperz.tofile(os.path.join(path, "taperz.bin"))

    stencil.coefx.tofile(os.path.join(path, "coefx.bin"))
    stencil.coefz.tofile(os.path.join(path, "coefz.bin"))

    v2 = stencil.randImg() * 1e6
    # v2 = np.ones(imageDim).astype(stencil.dtype) * 1e6
    stencil.setV(v2)
    np.transpose(stencil.v2dt2).tofile(os.path.join(path, "v2dt2.bin"))

    sensor = np.random.rand(args.time, stencil.m_x -
                            2 * stencil.nxb).astype(stencil.dtype)
    np.transpose(sensor).tofile(os.path.join(path, "sensorT.bin"))
    sensor.tofile(os.path.join(path, "sensor_s0.bin"))
    sensor.tofile(os.path.join(path, "sensor.bin"))
    #np.savetxt(os.path.join(path, "sensor.txt"), sensor, delimiter=',', fmt='%.5e')
    stencil.setSensor(args.nzb, sensor)
    snap0 = stencil.randImg()
    snap1 = stencil.randImg()
    np.transpose(snap0).tofile(os.path.join(path, "snap0.bin"))
    np.transpose(snap1).tofile(os.path.join(path, "snap1.bin"))
    upb = np.random.rand(stencil.nt, args.order // 2,
                         stencil.m_x).astype(stencil.dtype)
    upb[stencil.nt - 2, :, :] = snap0[stencil.nzb -
                                      stencil.order // 2: stencil.nzb, :]
    upb[stencil.nt - 1, :, :] = snap1[stencil.nzb -
                                      stencil.order // 2: stencil.nzb, :]
    np.transpose(upb, (0, 2, 1)).tofile(os.path.join(path, "upb.bin"))

    if args.verify != 0:
        imloc, r0, r1, p0, p1 = stencil.backward(snap0, snap1, upb)
        np.transpose(imloc).tofile(os.path.join(path, "imloc.bin"))
        np.transpose(p0).tofile(os.path.join(path, "p0.bin"))
        np.transpose(p1).tofile(os.path.join(path, "p1.bin"))
        #np.savetxt(os.path.join(path, "p0.txt"), np.transpose(p0), delimiter=',', fmt='%.5e')
        #np.savetxt(os.path.join(path, "p1.txt"), np.transpose(p1), delimiter=',', fmt='%.5e')

        np.transpose(r0).tofile(os.path.join(path, "r0.bin"))
        np.transpose(r1).tofile(os.path.join(path, "r1.bin"))
Esempio n. 3
0
def testRTM(args, imageDim):
    path = args.path
    if path is None:
        path = "rtm"
    if not os.path.exists(path):
        os.makedirs(path)
    stencil = RTM(imageDim, args.order, dtype=args.dtype)
    stencil.setTime(args.time)

    stencil.setB(args.nxb, args.nzb)
    stencil.computeTaper(0.75)
    stencil.taperx.tofile(os.path.join(path, "taperx.bin"))
    stencil.taperz.tofile(os.path.join(path, "taperz.bin"))

    stencil.coefx.tofile(os.path.join(path, "coefx.bin"))
    stencil.coefz.tofile(os.path.join(path, "coefz.bin"))

    # src = [stencil.ricker_wavelet(15) for i in range(args.shot)]
    src = np.random.rand(args.shot, args.time).astype(stencil.dtype)
    for i in range(args.shot):
        src[i].tofile(os.path.join(path, "src_s%d.bin" % i))
    #np.savetxt(os.path.join(path, "src.txt"),src,  delimiter=',', fmt='%.5e')

    #v2dt2 = np.ones(imageDim).astype(stencil.dtype)
    v2dt2 = stencil.randImg() * 1e6
    stencil.setV(v2dt2)
    np.transpose(stencil.v2dt2).tofile(os.path.join(path, "v2dt2.bin"))

    sensor = np.random.rand(args.shot, args.time, stencil.m_x -
                            2 * stencil.nxb).astype(stencil.dtype)
    for i in range(args.shot):
        sensor[i].tofile(os.path.join(path, "sensor_s%d.bin" % i))

    if args.verify != 0:
        if not args.fsx:
            args.fsx = args.width // 2

        img = None
        for i in range(args.shot):

            stencil.setSrc(args.nzb, args.fsx + i * args.sp, src[i])
            stencil.setSensor(args.nzb, sensor[i])

            snap0, snap1, upb = stencil.forward()
            np.transpose(snap0).tofile(os.path.join(path, "snap0_s%d.bin" % i))
            np.transpose(snap1).tofile(os.path.join(path, "snap1_s%d.bin" % i))

            imloc, r0, r1, p0, p1 = stencil.backward(snap0, snap1, upb)

            if img is None:
                img = imloc
            else:
                img += imloc
            np.transpose(imloc).tofile(os.path.join(path, "imloc_s%d.bin" % i))
            np.transpose(p0).tofile(os.path.join(path, "p0_s%d.bin" % i))
            np.transpose(p1).tofile(os.path.join(path, "p1_s%d.bin" % i))
            #np.savetxt(os.path.join(path, "p0.txt"), np.transpose(p0), delimiter=',', fmt='%.5e')
            #np.savetxt(os.path.join(path, "p1.txt"), np.transpose(p1), delimiter=',', fmt='%.5e')

            np.transpose(r0).tofile(os.path.join(path, "r0_s%d.bin" % i))
            np.transpose(r1).tofile(os.path.join(path, "r1_s%d.bin" % i))
            #np.savetxt(os.path.join(path, "r0.txt"), np.transpose(r0), delimiter=',', fmt='%.5e')
            #np.savetxt(os.path.join(path, "r1.txt"), np.transpose(r1), delimiter=',', fmt='%.5e')
            del upb
            del snap0
            del snap1
            del imloc

        np.transpose(img).tofile(os.path.join(path, "imloc.bin"))