In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import glob
import jedi
%matplotlib inline

In [ ]:
pre = "/Users/weilu/Research/server/oct_2017/week_of_oct02/freeEnergy"
folder_list = glob.glob(pre+"/*")

In [ ]:
folder_list = [
   '/Users/weilu/Research/server/oct_2017/week_of_oct02/freeEnergy/rg_0.4_lipid_2_extended',
    '/Users/weilu/Research/server/oct_2017/week_of_oct02/freeEnergy/rg_0.4_lipid_2_topology'
]
dis_list = np.linspace(30, 130, 51)

In [ ]:
pre = '/Users/weilu/Research/server/oct_2017/week_of_oct02/freeEnergy/rg_0.4_lipid_2_topology'

In [ ]:
def process_data(folder, dis):
    location = folder + "/simulation/dis_{}/0/".format(dis)
    #     print(location)
    all_lipid_list = []
    for i in range(4):
        file = "lipid.{}.dat".format(i)
        lipid = pd.read_csv(location+file).assign(Run = i)
        lipid.columns = lipid.columns.str.strip()
        lipid = lipid[["Steps","Lipid","Run"]]
        all_lipid_list.append(lipid)
    lipid = pd.concat(all_lipid_list)

    all_dis_list = []
    for i in range(4):
        file = "addforce.{}.dat".format(i)
        dis = pd.read_csv(location+file).assign(Run = i)
        dis.columns = dis.columns.str.strip()
        remove_columns = ['AddedForce', 'Dis12', 'Dis34', 'Dis56']
        dis.drop(remove_columns, axis=1,inplace=True)
        all_dis_list.append(dis)
    dis = pd.concat(all_dis_list)

    all_wham_list = []
    for i in range(4):
        file = "wham.{}.dat".format(i)
        wham = pd.read_csv(location+file).assign(Run = i)
        wham.columns = wham.columns.str.strip()
        remove_columns = ['Rg', 'Tc']
        wham = wham.drop(remove_columns, axis=1)
        all_wham_list.append(wham)
    wham = pd.concat(all_wham_list)

    file = "../log.lammps"
    temper = pd.read_table(location+file, skiprows=2, sep=' ')
    temper = temper.melt(id_vars=['Step'], value_vars=['T0', 'T1', 'T2', 'T3'], value_name="Run", var_name="Temp")

    t2 = temper.merge(wham, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                     ).sort_values('Step').drop('Steps', axis=1)
    t3 = t2.merge(dis, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                     ).sort_values('Step').drop('Steps', axis=1)
    t4 = t3.merge(lipid, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                             ).sort_values('Step').drop('Steps', axis=1)
    t4 = t4.assign(TotalE = t4.Energy + t4.Lipid)
    t350 = t4.query('Temp=="T0" & Step > 1e7')
    t350.to_csv(location+"t350.dat", sep=' ', index=False, header=False)
    t400 = t4.query('Temp=="T1" & Step > 1e7')
    t400.to_csv(location+"t400.dat", sep=' ', index=False, header=False)
    t450 = t4.query('Temp=="T2" & Step > 1e7')
    t450.to_csv(location+"t450.dat", sep=' ', index=False, header=False)
    t4.query('Temp=="T3" & Step > 1e7').to_csv(location+"t500.dat", sep=' ', index=False, header=False)

In [ ]:
process_data(folder, dis)

In [ ]:
for folder in folder_list:
    for dis in dis_list:
        process_data(folder, dis)

In [ ]:
t350.plot('Step', 'Run')

In [ ]:
t350.plot('Step', 'Qw')

In [ ]:
t350.plot('Step', 'Energy')

In [2]:


In [7]:
import IPython
print(IPython.sys_info())


{'commit_hash': 'd86648c5d',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/Users/weilu/anaconda/lib/python3.6/site-packages/IPython',
 'ipython_version': '6.1.0',
 'os_name': 'posix',
 'platform': 'Darwin-16.7.0-x86_64-i386-64bit',
 'sys_executable': '/Users/weilu/anaconda/bin/python',
 'sys_platform': 'darwin',
 'sys_version': '3.6.1 |Anaconda custom (x86_64)| (default, May 11 2017, '
                '13:04:09) \n'
                '[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]'}

