Last active
July 10, 2023 15:26
-
-
Save syrte/0a54039cec242267ac7df1ccfcba18b5 to your computer and use it in GitHub Desktop.
exec and load Zhao+2009 model, see http://202.127.29.4/dhzhao/mandc.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
exec and load Zhao+2009 model | |
cf http://202.127.29.4/dhzhao/mandc.html | |
""" | |
import os | |
from astropy.io import ascii | |
def run(zobs, lgMobs): | |
cmd = f""" | |
./mandc.x <<EOF | |
cDekel | |
0.3 0.7 | |
1 | |
0.7 | |
0.82 | |
0.95 | |
0.048 2.7255 | |
1 | |
{zobs:g} | |
{lgMobs:g} | |
EOF | |
""" | |
os.system(cmd) | |
def convert_float(x): | |
try: | |
x = float(x) | |
except ValueError: | |
pass | |
return x | |
def load(file): | |
names1 = 'ispec,nbin1,zobs,omegam0,omegaL0,sigma8,tilt,omegab0,omeganu0,T_cmb,N_nu,note' | |
names2 = 'ziz,Miz,c,rhohiz,R,V,Ms,rhos,Rs,Vs,Miz_200c,c_200c,rhohiz_200c,Miz_200m,c_200m,rhohiz_200m,uniage_iz' | |
vals = [convert_float(x) for x in open(file).readline().split()] | |
param = dict(zip(names1.split(','), vals)) | |
table = ascii.read(file, data_start=1, names=names2.split(',')) | |
return param, table | |
if __name__ == '__main__': | |
# example | |
z = 0 | |
lgM = 12 | |
run(z, lgM) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment