yt icon indicating copy to clipboard operation
yt copied to clipboard

Detecting conformal time in Ramses

Open Martin-Rey opened this issue 3 months ago • 2 comments

Hi,

I am having issue with the automated detection of conformal/proper time for a Ramses snapshot.

The snapshot is correctly flagged as a cosmological run, the RT fields are detected, but use_conformal_time remains True.

In [1]: import yt

In [2]: s = yt.load("./output_00192/")
yt : [INFO     ] 2025-10-15 12:22:23,511 Parameters: current_time              = 12.319863697238487 Gyr
yt : [INFO     ] 2025-10-15 12:22:23,511 Parameters: domain_dimensions         = [256 256 256]
yt : [INFO     ] 2025-10-15 12:22:23,511 Parameters: domain_left_edge          = [0. 0. 0.]
yt : [INFO     ] 2025-10-15 12:22:23,511 Parameters: domain_right_edge         = [1. 1. 1.]
yt : [INFO     ] 2025-10-15 12:22:23,512 Parameters: cosmological_simulation   = True
yt : [INFO     ] 2025-10-15 12:22:23,512 Parameters: current_redshift          = 0.11107106477806394
yt : [INFO     ] 2025-10-15 12:22:23,512 Parameters: omega_lambda              = 0.691399991512299
yt : [INFO     ] 2025-10-15 12:22:23,512 Parameters: omega_matter              = 0.308600008487701
yt : [INFO     ] 2025-10-15 12:22:23,512 Parameters: omega_radiation           = 0.0
yt : [INFO     ] 2025-10-15 12:22:23,512 Parameters: hubble_constant           = 0.6776999664306641

In [3]: s.use_conformal_time
Out[3]: True

In [4]: s.fluid_types
Out[4]: ('gas', 'deposit', 'index', 'ramses-rt', 'gravity', 'ramses')

I tracked the issue to the code here: https://github.com/yt-project/yt/blob/744b51bd6fdff588b1d26759f4984e3ec793da94/yt/frontends/ramses/data_structures.py#L877-L885

Even though the RT fields are detected with ramses-rt in fluid_types, the specific rt fluid type is not available until gas loading has been explicitly attempted. The if statement then fails and returns use_conformal_time=True.

I am not familiar enough with all the ins and outs of YT, but a simple fix could to replace if "rt" in by if "ramses-rt" in, or another more robust test taking into account partial loading.

Martin-Rey avatar Oct 15 '25 11:10 Martin-Rey

pinging our ramses expert @cphyc

chrishavlin avatar Oct 15 '25 14:10 chrishavlin

I just looked into the code, and I think we have two, maybe three issues here:

  1. I agree - the if "rt" in self.fluid_types should be if "ramses-rt" in self.fluid_types.
  2. Assuming this was correctly set (either automatically or manually passing the use_conformal_time=False to yt.load(...), the function that converts from conformal to physical will, unfortunately, happily disregard the flag, see https://github.com/yt-project/yt/blob/744b51bd6fdff588b1d26759f4984e3ec793da94/yt/frontends/ramses/particle_handlers.py#L349
  3. From discussions with @Martin-Rey, there might be a third bug that somehow overrides the ds.use_conformal_time flag. This should not happen, but let's investigate closer.

I'll iterate with Martin to get a working solution; it shouldn't be too hard, just a matter of fixing the logic!

cphyc avatar Oct 15 '25 14:10 cphyc