-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjulia_plotting.py
60 lines (46 loc) · 1.36 KB
/
julia_plotting.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 19 16:17:31 2021
@author: Jose
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import time
import glob
import imageio
start_time = time.time()
dx = 0.01
D = 0.5
Time = 4.0
N = M = 1024
x = np.arange(-5.0, 5.24, dx)
y = np.arange(-5.0, 5.24, dx)
xx, yy = np.meshgrid(x, y)
#read data
files = glob.glob('*.txt')
# images = np.array([])
images = []
for file in files:
filebase = file[:-4]
print(filebase)
psi = np.genfromtxt(file, delimiter=",")
#Plot 3d
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(xx, yy, psi, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
surf.set_clim(-1,1)
# Customize the z axis.
ax.set_zlim(-1, 1)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=15)
plt.savefig(filebase+'.png')
# np.append(images, imageio.imread(filebase+'.png'))
images.append(imageio.imread(filebase+'.png'))
imageio.mimsave('Diffusion2D_numba.gif', images)
end_time = time.time()
print(end_time-start_time)