You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking at the yt docs (https://yt-project.org/doc/examining/loading_data.html#ramses-data), ('star', particle_birth_time') should give me the formation time relative to the big bang and ('star', 'star_age') should give me the number of years a star particle's been around. Instead, it seems the other way around -- I'm getting formation times of 0 Myr and ages equal to the output's current time (see example below)., where I'd expect the smallest birth time to be ~171 Myr and the smallest age to be ~0 Myr.
The ages from ramses/utils/f90/getstarlist.f90 match particle_birth_time as currently calculated in yt, mostly to within +/- 1 Myr, with some tail. Indeed, the return (tsim - t) * t_scale line in convert_ramses_ages is how ages are calculated in getstarlist.f90 (see line 336 in https://bitbucket.org/rteyssie/ramses/src/master/utils/f90/getstarlist.f90).
So, in yt particle_birth_time = formation_time = time_simu - t should actually be star_age , and the function star_age returns data.ds.current_time - formation_time = time_tot + time_simu - time_simu + t = time_tot + t = particle_birth_time. These time_simu and time_tot parameters are calculated from the friedman function from ramses, which is reproduced in yt. t is the birth time of the star. I think the fix then is something like: convert_rames_ages in frontends/ramses/io.py instead of returning
(tsim - t) * t_scale
should return
data.ds.current_time - ((tsim - t) * t_scale)
or similar.
Code for reproduction
(Sorry, haven't had time to test with the yt data files, can do if you need me to)
importytimportnumpyasnpfromyt.data_objects.particle_filtersimportadd_particle_filterprint('yt version:', yt.__version__)
bbox= [[0.4, 0.4, 0.4], [0.6, 0.6, 0.6]]
ds=yt.load('./output_00031', bbox=bbox)
c=ds.arr([50., 50., 50.], 'Mpccm/h')
r=ds.arr(5., 'Mpccm/h')
# Get a spheres=ds.sphere(c, r)
# Print current timeprint(f'ds.current_time: {ds.current_time.in_units("Myr"):.6f}')
print(f'ds.cosmology.t_from_z(ds.current_redshift): {ds.cosmology.t_from_z(ds.current_redshift).in_units("Myr"):.6f}')
# Check they all have the right family valueassert((s['star', 'particle_family'] ==2).all())
# Try native particle_birth_time from yt-determined starst=s['star', 'particle_birth_time'].in_units('Myr')
a=s['star', 'star_age'].in_units('Myr')
print('-- using star family')
print(f'(birth) min: {t.min():.3f}, min nonzero: {t[t>0.].min():.3f}, max: {t.max():.3f}')
print(f'(age) min: {a.min():.3f}, min nonzero: {a[a>0.].min():.3f}, max: {a.max():.3f}')
print(f'(b+a) allclose(a+t, ds.current_time): {np.allclose(np.array(a+t), np.array(ds.current_time.in_units("Myr")))}')
# Try explicitly filtering particles a la docsdeffiltered_stars(pfilter, data):
filter=data['io', 'conformal_birth_time'] !=0returnfilteradd_particle_filter('filtered_stars',
function=filtered_stars,
filtered_type='io',
requires=['conformal_birth_time'] )
ds.add_particle_filter('filtered_stars')
# Get a spheres=ds.sphere(c, r)
t=s['filtered_stars', 'particle_birth_time'].in_units('Myr')
a=s['filtered_stars', 'star_age'].in_units('Myr')
print('-- using particle filter')
print(f'(birth) min: {t.min():.3f}, min nonzero: {t[t>0.].min():.3f}, max: {t.max():.3f}')
print(f'(age) min: {a.min():.3f}, min nonzero: {a[a>0.].min():.3f}, max: {a.max():.3f}')
print(f'(b+a) allclose(a+t, ds.current_time): {np.allclose(np.array(a+t), np.array(ds.current_time.in_units("Myr")))}')
Expected outcome
Would expect birth times >~ 171 Myr (from looking at the simulation output logs) and stellar ages from 0 (youngest) to 381 - 171 = 210 Myr (current time - oldest).
Version Information
Operating System: Ubuntu 18.04
Python Version: 3.8.5
yt version: 4.0.2
Other Libraries (if applicable): numpy
python from anaconda distribution, yt installed through pip.
The text was updated successfully, but these errors were encountered:
Hi, and welcome to yt! Thanks for opening your first issue. We have an issue template that helps us to gather relevant information to help diagnosing and fixing the issue.
Bug report
Bug summary
Looking at the yt docs (https://yt-project.org/doc/examining/loading_data.html#ramses-data),
('star', particle_birth_time')
should give me the formation time relative to the big bang and('star', 'star_age')
should give me the number of years a star particle's been around. Instead, it seems the other way around -- I'm getting formation times of 0 Myr and ages equal to the output's current time (see example below)., where I'd expect the smallest birth time to be ~171 Myr and the smallest age to be ~0 Myr.The ages from ramses/utils/f90/getstarlist.f90 match
particle_birth_time
as currently calculated in yt, mostly to within +/- 1 Myr, with some tail. Indeed, thereturn (tsim - t) * t_scale
line inconvert_ramses_ages
is how ages are calculated in getstarlist.f90 (see line 336 in https://bitbucket.org/rteyssie/ramses/src/master/utils/f90/getstarlist.f90).So, in yt
particle_birth_time = formation_time = time_simu - t
should actually bestar_age
, and the functionstar_age
returnsdata.ds.current_time - formation_time = time_tot + time_simu - time_simu + t = time_tot + t = particle_birth_time
. Thesetime_simu
andtime_tot
parameters are calculated from thefriedman
function from ramses, which is reproduced in yt.t
is the birth time of the star. I think the fix then is something like:convert_rames_ages
in frontends/ramses/io.py instead of returning(tsim - t) * t_scale
should return
data.ds.current_time - ((tsim - t) * t_scale)
or similar.
Code for reproduction
(Sorry, haven't had time to test with the yt data files, can do if you need me to)
Actual outcome
Expected outcome
Would expect birth times >~ 171 Myr (from looking at the simulation output logs) and stellar ages from 0 (youngest) to 381 - 171 = 210 Myr (current time - oldest).
Version Information
python from anaconda distribution, yt installed through pip.
The text was updated successfully, but these errors were encountered: