From d0c870377cc4e0388a343a6297f7ec5fa54adf16 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Mon, 13 May 2019 22:20:51 -0400 Subject: As presented at MSU on 2019-05-02 --- figs/animation/animate.py | 127 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 figs/animation/animate.py (limited to 'figs/animation/animate.py') diff --git a/figs/animation/animate.py b/figs/animation/animate.py new file mode 100644 index 0000000..aaa3a80 --- /dev/null +++ b/figs/animation/animate.py @@ -0,0 +1,127 @@ +from matplotlib import pyplot as pl +from matplotlib import animation +import sys + +# read data +# time dependent data +frames=[] +# asymptotic data (located in the first block) +asym=[] +infile=open(sys.argv[1],'r') +row=[] +for line in infile: + # read first block + if len(asym)==0: + if line=='\n': + asym=row + row=[] + else: + dat=[] + for n in line.split(): + dat.append(float(n)) + row.append(dat) + # read other blocks + else: + if line=='\n': + frames.append(row) + row=[] + else: + dat=[] + for n in line.split(): + dat.append(float(n)) + row.append(dat) +infile.close() + + +# set up plot +fig = pl.figure() +#pl.subplot(211) +axr=fig.gca() +asym_rho, = axr.plot([],[],linewidth=3.5,color='#00FF00') +rho, = axr.plot([],[],color='red') + +#pl.subplot(212) +#axJ=fig.gca() +#asym_J, = axJ.plot([],[],linewidth=3.5,color='#00FF00') +#J, = axJ.plot([],[],color='red') + +# plot ranges +xmax=0 +maxyr=0 +maxyJ=0 +for frame in frames: + for i in range(len(frame)): + if frame[i][1]>xmax: + xmax=frame[i][1] + if frame[i][2]>maxyr: + maxyr=frame[i][2] + if frame[i][3]>maxyJ: + maxyJ=frame[i][3] +for i in range(len(asym)): + if asym[i][0]>xmax: + xmax=asym[i][0] + if asym[i][1]>maxyr: + maxyr=asym[i][1] + if asym[i][2]>maxyJ: + maxyJ=asym[i][2] +xmin=0 +minyr=0 +minyJ=0 +for frame in frames: + for i in range(len(frame)): + if frame[i][1]