-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute_rho_sites.py
54 lines (41 loc) · 1.31 KB
/
compute_rho_sites.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
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
import sys
from os import path
import numpy as np
import pickle
from qcnico.coords_io import read_xyz
structype = sys.argv[1]
if structype == '40x40':
xyz_prefix = 'bigMAC-'
lbls = np.arange(1,301)
else:
xyz_prefix = structype + 'n'
if structype == 'tempdot5':
lbls = np.arange(117)
else: #tempdot6
lbls = np.arange(132)
rho = np.zeros(lbls.shape[0])
succ = np.ones(lbls.shape[0],dtype='bool')
for k, nn in enumerate(lbls):
print(f'\n{k}', end = ' ')
try:
full_pos = read_xyz(path.expanduser(f'~/scratch/clean_bigMAC/{structype}/relaxed_structures_no_dangle/{xyz_prefix}{nn}_relaxed_no-dangle.xyz'))
full_pos = full_pos[:,:2]
with open(f'sample-{nn}/undistorted_clusters_{structype}-{nn}.pkl', 'rb') as fo:
clusters = pickle.load(fo)
except FileNotFoundError as e:
print('File not found!')
succ[k] = False
continue
xmin = np.min(full_pos[:,0])
ymin = np.min(full_pos[:,1])
xmax = np.max(full_pos[:,0])
ymax = np.max(full_pos[:,1])
area = (xmax - xmin) * (ymax - ymin)
nclusters = 0
for c in clusters:
if len(c) > 1: nclusters +=1
rho[k] = nclusters/area
lbls = lbls[succ]
rho = rho[succ]
np.save(f'rho_sites_{structype}.npy', np.vstack((lbls,rho)).T)