-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimate
executable file
·31 lines (23 loc) · 858 Bytes
/
Animate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/home/davidho/anaconda3/bin/python
# -*- coding: utf-8 -*-
import argparse
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import animation
parser = argparse.ArgumentParser(
description='Animate seismogram output')
parser.add_argument('files', nargs='+', type=argparse.FileType('r'),
help='Files to be plotted')
parser.add_argument('--output', type=str, default="animation", help="output filename")
args = parser.parse_args()
fig = plt.figure()
ax = plt.gca(projection='3d')
frames = []
for seismo in args.files:
data = np.loadtxt(seismo)
frame = plt.plot(data[:, 0], data[:, 1], zs=data[:, 2], color="b")
frames.append(frame)
anim = animation.ArtistAnimation(fig, frames, interval = 200,
blit = True)
anim.save(args.output+".mp4", writer="ffmpeg")