-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_graph_dat.py
More file actions
executable file
·45 lines (32 loc) · 962 Bytes
/
Copy pathbuild_graph_dat.py
File metadata and controls
executable file
·45 lines (32 loc) · 962 Bytes
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
#!/usr/bin/env python
import os
import glob
import numpy as np
import subprocess
FILE_NAME = "beta_t_mag.dat"
files = glob.glob("mag_files/*.dat")
datapoints = []
for f in files:
beta = float(f.split("/")[1].split("_")[1])
mu = float(f.split("/")[1].split("_")[2][:-4])
T = 1.0/beta
try:
mag = float(subprocess.check_output(['tail', '-1', f])[:-1])
except Exception:
mag = 0.0
datapoints.append([beta,T,mu,mag])
mu_vals = list(set([x[2] for x in datapoints]))
mu_vals.sort()
print mu_vals
if os.path.isfile(FILE_NAME):
os.remove(FILE_NAME)
with open(FILE_NAME, 'w') as f :
f.write("#beta T mag\n\n\n")
for mu in mu_vals:
f.write('"Mu = '+str(mu)+'"\n')
points = [x for x in datapoints if x[2] == mu]
points.sort(key = lambda x : x[0])
for p in points:
f.write("{:10.7f} {:10.7f} {:10.7f}\n".format(p[0],p[1],p[3]))
f.write("\n\n")
f.close()