Commit b15ed34f authored by Maxime Rey's avatar Maxime Rey
Browse files

New function: Included new function to compute aout for namelists.

parent 811f8c45
......@@ -61,4 +61,25 @@ def h5_list(filepath):
import h5py
thefile = h5py.File(filepath,'r+')
print(list(thefile.keys()), len(thefile.keys()))
\ No newline at end of file
print(list(thefile.keys()), len(thefile.keys()))
def compute_aout(dt=10, z_init=15, nbins=10, zmin=None, checktimes=False):
""" Generate sequence of aexp for evenly-timed (dt in Myrs) ramses outputs in the ramses namelist format. JB & modifs from MR."""
from astropy import cosmology
from astropy import units as u
cosmo = cosmology.FlatLambdaCDM(H0=70 * / u.s / u.Mpc, Tcmb0=2.725 * u.K, Om0=0.3)
dt *= u.Myr
time_at_zmax = cosmo.age(z_init)
if zmin:
nbins = int(((cosmo.age(zmin) - time_at_zmax) / dt).decompose())+1
times = ((time_at_zmax + range(nbins)*dt).to(u.Gyr))
aout = []
for t in times:
zs = cosmology.z_at_value(cosmo.age,t)
if checktimes:
for a in aout: # If you want to check
return aout
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment