Exemple #1
0
def visualize_front_ascii(u, t, fps=10):
    """
    Plot u and the exact solution vs t line by line in a
    terminal window (only using ascii characters).
    Makes it easy to plot very long time series.
    """
    from scitools.avplotter import Plotter
    import time
    umin = 1.2*u.min();  umax = -umin

    p = Plotter(ymin=umin, ymax=umax, width=60, symbols='+o')
    for n in range(len(u)):
        print p.plot(t[n], u[n]), '%.2f' % (t[n])
        time.sleep(1/float(fps))
Exemple #2
0
def visualize_front_ascii(u, t, fps=10):
    """
    Plot u and the exact solution vs t line by line in a
    terminal window (only using ascii characters).
    Makes it easy to plot very long time series.
    """
    from scitools.avplotter import Plotter
    import time
    umin = 1.2*u.min();  umax = -umin

    p = Plotter(ymin=umin, ymax=umax, width=60, symbols='+o')
    for n in range(len(u)):
        print p.plot(t[n], u[n]), '%.2f' % (t[n])
        time.sleep(1/float(fps))
Exemple #3
0
def visualize_front_ascii(u, t, U, omega, fps=10):
	"""
	Строится график зависимостей приближенного и точного решений
	от t построчно в окне терминала (используются только символы ascii).
	"""
	from scitools.avplotter import Plotter
	import time
	from math import pi
	P = 2*pi/omega
	umin = 1.2*u.min();  umax = -umin

	p = Plotter(ymin=umin, ymax=umax, width=60, symbols='+o')
	for n in range(len(u)):
		print p.plot(t[n], u[n], U*np.cos(omega*t[n])), \
			'%.1f' % (t[n]/P)
		time.sleep(1/float(fps))
def visualize_front_ascii(u, t, I, w, fps=10):
    """
    Plot u and the exact solution vs t line by line in a
    terminal window (only using ascii characters).
    Makes it easy to plot very long time series.
    """
    from scitools.avplotter import Plotter
    import time
    from math import pi

    P = 2 * pi / w
    umin = 1.2 * u.min()
    umax = -umin

    p = Plotter(ymin=umin, ymax=umax, width=60, symbols="+o")
    for n in range(len(u)):
        print p.plot(t[n], u[n], I * cos(w * t[n])), "%.1f" % (t[n] / P)
        time.sleep(1 / float(fps))
def read_and_plot(filename, u_min, u_max):
    """
    Read file and plot u vs t line by line in a
    terminal window (only using ascii characters).
    """
    from scitools.avplotter import Plotter
    import time
    umin = 1.2 * u_min
    umax = 1.2 * u_max
    p = Plotter(ymin=umin, ymax=umax, width=60, symbols='+o')
    fps = 10
    infile = open(filename, 'r')

    # read and treat one line at a time
    infile.readline()  # skip header line
    for line in infile:
        time_and_pos = line.split()  # gives list with 2 elements
        t = float(time_and_pos[0])
        u = float(time_and_pos[1])
        #print 'time: %g   position: %g' % (time, pos)
        print p.plot(t, u), '%.2f' % (t)
        time.sleep(1 / float(fps))
Exemple #6
0
for i in range(len(h)):
    plot(x[:m], h[i][:m])
legend(['Curve 0', 'Curve 1', 'Curve 2'])
title('Curves in class pysketcher.StochasticWavyCurve')
savefig('tmp.png')
savefig('tmp.pdf')

def write_array(a):
    s = 'np.array(['
    for e in a:
        s += '%.4f, ' % e
    s += '])'
    return s

f = open('tmp.py', 'w')
f.write("""
x = %s
y = [None]*3
y[0] = %s
y[1] = %s
y[2] = %s
""" % (write_array(x[:m]), write_array(h[0][:m]), write_array(h[1][:m]), write_array(h[2][:m])))
f.close()
from scitools.avplotter import Plotter
p = Plotter(-0.15, 0.17, width=70)
for i in range(3):
    print '-'*70
    for x_, h_ in zip(x[:m:5], h[i][:m:5]):
        print p.plot(x_, h_)
show()
Exemple #7
0
title('Curves in class pysketcher.StochasticWavyCurve')
savefig('tmp.png')
savefig('tmp.pdf')


def write_array(a):
    s = 'np.array(['
    for e in a:
        s += '%.4f, ' % e
    s += '])'
    return s


f = open('tmp.py', 'w')
f.write("""
x = %s
y = [None]*3
y[0] = %s
y[1] = %s
y[2] = %s
""" % (write_array(x[:m]), write_array(h[0][:m]), write_array(
    h[1][:m]), write_array(h[2][:m])))
f.close()
from scitools.avplotter import Plotter
p = Plotter(-0.15, 0.17, width=70)
for i in range(3):
    print '-' * 70
    for x_, h_ in zip(x[:m:5], h[i][:m:5]):
        print p.plot(x_, h_)
show()