Ejemplo n.º 1
0
Archivo: 7ab.py Proyecto: jcapriot/src
def main(argv=sys.argv):

    nt = 300
    nx = 64
    nz = 300
    nb = 50
    v = 1.0
    top = 3.2
    c1 = 0.9
    c2 = 6.8
    d1 = 0.02
    d2 = 0.12

    par = m8r.Par(argv)

    top = par.float('top', 5.0)
    c1 = par.float('c1', 0.5)
    c2 = par.float('c2', 5.0)

    vp = vplot.Vplot()

    vp.uorig(-c1, -.5)
    vp.uclip(0., top - 3., 4., top)
    vp.umove(0., top - 0.)
    vp.udraw(0., top - 4.)
    vp.umove(0., top - 0.)
    vp.udraw(4., top - 0.)

    z = 0.4
    while z < 4:
        vp.penup()
        x0 = z * math.tan(math.pi * 45. / 180.)
        x = 0
        while x < 4:
            t = math.hypot(z, x - x0) / v
            vp.upendn(x, top - t)
            x += 0.01
        z += 0.4

    b = numpy.zeros(nb, 'f')
    for ib in xrange(nb):
        b[ib] = math.exp(-3. * (ib + 1.) / 20.) * math.sin(math.pi *
                                                           (ib + 1) / 10)

    cs = par.string('c')
    if cs:
        c = m8r.Output('c')
        c.setformat('native_float')
        c.put('n1', nt)
        c.put('n2', nx)
        c.put('d1', d1)
        c.put('d2', d2)

        tdat = numpy.zeros((nx, nt), 'f')

        for iz in range(12):
            z = (iz + 1.) * nt / 12.
            x0 = z * math.tan(math.pi * 45. / 180.)
            for ix in xrange(nx):
                x = (ix + 1.) * d2 / d1
                t = math.hypot(z, x - x0) / v
                for ib in xrange(nb):
                    it = t + ib - 1
                    if it < nt:
                        tdat[ix, it] += b[ib]
        c.write(tdat)

    vp.uorig(-c2, -.5)
    vp.uclip(0., top - 3., 4., top)
    vp.umove(0., top - 0.)
    vp.udraw(0., top - 4.)
    vp.umove(0., top - 0.)
    vp.udraw(4., top - 0.)

    t = 0.4
    while t < 6:
        vp.penup()
        x0 = t / math.sin(math.pi * 45. / 180.)
        theta = -89.5
        while theta < 89.5:
            z = t * math.cos(math.pi * theta / 180)
            x = x0 + t * math.sin(math.pi * theta / 180)
            vp.upendn(x, top - z)
            theta += 1
        t += 0.4

    ds = par.string('d')
    if ds:
        d = m8r.Output('d')
        d.setformat('native_float')
        d.put('n1', nz)
        d.put('n2', nx)
        d.put('d1', d1)
        d.put('d1', d2)

        zdat = numpy.zeros([nx, nz], 'f')

        for it in range(20):
            t = (it + 1.) * nz / 20.
            x0 = t / math.sin(math.pi * 45. / 180.)
            theta = -89.5
            while theta < 89.5:
                z = t * math.cos(math.pi * theta / 180.)
                x = x0 + t * math.sin(math.pi * theta / 180.)
                ix = x * d1 / d2
                r = math.hypot(z, x - x0)
                for ib in xrange(nb):
                    iz = z + ib - 1
                    if iz >= 0 and iz < nz and ix >= 0 and ix < nx:
                        zdat[ix, iz] += b[ib] * r
                theta += 1

        d.write(zdat)
Ejemplo n.º 2
0
    vp.uorig(-1. + xmin, 0.)

    vp.utext(xmin / 2, tmax + .45, 18, 0, "Common Shot")
    vp.utext(xmax + .1, tmax - .45, 14, 0, "g")
    vp.utext(.25, .1, 14, 0, "t")

    vp.uclip(xmin, .6, xmax, tmax)
    vp.umove(xmin, tmax)
    vp.udraw(xmax, tmax)
    vp.umove(0., tmax)
    vp.udraw(0., tmax - tmax)
    vp.color(6)
    for iz in xrange(nz):
        orig = 3 * ((xmax - xmin) * rand01() + xmin)
        alfa = degrees * 2 * 3.14 / 360 * rand01()
        c2a = math.cos(2 * alfa)
        vp.penup()
        for ix in xrange(nx):  # x=g s=0
            x = x0 + ix * dx
            arg = orig * orig + (x - orig) * (x - orig) + 2 * orig * (
                x - orig) * c2a
            t = math.sqrt(arg)
            if t < math.fabs(x):
                t = math.fabs(x)
            vp.upendn(x, tmax - t)


if __name__ == "__main__":
    vp = vplot.Vplot()
    draw(vp)