-
Notifications
You must be signed in to change notification settings - Fork 5
/
dihedral_step_evolution.py
executable file
·45 lines (36 loc) · 1.54 KB
/
dihedral_step_evolution.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
#!/usr/bin/env python3
"""
Receives a '.dat' file containing dihedrals to plot them across a step axis.
Author: Henrique Musseli Cezar
Date: FEB/2017
"""
import argparse
import os
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from distutils.spawn import find_executable
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Receives a '.dat' file containing angles to plot the evolution with the steps.")
parser.add_argument("fangles", help="path to the file containing the angles, one angle per line.")
parser.add_argument("stepmult", nargs='?', help="step multiplier, the number of steps between each saved configuration (each angle). Default is 1 and can changed to have an x-axis with the total number of steps", default=1)
args = parser.parse_args()
# read data and prepare the lists
angles = []
with open(args.fangles,'r') as f:
for line in f:
angles.append(float(line.strip()))
stepmult = int(args.stepmult)
step = [x*stepmult for x in range(1,len(angles)+1)]
# plot it
if find_executable('latex') and find_executable('dvipng'):
mpl.rcParams.update({'font.size':18, 'text.usetex':True, 'font.family':'serif', 'ytick.major.pad':4})
else:
mpl.rcParams.update({'font.size':18, 'font.family':'serif', 'ytick.major.pad':4})
plt.scatter(step,angles,s=2)
plt.xlabel(r"MC Cycle")
plt.ylabel(r"$\phi$ ($^\circ$)")
plt.xlim([0,step[-1]])
plt.ylim([-180,180])
plt.yticks([-180,-120,-60,0,60,120,180])
plt.savefig(os.path.splitext(args.fangles)[0]+".pdf", bbox_inches='tight')