-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstructform.py
55 lines (42 loc) · 1.53 KB
/
structform.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
from numpy import *
from physics import *
from scipy.interpolate import interp1d
def sigma1DNorm(chan,rs):
if chan == 'sWave':
return 1.
elif chan == 'pWave':
return rs*1e-11/sqrt(100.)
def getstructform(chan,structFormType):
if chan == 'sWave':
structFormFName = (
{'rho_eff_Einasto_subs':'structFormData/rho_eff_Einasto_subs.txt',
'rho_eff_Einasto_no_subs':'structFormData/rho_eff_Einasto_no_subs.txt',
'rho_eff_NFW_subs':'structFormData/rho_eff_NFW_subs_corrected.txt',
'rho_eff_NFW_no_subs':'structFormData/rho_eff_NFW_no_subs.txt'}
)
elif chan == 'pWave':
structFormFName = (
{'rho_eff_Einasto_subs':'structFormData/rho_eff_Einasto_subs_pwave.txt',
'rho_eff_NFW_subs':'structFormData/rho_eff_NFW_subs_pwave.txt'
}
)
a = loadtxt(structFormFName[structFormType])
# Convert to 1 + z
rhoEff = vstack((a[:,0],a[:,2]))
rhoEff[0,:] += 1
# Convert the density to eV, and also the fact that the densities are normalized to rhoM instead of rhoDM
rhoEff[1,:] *= 1e9*rhoDM/1.50389e3
interpRhoEff = interp1d(rhoEff[0,:],rhoEff[1,:])
maxrsInterp = 52
def structform(rs):
rho = zeros(rs.size)
interpRhoInd = where(rs <= maxrsInterp)
anaRhoInd = where(rs > maxrsInterp)
if chan == 'sWave':
rho[interpRhoInd] = interpRhoEff(rs[interpRhoInd])
rho[anaRhoInd] = rhoDM*rs[anaRhoInd]**3
elif chan == 'pWave':
rho[interpRhoInd] = interpRhoEff(rs[interpRhoInd])*rs[interpRhoInd]
rho[anaRhoInd] = rhoDM*rs[anaRhoInd]**3*sigma1DNorm(chan,rs[anaRhoInd])
return rho
return structform