Repository: yt-project/yt

Issue:
RAMSES data at high redshift
Hello,
I have been user of YT for a year and experienced a little trouble to read my latest RAMSES simulation. I want to use RAMSES at very high redshift (start at z~1000 with no radiation) and use a different parametrization for scale factor ( a(t) prpto t). It implies that I am having very high values for z and t_frw leading YT to raise the following error.

Here is the code I wrote :
```python
import yt
ds = yt.load('output_00131/info_00131.txt')
```

And here is the error message :
```
IndexError                                Traceback (most recent call last)
<ipython-input-7-49e2114551c4> in <module>
----> 1 ds = yt.load('output_00131/info_00131.txt')

~/.local/lib/python3.6/site-packages/yt/convenience.py in load(*args, **kwargs)
     84     candidates = find_lowest_subclasses(candidates)
     85     if len(candidates) == 1:
---> 86         return candidates[0](*args, **kwargs)
     87     if len(candidates) == 0:
     88         if ytcfg.get("yt", "enzo_db") != '' \

~/.local/lib/python3.6/site-packages/yt/frontends/ramses/data_structures.py in __init__(self, filename, dataset_type, fields, storage_filename, units_override, unit_system, extra_particle_fields, cosmological, bbox)
    410 
    411         Dataset.__init__(self, filename, dataset_type, units_override=units_override,
--> 412                          unit_system=unit_system)
    413 
    414         # Add the particle types

~/.local/lib/python3.6/site-packages/yt/data_objects/static_output.py in __init__(self, filename, dataset_type, file_style, units_override, unit_system)
    247         self._create_unit_registry()
    248 
--> 249         self._parse_parameter_file()
    250         self.set_units()
    251         self._assign_unit_system(unit_system)

~/.local/lib/python3.6/site-packages/yt/frontends/ramses/data_structures.py in _parse_parameter_file(self)
    575             iage = np.min([iage,self.n_frw//2 + (iage - self.n_frw//2)//10])
    576 
--> 577             self.time_simu = self.t_frw[iage  ]*(age-self.tau_frw[iage-1])/(self.tau_frw[iage]-self.tau_frw[iage-1])+ \
    578                              self.t_frw[iage-1]*(age-self.tau_frw[iage  ])/(self.tau_frw[iage-1]-self.tau_frw[iage])
    579 

IndexError: index 2686 is out of bounds for axis 0 with size 1001
```

As I understood, I just need the place where the bounds for those parameters in YT is stored.
My dataset can be dowloaded here : https://filesender.renater.fr/?s=download&token=663f4954-6761-4313-b01f-222e5a026034


edit by @neutrinoceros : code formatting


Discussion:
As a temporary workaround, can you confirm that loading with
```python
import yt
ds = yt.load('output_00131/info_00131.txt', cosmological=False)
```
does work?
It will prevent yt from trying to convert from RAMSES times to physical times (and should prevent the error you have). The problem is then that you don't have `ds.current_redshit` defined, and the times you get will likely be incorrectly converted.
Note that this is indeed a bug, caused by yt's internal assumption that RAMSES times are given in "super-comoving" units (see https://ui.adsabs.harvard.edu/abs/1998MNRAS.297..467M/abstract).
You can bypass that by preventing its detection as a "cosmological" simulation.
Yes, I worked and indeed in that case the redshift is not printed. Thanks a lot !

Resolving patch:
diff --git a/yt/frontends/ramses/data_structures.py b/yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -822,17 +822,25 @@ def read_rhs(f, cast):
             iage = 1 + int(10.0 * age / self.dtau)
             iage = np.min([iage, self.n_frw // 2 + (iage - self.n_frw // 2) // 10])
 
-            self.time_simu = self.t_frw[iage] * (age - self.tau_frw[iage - 1]) / (
-                self.tau_frw[iage] - self.tau_frw[iage - 1]
-            ) + self.t_frw[iage - 1] * (age - self.tau_frw[iage]) / (
-                self.tau_frw[iage - 1] - self.tau_frw[iage]
-            )
+            try:
+                self.time_simu = self.t_frw[iage] * (age - self.tau_frw[iage - 1]) / (
+                    self.tau_frw[iage] - self.tau_frw[iage - 1]
+                ) + self.t_frw[iage - 1] * (age - self.tau_frw[iage]) / (
+                    self.tau_frw[iage - 1] - self.tau_frw[iage]
+                )
 
-            self.current_time = (
-                (self.time_tot + self.time_simu)
-                / (self.hubble_constant * 1e7 / 3.08e24)
-                / self.parameters["unit_t"]
-            )
+                self.current_time = (
+                    (self.time_tot + self.time_simu)
+                    / (self.hubble_constant * 1e7 / 3.08e24)
+                    / self.parameters["unit_t"]
+                )
+            except IndexError:
+                mylog.warning(
+                    "Yt could not convert conformal time to physical time. "
+                    "Yt will assume the simulation is *not* cosmological."
+                )
+                self.cosmological_simulation = 0
+                self.current_time = self.parameters["time"]
 
         if self.num_groups > 0:
             self.group_size = rheader["ncpu"] // self.num_groups


Test patch: