-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDensity1.py
71 lines (48 loc) · 1.36 KB
/
Density1.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import sys
import os
import math
import numpy as np
sys.path.append('.')
import cPickle
import CellModeller
import matplotlib.pyplot as plt
file = sys.argv[1] #select pickle file in command line
data = cPickle.load(open(file,'r'))
def rad_pos(cellstate):
return np.sqrt(cellstate.pos[0]*cellstate.pos[0]+cellstate.pos[1]*cellstate.pos[1])
def area_cell(cellstate):
return 2.0*cellstate.length*cellstate.radius+np.pi*cellstate.radius*cellstate.radius
def r_delta(rmax,lmax):
n=int(np.floor(rmax/(6*lmax)))
rDelta=int(np.floor(rmax/n))
return rDelta
cs = data['cellStates']
ncells=len(cs)
r=np.zeros((ncells,4))
i=0
for it in cs:
radialPosition = rad_pos(cs[it])
area=area_cell(cs[it])
r[i,0]=radialPosition
r[i,1]=cs[it].length
r[i,2]=cs[it].radius
r[i,3]=area
i=i+1
rsort_poss=np.sort(r,0)
lmax=np.amax(r[:,1])
rmax=int(np.floor(np.amax(r[:,0])))
rDelta=r_delta(rmax,lmax)
for r0 in range(0,rmax-rDelta):
r1=r0+rDelta
a_ring=np.pi*(r1*r1-r0*r0)
a_cell=0.0
j=0
for i in range(len(rsort_poss[:,0])):
if float(r0)<=rsort_poss[i,0] and float(r1)>=rsort_poss[i,0]:
a_cell=a_cell+rsort_poss[i,3]
j+=1
elif r1<rsort_poss[i,0]:
break
print(r0,r1,a_ring,a_cell,a_cell/a_ring,j)
plt.plot(rsort_poss[:,0],rsort_poss[:,1])
plt.show()