Skip to content

Commit

Permalink
Merge pull request yt-project#3877 from meeseeksmachine/auto-backport…
Browse files Browse the repository at this point in the history
…-of-pr-3868-on-yt-4.0.x

Backport PR yt-project#3868 on branch yt-4.0.x (BUG: Use cm_per_mpc instead of 3.08e24 yt-project#3867)
  • Loading branch information
neutrinoceros authored Mar 31, 2022
2 parents 6db2d16 + 59ab080 commit da27553
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion yt/frontends/ramses/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions yt/frontends/ramses/tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit da27553

Please sign in to comment.