In [9]:
folder = '/Users/weilu/Research/server/oct_2017/week_of_oct02/freeEnergy/rg_0.4_lipid_2_extended'
dis_list = np.linspace(30, 130, 51)
all_dis = []
for dis in dis_list:
    location = folder + "/simulation/dis_{}/0/".format(dis)
    #     print(location)
    all_lipid_list = []
    for i in range(4):
        file = "lipid.{}.dat".format(i)
        lipid = pd.read_csv(location+file).assign(Run = i)
        lipid.columns = lipid.columns.str.strip()
        lipid = lipid[["Steps","Lipid","Run"]]
        all_lipid_list.append(lipid)
    lipid = pd.concat(all_lipid_list)

    all_dis_list = []
    for i in range(4):
        file = "addforce.{}.dat".format(i)
        dis = pd.read_csv(location+file).assign(Run = i)
        dis.columns = dis.columns.str.strip()
        remove_columns = ['AddedForce', 'Dis12', 'Dis34', 'Dis56']
        dis.drop(remove_columns, axis=1,inplace=True)
        all_dis_list.append(dis)
    dis = pd.concat(all_dis_list)

    all_wham_list = []
    for i in range(4):
        file = "wham.{}.dat".format(i)
        wham = pd.read_csv(location+file).assign(Run = i)
        wham.columns = wham.columns.str.strip()
        remove_columns = ['Rg', 'Tc']
        wham = wham.drop(remove_columns, axis=1)
        all_wham_list.append(wham)
    wham = pd.concat(all_wham_list)

    file = "../log.lammps"
    temper = pd.read_table(location+file, skiprows=2, sep=' ')
    temper = temper.melt(id_vars=['Step'], value_vars=['T0', 'T1', 'T2', 'T3'], value_name="Run", var_name="Temp")

    t2 = temper.merge(wham, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                     ).sort_values('Step').drop('Steps', axis=1)
    t3 = t2.merge(dis, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                     ).sort_values('Step').drop('Steps', axis=1)
    t4 = t3.merge(lipid, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                             ).sort_values('Step').drop('Steps', axis=1)
    t4 = t4.assign(TotalE = t4.Energy + t4.Lipid)
    all_dis.append(t4)
data = pd.concat(all_dis)

In [12]:
data.to_feather("/Users/weilu/Research/data/test_data/test.feather")


---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~/anaconda/lib/python3.6/site-packages/pandas/io/feather_format.py in _try_import()
     12     try:
---> 13         import feather
     14     except ImportError:

ModuleNotFoundError: No module named 'feather'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-12-745126e06070> in <module>()
----> 1 data.to_feather("/Users/weilu/Research/data/test_data/test.feather")

