Skip to content

Instantly share code, notes, and snippets.

@leelasd
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leelasd/7d53dfd398705c7d5697 to your computer and use it in GitHub Desktop.
Save leelasd/7d53dfd398705c7d5697 to your computer and use it in GitHub Desktop.
RDF & CN analysis from GMX
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
###############
def get_RDF(filename='1'):
rdf=pd.read_csv(filename+'/rdf.xvg', header=None, delim_whitespace=True,skiprows=14)
cn=pd.read_csv(filename+'/rdf_cn.xvg', header=None, delim_whitespace=True,skiprows=14)
rdf.columns=['R','RDF']
cn.columns=['R','CN']
fig, ax1 = plt.subplots()
plt.title(filename)
ax1.fill_between(rdf.R*10,rdf.RDF,alpha=0.8,color='r')
ax2=ax1.twinx()
ax2.axhline(y=6)
ax2.plot(cn.R*10,cn.CN,'k--')
ax2.set_ylim(1,10)
ax1.set_xlim(1.5,3.0)
return(fig)
#################
dfR=pd.read_csv("rdf.xvg", header=None, delim_whitespace=True,skiprows=14)
dfCN=pd.read_csv("rdf_cn.xvg", header=None, delim_whitespace=True,skiprows=14)
dfR.columns=['Dist','RDF']
dfCN.columns=['Dist','CN']
fig, ax1 = plt.subplots()
ax1.plot(dfR.Dist,dfR.RDF,'r-')
ax2 = ax1.twinx()
ax2.plot(dfCN.Dist,dfCN.CN,'b--')
ax2.set_xlim(0.1,0.3)
ax1.set_xlim(0.1,0.3)
ax2.set_ylim(0,7)
plt.show()
dfR.sort(['RDF'])[-1:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment