diff --git a/yt/frontends/ramses/data_structures.py b/yt/frontends/ramses/data_structures.py index 471ff8aae31..335f3374f09 100644 --- a/yt/frontends/ramses/data_structures.py +++ b/yt/frontends/ramses/data_structures.py @@ -18,6 +18,7 @@ from yt.utilities.lib.cosmology_time import friedman from yt.utilities.on_demand_imports import _f90nml as f90nml from yt.utilities.physical_constants import kb, mp +from yt.utilities.physical_ratios import cm_per_mpc from .definitions import ( OUTPUT_DIR_EXP, @@ -973,7 +974,7 @@ def caster(val): self.current_time = ( (self.time_tot + self.time_simu) - / (self.hubble_constant * 1e7 / 3.08e24) + / (self.hubble_constant * 1e7 / cm_per_mpc) / self.parameters["unit_t"] ) except IndexError: diff --git a/yt/frontends/ramses/tests/test_outputs.py b/yt/frontends/ramses/tests/test_outputs.py index 5a39a0860dc..868c58b1363 100644 --- a/yt/frontends/ramses/tests/test_outputs.py +++ b/yt/frontends/ramses/tests/test_outputs.py @@ -119,10 +119,15 @@ def test_unit_cosmo(): for force_cosmo in [True, None]: ds = yt.load(ramsesCosmo, cosmological=force_cosmo) - expected_raw_time = 1.119216564055017 # in ramses unit + # NOTE: these are the old test values, which used 3.08e24 as + # the Mpc to cm conversion factor + # expected_raw_time = 1.119216564055017 # in ramses unit + # expected_time = 3.756241729312462e17 # in seconds + + expected_raw_time = 1.121279694787743 # in ramses unit assert_equal(ds.current_time.value, expected_raw_time) - expected_time = 3.756241729312462e17 # in seconds + expected_time = 3.7631658742904595e17 # in seconds assert_equal(ds.current_time.in_units("s").value, expected_time)