~/anaconda/lib/python3.6/site-packages/pandas/core/frame.py in to_feather(self, fname)
   1512         """
   1513         from pandas.io.feather_format import to_feather
-> 1514         to_feather(self, fname)
   1515 
   1516     @Substitution(header='Write out column names. If a list of string is given, \

~/anaconda/lib/python3.6/site-packages/pandas/io/feather_format.py in to_feather(df, path)
     47         raise ValueError("feather only support IO with DataFrames")
     48 
---> 49     feather = _try_import()
     50     valid_types = {'string', 'unicode'}
     51 

~/anaconda/lib/python3.6/site-packages/pandas/io/feather_format.py in _try_import()
     15 
     16         # give a nice error message
---> 17         raise ImportError("the feather-format library is not installed\n"
     18                           "you can install via conda\n"
     19                           "conda install feather-format -c conda-forge\n"

ImportError: the feather-format library is not installed
you can install via conda
conda install feather-format -c conda-forge
or via pip
pip install feather-format

In [15]:
data.plot.hexbin(x='Qw', y='Distance')


Out[15]:
<matplotlib.axes._subplots.AxesSubplot at 0x112d4aa58>

In [17]:
['T' + str(i) for i in range(5)]


Out[17]:
['T0', 'T1', 'T2', 'T3', 'T4']

In [19]:
def read_temper(n=4, location="."):
    for i in range(n):
        file = "lipid.{}.dat".format(i)
        lipid = pd.read_csv(location+file).assign(Run = i)
        lipid.columns = lipid.columns.str.strip()
        lipid = lipid[["Steps","Lipid","Run"]]
        all_lipid_list.append(lipid)
    lipid = pd.concat(all_lipid_list)

    all_dis_list = []
    for i in range(n):
        file = "addforce.{}.dat".format(i)
        dis = pd.read_csv(location+file).assign(Run = i)
        dis.columns = dis.columns.str.strip()
        remove_columns = ['AddedForce', 'Dis12', 'Dis34', 'Dis56']
        dis.drop(remove_columns, axis=1,inplace=True)
        all_dis_list.append(dis)
    dis = pd.concat(all_dis_list)

    all_wham_list = []
    for i in range(n):
        file = "wham.{}.dat".format(i)
        wham = pd.read_csv(location+file).assign(Run = i)
        wham.columns = wham.columns.str.strip()
        remove_columns = ['Rg', 'Tc']
        wham = wham.drop(remove_columns, axis=1)
        all_wham_list.append(wham)
    wham = pd.concat(all_wham_list)

    file = "../log.lammps"
    temper = pd.read_table(location+file, skiprows=2, sep=' ')
    temper = temper.melt(id_vars=['Step'], value_vars=['T' + str(i) for i in range(n)], value_name="Run", var_name="Temp")

    t2 = temper.merge(wham, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                     ).sort_values('Step').drop('Steps', axis=1)
    t3 = t2.merge(dis, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                     ).sort_values('Step').drop('Steps', axis=1)
    t4 = t3.merge(lipid, how='inner', left_on=["Step", "Run"], right_on=["Steps", "Run"]
                             ).sort_values('Step').drop('Steps', axis=1)
    t4 = t4.assign(TotalE = t4.Energy + t4.Lipid)
    return t4

In [21]:
n= 8
location = "/Users/weilu/Research/server/oct_2017/week_oct09_two/higher_temp/simulation/dis_30.0/0/"
data= read_temper(location=location, n=n)

In [67]:
t350 = data.query('Temp=="T0" & Step > 0e7')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[67]:
<matplotlib.axes._subplots.AxesSubplot at 0x1295a3f28>

In [68]:
t350 = data.query('Temp=="T1" & Step > 0e7')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[68]:
<matplotlib.axes._subplots.AxesSubplot at 0x129c4e278>

In [62]:
t350 = data.query('Temp=="T2" & Step > 0e7')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[62]:
<matplotlib.axes._subplots.AxesSubplot at 0x128914ef0>

In [69]:
t350 = data.query('Temp=="T3" & Step > 0e7')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[69]:
<matplotlib.axes._subplots.AxesSubplot at 0x128dd30f0>

In [61]:
t350 = data.query('Temp=="T4" & Step > 0e7')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[61]:
<matplotlib.axes._subplots.AxesSubplot at 0x1250865c0>

In [60]:
t350 = data.query('Temp=="T5" & Step > 0e7')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[60]:
<matplotlib.axes._subplots.AxesSubplot at 0x12175f630>

In [59]:



Out[59]:
<matplotlib.axes._subplots.AxesSubplot at 0x11fa3b2b0>

In [41]:
n= 8
location = "/Users/weilu/Research/server/oct_2017/week_oct09_two/higher_temp/simulation/dis_80.0/0/"
data2= read_temper(location=location, n=n)

In [58]:
t350 = data2.query('Temp=="T1" & Step > 0e7')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[58]:
<matplotlib.axes._subplots.AxesSubplot at 0x1225c52b0>

In [ ]:
t350 = data2.query('Temp=="T1" & Step > 1e7')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')

In [51]:
n= 4
location = "/Users/weilu/Research/server/oct_2017/week_of_oct02/freeEnergy/rg_0.4_lipid_2_extended/simulation/dis_30.0/0/"
data3= read_temper(location=location, n=n)

In [66]:
t350 = data3.query('Temp=="T0"')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[66]:
<matplotlib.axes._subplots.AxesSubplot at 0x1225b05c0>

In [65]:
t350 = data3.query('Temp=="T1"')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[65]:
<matplotlib.axes._subplots.AxesSubplot at 0x125b66278>

In [64]:
t350 = data3.query('Temp=="T2"')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[64]:
<matplotlib.axes._subplots.AxesSubplot at 0x125a61ef0>

In [70]:
t350 = data3.query('Temp=="T3"')
t350.plot('Step', 'Run')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


Out[70]:
<matplotlib.axes._subplots.AxesSubplot at 0x1288e9668>

In [74]:
t350 = data3.query('Run==0')
t350.plot('Step', 'Temp')
t350.plot('Step', 'Qw')
t350.plot('Step', 'Energy')


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-74-e60e2af1cad7> in <module>()
      1 t350 = data3.query('Run == 0')
----> 2 t350.plot('Step', 'Temp')
      3 t350.plot('Step', 'Qw')
      4 t350.plot('Step', 'Energy')

~/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py in __call__(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   2618                           fontsize=fontsize, colormap=colormap, table=table,
   2619                           yerr=yerr, xerr=xerr, secondary_y=secondary_y,
-> 2620                           sort_columns=sort_columns, **kwds)
   2621     __call__.__doc__ = plot_frame.__doc__
   2622 

~/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   1855                  yerr=yerr, xerr=xerr,
   1856                  secondary_y=secondary_y, sort_columns=sort_columns,
-> 1857                  **kwds)
   1858 
   1859 

~/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
   1680         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
   1681 
-> 1682     plot_obj.generate()
   1683     plot_obj.draw()
   1684     return plot_obj.result

~/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py in generate(self)
    234     def generate(self):
    235         self._args_adjust()
--> 236         self._compute_plot_data()
    237         self._setup_subplots()
    238         self._make_plot()

~/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py in _compute_plot_data(self)
    343         if is_empty:
    344             raise TypeError('Empty {0!r}: no numeric data to '
--> 345                             'plot'.format(numeric_data.__class__.__name__))
    346 
    347         self.data = numeric_data

TypeError: Empty 'DataFrame': no numeric data to plot

In [72]:
data3


Out[72]:
Step Temp Run Qw Energy Distance Lipid TotalE
0 4000 T0 1 0.051328 -180.561073 241.150081 -0.003150 -180.564223
15 4000 T3 3 0.051168 -52.272277 239.779323 0.257297 -52.014980
14 4000 T3 3 0.051168 -52.272277 239.779323 0.227489 -52.044788
13 4000 T3 3 0.051168 -52.272277 239.779323 0.289218 -51.983059
12 4000 T3 3 0.051168 -52.272277 239.779323 0.024245 -52.248032
10 4000 T1 0 0.051460 -145.509740 240.832594 0.102526 -145.407214
9 4000 T1 0 0.051460 -145.509740 240.832594 0.109315 -145.400426
8 4000 T1 0 0.051460 -145.509740 240.832594 0.013637 -145.496103
11 4000 T1 0 0.051460 -145.509740 240.832594 0.234867 -145.274873
6 4000 T2 2 0.054114 -178.377807 242.690315 0.255513 -178.122295
5 4000 T2 2 0.054114 -178.377807 242.690315 0.450095 -177.927713
4 4000 T2 2 0.054114 -178.377807 242.690315 0.070846 -178.306961
3 4000 T0 1 0.051328 -180.561073 241.150081 0.259122 -180.301951
2 4000 T0 1 0.051328 -180.561073 241.150081 0.110916 -180.450158
1 4000 T0 1 0.051328 -180.561073 241.150081 0.143941 -180.417132
7 4000 T2 2 0.054114 -178.377807 242.690315 0.230648 -178.147159
25 8000 T0 1 0.073783 -437.562864 143.866671 -0.345778 -437.908641
31 8000 T1 0 0.068913 -304.161400 132.744382 -0.137282 -304.298681
30 8000 T1 0 0.068913 -304.161400 132.744382 -1.060612 -305.222012
29 8000 T1 0 0.068913 -304.161400 132.744382 -0.136743 -304.298142
28 8000 T1 0 0.068913 -304.161400 132.744382 0.167048 -303.994352
27 8000 T0 1 0.073783 -437.562864 143.866671 -0.116031 -437.678895
26 8000 T0 1 0.073783 -437.562864 143.866671 -0.988660 -438.551524
24 8000 T0 1 0.073783 -437.562864 143.866671 -0.079496 -437.642360
19 8000 T3 3 0.072346 -145.424143 131.610711 -0.095539 -145.519682
22 8000 T2 2 0.071423 -300.009746 145.835932 -0.060098 -300.069844
21 8000 T2 2 0.071423 -300.009746 145.835932 -0.341059 -300.350804
20 8000 T2 2 0.071423 -300.009746 145.835932 -0.126099 -300.135845
18 8000 T3 3 0.072346 -145.424143 131.610711 -0.784124 -146.208267
17 8000 T3 3 0.072346 -145.424143 131.610711 0.028153 -145.395990
... ... ... ... ... ... ... ... ...
79981 19996000 T3 1 0.652191 -905.381943 26.901585 -18.459681 -923.841624
79980 19996000 T3 1 0.652191 -905.381943 26.901585 -63.980858 -969.362800
79978 19996000 T2 2 0.324935 -646.409437 13.227381 -77.295302 -723.704739
79977 19996000 T2 2 0.324935 -646.409437 13.227381 -104.755573 -751.165011
79976 19996000 T2 2 0.324935 -646.409437 13.227381 -80.888510 -727.297948
79979 19996000 T2 2 0.324935 -646.409437 13.227381 -115.024841 -761.434279
79974 19996000 T0 3 0.362070 -787.742135 12.027203 -76.153022 -863.895157
79973 19996000 T0 3 0.362070 -787.742135 12.027203 -90.608416 -878.350551
79972 19996000 T0 3 0.362070 -787.742135 12.027203 -79.371605 -867.113740
79971 19996000 T1 0 0.310672 -507.358561 27.283029 -98.308049 -605.666611
79970 19996000 T1 0 0.310672 -507.358561 27.283029 -71.183024 -578.541585
79969 19996000 T1 0 0.310672 -507.358561 27.283029 -110.215852 -617.574414
79968 19996000 T1 0 0.310672 -507.358561 27.283029 -75.155643 -582.514205
79975 19996000 T0 3 0.362070 -787.742135 12.027203 -115.935502 -903.677637
79997 20000000 T3 1 0.616985 -899.269416 23.835518 -18.306210 -917.575626
79996 20000000 T3 1 0.616985 -899.269416 23.835518 -61.815884 -961.085300
79995 20000000 T1 0 0.358867 -560.282896 18.402387 -105.725847 -666.008743
79994 20000000 T1 0 0.358867 -560.282896 18.402387 -68.904100 -629.186996
79993 20000000 T1 0 0.358867 -560.282896 18.402387 -106.093741 -666.376637
79992 20000000 T1 0 0.358867 -560.282896 18.402387 -76.526746 -636.809642
79991 20000000 T2 2 0.353911 -624.433682 19.300384 -117.319962 -741.753644
79987 20000000 T0 3 0.363336 -784.795841 13.186940 -117.778339 -902.574180
79989 20000000 T2 2 0.353911 -624.433682 19.300384 -110.248157 -734.681838
79988 20000000 T2 2 0.353911 -624.433682 19.300384 -78.414646 -702.848327
79986 20000000 T0 3 0.363336 -784.795841 13.186940 -78.180884 -862.976725
79985 20000000 T0 3 0.363336 -784.795841 13.186940 -97.246868 -882.042709
79984 20000000 T0 3 0.363336 -784.795841 13.186940 -76.516865 -861.312706
79998 20000000 T3 1 0.616985 -899.269416 23.835518 -107.755015 -1007.024430
79990 20000000 T2 2 0.353911 -624.433682 19.300384 -79.154152 -703.587834
79999 20000000 T3 1 0.616985 -899.269416 23.835518 -104.152052 -1003.421467

80000 rows × 8 columns


In [87]:
t350 = data3.query('Run==2')
dic = {"T0":350, "T1":400, "T2":450, "T3":500}
t350 = t350.assign(myT = t350['Temp'].map(dic))
t350.plot('Step', 'myT')


Out[87]:
<matplotlib.axes._subplots.AxesSubplot at 0x11850dac8>

In [90]:
for i in range(4):
    tmp = data3.query('Run=={}'.format(i))
    dic = {"T0":350, "T1":400, "T2":450, "T3":500}
    tmp = tmp.assign(myT = tmp['Temp'].map(dic))
    tmp.plot('Step', 'myT')



In [ ]: