Skip to content
Snippets Groups Projects
idmsweep.py 1.26 KiB
Newer Older
mehtank's avatar
mehtank committed
from idmlin import IDMLin
from matplotlib import pyplot as plt
from numpy import arange

def idmgo(t, a, b, s, v, fmt=None):
    idm = IDMLin(t=t, a=a, b=b, s0=s)
    res = arange(100)/100.
    idm.go(v, res)
    if fmt is None:
        return res, idm.os()
    else:
        return res, idm.os(), fmt

def sweep():
    names = ("T", "a", "b", "s_0", "v_0")
    defaults = (1.5, 1, 3, 2, 30)

    trng = [0.5, 1, 2, 2.5]
    arng = [0.3, 0.5, 0.8, 1.5]
    brng = [1, 2, 4, 5]
    srng = [0.5, 1, 2.5, 3]
    vrng = [10, 20, 40, 50]

    rngs = [trng, arng, brng, srng, vrng]

    colors = ['r', 'g', 'b', 'm', 'c']
    dots = [':', '--', '-', '.-']

    '''
    for i in range(len(rngs)):
        plt.plot(*idmgo(*defaults, fmt='k'))
        print names[i], rngs[i][:2], defaults[i], rngs[i][2:]
        args = list(defaults)
        for n, arg in enumerate(rngs[i]):
            args[i] = arg
            plt.plot(*idmgo(*args, fmt=colors[i]+dots[n]))

        plt.axis([0,1,-.2,.2])
        plt.show()
    '''

    plt.plot(*idmgo(*defaults, fmt='k'))
    print "a = ", 
    for arg in range(20):
        args = list(defaults)
        a = arg/20. + 0.2
        print a,
        args[1] = a
        plt.plot(*idmgo(*args))
    print
    plt.axis([0,0.1,-.05,.45])
    plt.show()

sweep()