-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathangmom.py
More file actions
41 lines (32 loc) · 885 Bytes
/
angmom.py
File metadata and controls
41 lines (32 loc) · 885 Bytes
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
import matplotlib
matplotlib.use('Agg')
import src as pr
import numpy as np
import pylab as pl
from scipy import integrate
import time
base= '/n/hernquistfs2/fbecerra/'
sim, snap = 'nahw1', 137
Rvir = 1400
fields = ['angmom', 'rho', 'tff']
print snap
path = base+sim+'/snapdir_%03d/' %snap
file = sim+'_%03d' %snap
snapbase = path+file
MySnap = pr.snap.Snap()
MySnap.read_header(snapbase)
MySnap.read_fields(snapbase)
MySnap.center_box()
MySnap.rotate_box()
MySnap.calculate_radius()
MyRadial = pr.radial.Radial()
MyRadial.radial_profile(MySnap, fields)
radius = 10**MyRadial.radial['radius']
f = radius - Rvir
idx_rvir = np.where(f > 0)[0][0]
angmom = 10**MyRadial.radial['angmom'][idx_rvir]
dens = 10**MyRadial.radial['rho'][idx_rvir]
tff = 10**MyRadial.radial['tff'][idx_rvir]
print 'Angular momentum: ', angmom
print 'Volume density: ', dens
print 'Free-fall time: ', tff