In [89]:
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
from scipy.interpolate import interp2d
import sys
import argparse
import os
import numpy as np
from numpy.random import uniform
import pandas as pd
from itertools import product
import datetime
import glob
%matplotlib inline
plt.rcParams['axes.labelsize'] = 14
plt.rcParams['xtick.labelsize'] = 12
plt.rcParams['ytick.labelsize'] = 12
# plt.rcParams['figure.figsize'] = (10,5)
# plt.rcParams['figure.figsize'] = (10,5.625) # 16:9
plt.rcParams['figure.figsize'] = (10,6.180) #golden ratio
# %matplotlib notebook
# Where to save the figures
PROJECT_ROOT_DIR = "."
CHAPTER_ID = "Week_of_feb14_2018"
def save_fig(fig_id, tight_layout=True):
directory = os.path.join(PROJECT_ROOT_DIR, "images", CHAPTER_ID)
if not os.path.exists(directory):
os.makedirs(directory)
path = os.path.join(PROJECT_ROOT_DIR, "images", CHAPTER_ID, fig_id + ".png")
print("Saving figure", fig_id)
if tight_layout:
plt.tight_layout()
plt.savefig(path, format='png', dpi=300)
In [100]:
location = "/Users/weilu/Research/server/feb_2018/week_of_feb12/constant_force/force_0.2_/simulation"
In [91]:
location = "/Users/weilu/Research/server/feb_2018/week_of_feb12/constant_force/force_0.2_/simulation/18/0"
In [136]:
a = 123
f"{a}pp"
Out[136]:
'123pp'
In [135]:
f"/Users/weilu/Research/data/pulling/{datetime.datetime.today().strftime('%d_%h')}_data_{label}.feather"
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-135-3384dea2f908> in <module>()
----> 1 f"/Users/weilu/Research/data/pulling/{datetime.datetime.today().strftime('%d_%h')}_data_{label}.feather"
NameError: name 'label' is not defined
In [94]:
location = "/Users/weilu/Research/server/feb_2018/week_of_feb12/constant_force/force_0.2_/simulation/localQ/"
localQ = pd.read_table(os.path.join(location,"outmean"), header=None, sep=' ').dropna(axis=1)
In [99]:
sns.heatmap(localQ.T, cmap=sns.color_palette("RdBu_r", 7), center=0.5)
Out[99]:
<matplotlib.axes._subplots.AxesSubplot at 0x1a2311cc50>
In [95]:
localQ
Out[95]:
0
1
2
3
4
5
6
7
8
9
...
171
172
173
174
175
176
177
178
179
180
0
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
1
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
2
0.0000
0.3333
0.3889
0.7143
0.8333
0.6364
0.6667
0.2500
0.0000
0.5455
...
0.7500
0.3750
0.7000
0.4615
0.1250
0.0
0.4444
0.5714
0.0000
0.0
3
0.2087
0.3269
0.3581
0.6241
0.4806
0.6571
0.6638
0.3580
0.1359
0.4753
...
0.7257
0.1638
0.5015
0.5149
0.3350
0.0
0.2826
0.4265
0.0995
0.0
4
0.0713
0.2772
0.2786
0.5410
0.4659
0.6230
0.6395
0.3699
0.1498
0.4620
...
0.7105
0.1106
0.3631
0.4457
0.2287
0.0
0.1955
0.2885
0.0575
0.0
5
0.0082
0.1624
0.1434
0.3384
0.4404
0.5608
0.6149
0.3582
0.2124
0.4243
...
0.6779
0.0802
0.2615
0.3738
0.1279
0.0
0.1314
0.1621
0.0200
0.0
6
0.0001
0.0720
0.0451
0.0931
0.3190
0.4057
0.5257
0.2670
0.2520
0.3517
...
0.6361
0.0657
0.2019
0.3151
0.0778
0.0
0.0884
0.0905
0.0071
0.0
7
0.0000
0.0207
0.0175
0.0042
0.0608
0.1087
0.2267
0.1039
0.1476
0.1801
...
0.5806
0.0553
0.1918
0.2783
0.0680
0.0
0.0746
0.0682
0.0029
0.0
8
0.0000
0.0556
0.0139
0.0000
0.0000
0.0000
0.0035
0.0417
0.0833
0.0152
...
0.6944
0.0938
0.2792
0.3878
0.1354
0.0
0.1343
0.1845
0.0000
0.0
9
0.0000
0.0159
0.0212
0.0000
0.0000
0.0000
0.0000
0.0119
0.1429
0.0000
...
0.6746
0.0833
0.3000
0.3993
0.1190
0.0
0.1270
0.1565
0.0000
0.0
10
0.0000
0.0476
0.0317
0.0000
0.0000
0.0000
0.0000
0.0357
0.0714
0.0065
...
0.6905
0.1250
0.4071
0.4835
0.2679
0.0
0.2460
0.3163
0.0357
0.0
11
0.0000
0.0000
0.0069
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0057
...
0.7292
0.1094
0.3875
0.3942
0.1406
0.0
0.1944
0.2143
0.0313
0.0
12
0.0000
0.0303
0.0303
0.0000
0.0000
0.0000
0.0000
0.0227
0.2727
0.0000
...
0.6818
0.1136
0.4091
0.4056
0.1591
0.0
0.1818
0.1948
0.0455
0.0
13
0.0000
0.0196
0.0196
0.0000
0.0000
0.0000
0.0000
0.0147
0.1176
0.0000
...
0.7255
0.0294
0.3647
0.4072
0.2059
0.0
0.2092
0.2857
0.0000
0.0
14
0.0000
0.0435
0.0242
0.0000
0.0000
0.0000
0.0000
0.0326
0.0870
0.0079
...
0.6449
0.1141
0.3913
0.4398
0.2174
0.0
0.2198
0.2857
0.0109
0.0
15
0.0000
0.0391
0.0329
0.0000
0.0000
0.0000
0.0000
0.0293
0.1224
0.0088
...
0.7007
0.1008
0.3995
0.4364
0.2334
0.0
0.2234
0.2945
0.0612
0.0
16
0.0000
0.0307
0.0315
0.0000
0.0000
0.0000
0.0000
0.0230
0.1157
0.0116
...
0.6790
0.1027
0.3958
0.4341
0.2251
0.0
0.1990
0.2904
0.0631
0.0
17
0.0000
0.0265
0.0242
0.0000
0.0000
0.0000
0.0000
0.0199
0.0860
0.0091
...
0.6728
0.1075
0.3817
0.4183
0.2007
0.0
0.1806
0.2505
0.0405
0.0
18
0.0000
0.0163
0.0140
0.0000
0.0000
0.0000
0.0000
0.0122
0.0543
0.0049
...
0.6713
0.1038
0.3650
0.4053
0.1837
0.0
0.1699
0.2239
0.0308
0.0
19
0.0000
0.0227
0.0157
0.0000
0.0000
0.0000
0.0000
0.0170
0.0584
0.0058
...
0.6038
0.0736
0.2927
0.3404
0.1259
0.0
0.1284
0.1488
0.0280
0.0
20
0.0000
0.0236
0.0240
0.0000
0.0000
0.0000
0.0000
0.0177
0.0942
0.0078
...
0.5364
0.0573
0.1931
0.2733
0.0857
0.0
0.0940
0.1156
0.0203
0.0
21
0.0000
0.0208
0.0165
0.0000
0.0000
0.0000
0.0000
0.0156
0.0541
0.0063
...
0.4945
0.0423
0.1693
0.2436
0.0551
0.0
0.0766
0.0791
0.0062
0.0
22
0.0000
0.0196
0.0136
0.0000
0.0000
0.0000
0.0000
0.0147
0.0560
0.0051
...
0.4182
0.0387
0.1315
0.1975
0.0293
0.0
0.0489
0.0415
0.0013
0.0
23
0.0000
0.0212
0.0091
0.0000
0.0000
0.0000
0.0000
0.0159
0.0364
0.0033
...
0.3182
0.0136
0.0645
0.1210
0.0273
0.0
0.0263
0.0390
0.0045
0.0
24
0.0000
0.0267
0.0267
0.0000
0.0000
0.0000
0.0000
0.0200
0.0800
0.0109
...
0.2667
0.0300
0.0520
0.0862
0.0200
0.0
0.0178
0.0000
0.0000
0.0
25
0.0000
0.0444
0.0074
0.0000
0.0000
0.0000
0.0000
0.0333
0.0000
0.0061
...
0.2111
0.0000
0.0533
0.0974
0.0333
0.0
0.0296
0.0571
0.0000
0.0
26
0.0000
0.0000
0.0242
0.0000
0.0000
0.0000
0.0000
0.0000
0.0870
0.0079
...
0.1884
0.0326
0.0435
0.1104
0.0652
0.0
0.0725
0.0932
0.0000
0.0
27
0.0000
0.0444
0.0296
0.0000
0.0000
0.0000
0.0000
0.0333
0.0000
0.0121
...
0.1667
0.0333
0.0533
0.1282
0.0667
0.0
0.0593
0.1429
0.0667
0.0
28
0.0000
0.0333
0.0111
0.0000
0.0000
0.0000
0.0000
0.0250
0.0500
0.0045
...
0.0167
0.0000
0.0050
0.0154
0.0000
0.0
0.0056
0.0000
0.0000
0.0
29
0.0000
0.0370
0.0000
0.0000
0.0000
0.0000
0.0000
0.0278
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
30
0.0000
0.0175
0.0175
0.0000
0.0000
0.0000
0.0000
0.0132
0.0000
0.0096
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
31
0.0000
0.0317
0.0212
0.0000
0.0000
0.0000
0.0000
0.0238
0.0476
0.0087
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
32
0.0000
0.0000
0.0202
0.0000
0.0000
0.0000
0.0000
0.0000
0.0909
0.0083
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
33
0.0000
0.0303
0.0370
0.0000
0.0000
0.0000
0.0000
0.0227
0.1212
0.0110
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
34
0.0000
0.0474
0.0370
0.0000
0.0000
0.0000
0.0000
0.0355
0.1093
0.0109
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
35
0.0000
0.0402
0.0311
0.0000
0.0000
0.0000
0.0000
0.0302
0.1082
0.0111
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
36
0.0000
0.0334
0.0268
0.0000
0.0000
0.0000
0.0000
0.0251
0.0954
0.0091
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
37
0.0000
0.0275
0.0243
0.0000
0.0000
0.0000
0.0000
0.0206
0.0872
0.0086
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
38
0.0000
0.0228
0.0212
0.0000
0.0000
0.0000
0.0000
0.0171
0.0802
0.0074
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
39
0.0000
0.0190
0.0181
0.0000
0.0000
0.0000
0.0000
0.0143
0.0711
0.0064
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
40
0.0000
0.0152
0.0145
0.0000
0.0000
0.0000
0.0000
0.0114
0.0587
0.0052
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
41
0.0000
0.0135
0.0129
0.0000
0.0000
0.0000
0.0000
0.0101
0.0589
0.0042
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
42
0.0000
0.0094
0.0089
0.0000
0.0000
0.0000
0.0000
0.0070
0.0469
0.0026
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
43
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
44
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
45
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
46
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
47
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
48
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
49
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
...
0.0000
0.0000
0.0000
0.0000
0.0000
0.0
0.0000
0.0000
0.0000
0.0
50 rows × 181 columns
In [92]:
localQ = pd.read_table(os.path.join(location,"localQ_trajectory"), header=None, sep=' ').dropna(axis=1)
In [58]:
localQ.insert(0, "Steps", localQ.index*4000)
In [ ]:
localQ = localQ.melt(id_vars="Steps", var_name="residue").sort_values(by=["Steps", "residue"])
localQ["residue"] += 1
In [93]:
sns.heatmap(localQ.T)
Out[93]:
<matplotlib.axes._subplots.AxesSubplot at 0x1a20401048>
In [86]:
# plt.figure()
sns.heatmap(localQ.T)
save_fig("a")
Saving figure a
In [88]:
# plt.figure()
sns.heatmap(localQ.T)
save_fig("a")
Saving figure a
In [90]:
# plt.figure()
sns.heatmap(localQ.T)
save_fig("a")
Saving figure a
In [80]:
a
save_fig("a")
Saving figure a
<matplotlib.figure.Figure at 0x1a1562a1d0>
In [55]:
import seaborn as sns
In [59]:
sns.heatmap(localQ, annot=True)
Out[59]:
<matplotlib.axes._subplots.AxesSubplot at 0x1a0ab82198>
In [54]:
localQ
Out[54]:
Steps
residue
value
0
0
1
1.00
18
0
2
1.00
36
0
3
1.00
54
0
4
1.00
72
0
5
1.00
90
0
6
1.00
108
0
7
1.00
126
0
8
1.00
144
0
9
1.00
162
0
10
1.00
180
0
11
1.00
198
0
12
1.00
216
0
13
1.00
234
0
14
1.00
252
0
15
1.00
270
0
16
1.00
288
0
17
1.00
306
0
18
1.00
324
0
19
1.00
342
0
20
1.00
360
0
21
1.00
378
0
22
1.00
396
0
23
1.00
414
0
24
1.00
432
0
25
1.00
450
0
26
1.00
468
0
27
1.00
486
0
28
1.00
504
0
29
1.00
522
0
30
1.00
...
...
...
...
2735
68000
152
0.50
2753
68000
153
0.60
2771
68000
154
0.50
2789
68000
155
0.50
2807
68000
156
0.56
2825
68000
157
0.38
2843
68000
158
0.43
2861
68000
159
0.78
2879
68000
160
0.50
2897
68000
161
0.33
2915
68000
162
0.90
2933
68000
163
0.80
2951
68000
164
0.65
2969
68000
165
0.67
2987
68000
166
0.80
3005
68000
167
0.71
3023
68000
168
0.79
3041
68000
169
0.70
3059
68000
170
0.71
3077
68000
171
0.89
3095
68000
172
0.91
3113
68000
173
0.62
3131
68000
174
0.50
3149
68000
175
0.76
3167
68000
176
0.78
3185
68000
177
1.00
3203
68000
178
0.50
3221
68000
179
0.56
3239
68000
180
0.50
3257
68000
181
1.00
3258 rows × 3 columns
In [47]:
localQ.sort_values(by=["Steps", "residue"])
Out[47]:
Steps
residue
value
0
0
0
1.00
18
0
1
1.00
36
0
2
1.00
54
0
3
1.00
72
0
4
1.00
90
0
5
1.00
108
0
6
1.00
126
0
7
1.00
144
0
8
1.00
162
0
9
1.00
180
0
10
1.00
198
0
11
1.00
216
0
12
1.00
234
0
13
1.00
252
0
14
1.00
270
0
15
1.00
288
0
16
1.00
306
0
17
1.00
324
0
18
1.00
342
0
19
1.00
360
0
20
1.00
378
0
21
1.00
396
0
22
1.00
414
0
23
1.00
432
0
24
1.00
450
0
25
1.00
468
0
26
1.00
486
0
27
1.00
504
0
28
1.00
522
0
29
1.00
...
...
...
...
2735
68000
151
0.50
2753
68000
152
0.60
2771
68000
153
0.50
2789
68000
154
0.50
2807
68000
155
0.56
2825
68000
156
0.38
2843
68000
157
0.43
2861
68000
158
0.78
2879
68000
159
0.50
2897
68000
160
0.33
2915
68000
161
0.90
2933
68000
162
0.80
2951
68000
163
0.65
2969
68000
164
0.67
2987
68000
165
0.80
3005
68000
166
0.71
3023
68000
167
0.79
3041
68000
168
0.70
3059
68000
169
0.71
3077
68000
170
0.89
3095
68000
171
0.91
3113
68000
172
0.62
3131
68000
173
0.50
3149
68000
174
0.76
3167
68000
175
0.78
3185
68000
176
1.00
3203
68000
177
0.50
3221
68000
178
0.56
3239
68000
179
0.50
3257
68000
180
1.00
3258 rows × 3 columns
In [ ]:
In [ ]:
cols = list(df)
cols.insert(0, cols.pop(cols.index('Steps')))
df = df.loc[:, cols]
In [ ]:
localQ.reindex()
In [12]:
localQ.pivot()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-09caf176e045> in <module>()
----> 1 localQ.pivot()
~/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in pivot(self, index, columns, values)
3851 """
3852 from pandas.core.reshape.reshape import pivot
-> 3853 return pivot(self, index=index, columns=columns, values=values)
3854
3855 def stack(self, level=-1, dropna=True):
~/anaconda3/lib/python3.6/site-packages/pandas/core/reshape/reshape.py in pivot(self, index, columns, values)
367 cols = [columns] if index is None else [index, columns]
368 append = index is None
--> 369 indexed = self.set_index(cols, append=append)
370 return indexed.unstack(columns)
371 else:
~/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in set_index(self, keys, drop, append, inplace, verify_integrity)
2828 names.append(None)
2829 else:
-> 2830 level = frame[col]._values
2831 names.append(col)
2832 if drop:
~/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key)
1962 return self._getitem_multilevel(key)
1963 else:
-> 1964 return self._getitem_column(key)
1965
1966 def _getitem_column(self, key):
~/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_column(self, key)
1969 # get column
1970 if self.columns.is_unique:
-> 1971 return self._get_item_cache(key)
1972
1973 # duplicate columns & possible reduce dimensionality
~/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py in _get_item_cache(self, item)
1643 res = cache.get(item)
1644 if res is None:
-> 1645 values = self._data.get(item)
1646 res = self._box_item_values(item, values)
1647 cache[item] = res
~/anaconda3/lib/python3.6/site-packages/pandas/core/internals.py in get(self, item, fastpath)
3597 loc = indexer.item()
3598 else:
-> 3599 raise ValueError("cannot label index with a null key")
3600
3601 return self.iget(loc, fastpath=fastpath)
ValueError: cannot label index with a null key
In [ ]:
Content source: luwei0917/awsemmd_script
Similar notebooks: