forked from MichaelSt98/milupHPC
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotProcRings.py
More file actions
65 lines (50 loc) · 1.93 KB
/
plotProcRings.py
File metadata and controls
65 lines (50 loc) · 1.93 KB
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
61
62
63
64
65
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import h5py
import os
import re
import argparse
import glob
" based on https://github.com/jammartin/ParaLoBstar/blob/main/tools/conservation/main.py"
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Plot position of particles.")
parser.add_argument("--data", "-d", metavar="str", type=str, help="input directory",
nargs="?", default="output")
parser.add_argument("--output", "-o", metavar="str", type=str, help="output directory",
nargs="?", default="output")
args = parser.parse_args()
i = 0
for h5file in sorted(glob.glob(os.path.join(args.data, "*.h5")), key=os.path.basename):
print("Processing ", h5file, " ...")
data = h5py.File(h5file, 'r')
time = re.findall(r'(\d+)*.h5', h5file)
positions = np.array(data["x"][:])
process = np.array(data["proc"][:])
NoProc =np.amax(process)
print("...plotting timestep figure {} ".format(i))
fig = plt.figure(dpi=500)
ax = fig.add_subplot() #projection='3d' for 3D plot
p = ax.scatter(positions[:, 0], positions[:, 1], c= process, marker="o", s=0.05, cmap='Dark2' , vmin = 0 , vmax = NoProc) #, r[:, 2] for 3d, vmin, vmax set the min/max for the colorbar, use a qualitative colormap
ax.set_xlabel('X')
ax.set_ylabel('Y')
#ax.set_zlabel('Z')
#to compare different timesteps
#ax.set_xlim3d(-10, 10)
#ax.set_ylim3d(-10, 10)
#ax.set_zlim3d(-10, 10)″
#set ax limits
#for rings from origin
ax.set_xlim(-14, 14)
ax.set_ylim(-7,7) #(-8, 8)
#rings in the 2nd quadrant
#ax.set_xlim(-3, 25)
#ax.set_ylim(-1, 13)
#rings in the first quadrant
#ax.set_xlim(-25, 3)
#ax.set_ylim(-1, 13)
#ax.set_title('Timestep: {}'.format(time[i][0]))
ax.set_title("MPI-Processes")
plt.savefig("{0:}/Process{1:06d}.png".format(args.output, i))
plt.close()
i = i+1