-
Notifications
You must be signed in to change notification settings - Fork 1
/
findcluster.py
48 lines (40 loc) · 1.69 KB
/
findcluster.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
# functions to find and mark cluster in low res DM only zoom in
# version for 600 Mpc volume
kpcunit = 600000.0
msolunit = 2.7523584e+19
omega = 0.3086
medmass = omega/(288*2**5)**3
def findgal() :
charm.createGroup_AttributeRange('highres', 'All', 'mass', -1, medmass*1.1)
cntMass = charm.getCenterOfMass('highres')
# get 5 Mpc sphere around cntMass
charm.createGroupAttributeSphere('center', 'All', 'position', cntMass[0],
cntMass[1], cntMass[2], 5000./kpcunit)
cntPot = charm.findAttributeMin('center', 'potential')
return cntPot
def mtot(group) :
dmass = charm.getAttributeSum(group, 'dark', 'mass')
return dmass
# gmass = charm.getAttributeSum(group, 'gas', 'mass')
# smass = charm.getAttributeSum(group, 'star', 'mass')
# return dmass + gmass + smass
def density(group, r) :
from math import pi
v = (4*pi/3.0)*r**3
return mtot(group)/v
def getgaldensity(center, r) :
global kpcunit
charm.createGroupAttributeSphere('gal', 'All', 'position', center[0],
center[1], center[2], r/kpcunit)
return density('gal', r/kpcunit)
def getmass(group):
return msolunit*charm.getAttributeSum(group, 'dark', 'mass')
def writemark() :
charm.writeGroupArray('gal', 'index', 'vir3.mark')
def writemark_hres() :
"""Get just the high res particles out of the gal group and write out their indices"""
charm.createGroup_AttributeRange('galhighres', 'gal', 'mass', -1, medmass*1.1)
charm.writeGroupArray('gal', 'index', 'vir3hr.mark')
def readmark() :
charm.readMark('/tmp/vir3.mark', 'mark', 'index')
charm.createGroup_AttributeRange('marked', 'All', 'mark', 1., 100.)