Repository: yt-project/yt

Issue:
Index Error updating from YT-3.4.0 to YT-3.5.1
<!--To help us understand and resolve your issue, please fill out the form to
the best of your ability.-->
<!--You can feel free to delete the sections that do not apply.-->

### Bug report

**Bug summary**

Index error after yt upgrade 

**Code for reproduction**

<!--A minimum code snippet required to reproduce the bug, also minimizing the
number of dependencies required.-->

<!-- If you need to use a data file to trigger the issue you're having, consider
using one of the datasets from the yt data hub (http://yt-project.org/data). If
your issue cannot be triggered using a public dataset, you can use the yt
curldrop (https://docs.hub.yt/services.html#curldrop) to share data
files. Please include a link to the dataset in the issue if you use the
curldrop.-->

```
import yt
from yt.units import kpc
import matplotlib.pyplot as plt
import numpy as np
np.set_printoptions(threshold=1500)
filename="/lunarc/nobackup/users/samvad/FINAL-50-0.5/output/output_00018/info_00018.txt"
ds=yt.load(filename)

for i in sorted(ds.derived_field_list):
        print(i)
```

**Actual outcome**

<!--The output produced by the above code, which may be a screenshot, console
output, etc.-->

```
File "fields.py", line 10, in <module>
    for i in sorted(ds.derived_field_list):
  File "yt/data_objects/static_output.py", line 216, in ireq
    self.index
  File "yt/data_objects/static_output.py", line 509, in index
    self, dataset_type=self.dataset_type)
  File "yt/frontends/ramses/data_structures.py", line 236, in __init__
    super(RAMSESIndex, self).__init__(ds, dataset_type)
  File "yt/geometry/geometry_handler.py", line 50, in __init__
    self._setup_geometry()
  File "yt/geometry/oct_geometry_handler.py", line 25, in _setup_geometry
    self._initialize_oct_handler()
  File "yt/frontends/ramses/data_structures.py", line 245, in _initialize_oct_handler
    for i in cpu_list]
  File "yt/frontends/ramses/data_structures.py", line 245, in <listcomp>
    for i in cpu_list]
  File "yt/frontends/ramses/data_structures.py", line 82, in __init__
    self._read_amr_header()
  File "yt/frontends/ramses/data_structures.py", line 141, in _read_amr_header
    hvals.update(f.read_attrs(header))
  File "yt/utilities/cython_fortran_utils.pyx", line 223, in yt.utilities.cython_fortran_utils.FortranFile.read_attrs
IndexError: index 0 is out of bounds for axis 0 with size 0
```

**Expected outcome**

has to print the fields in the data. Was working with yt 3.4.0

**Version Information**
<!--Please specify your platform and versions of the relevant libraries you are
using:-->
  * Operating System: Mac
  * Python Version: 3.6
  * yt version: 3.5.1
  * Other Libraries (if applicable): 

installed Anaconda separately and then did conda installation of YT using 'forge'
<!--Please tell us how you installed yt and python e.g., from source,
pip, conda. If you installed from conda, please specify which channel you used
if not the default-->



Discussion:

Resolving patch:
diff --git a/yt/frontends/ramses/definitions.py b/yt/frontends/ramses/definitions.py
--- a/yt/frontends/ramses/definitions.py
+++ b/yt/frontends/ramses/definitions.py
@@ -42,7 +42,8 @@ def ramses_header(hvals):
                  ('stat', 3, 'd'),
                  ('cosm', 7, 'd'),
                  ('timing', 5, 'd'),
-                 ('mass_sph', 1, 'd') )
+                 ('mass_sph', 1, 'd', True)
+                 )
     yield next_set
 
 field_aliases = {


Test patch:
diff --git a/yt/frontends/ramses/tests/test_outputs.py b/yt/frontends/ramses/tests/test_outputs.py
--- a/yt/frontends/ramses/tests/test_outputs.py
+++ b/yt/frontends/ramses/tests/test_outputs.py
@@ -373,10 +373,10 @@ def test_formation_time():
 
 @requires_file(ramses_new_format)
 def test_cooling_fields():
-    
+
     #Test the field is being loaded correctly
     ds=yt.load(ramses_new_format)
-    
+
     #Derived cooling fields
     assert ('gas','cooling_net') in ds.derived_field_list
     assert ('gas','cooling_total') in ds.derived_field_list
@@ -395,7 +395,7 @@ def test_cooling_fields():
     assert ('gas','heating_primordial_prime') in ds.derived_field_list
     assert ('gas','heating_compton_prime') in ds.derived_field_list
     assert ('gas','mu') in ds.derived_field_list
-    
+
     #Abundances
     assert ('gas','Electron_number_density') in ds.derived_field_list
     assert ('gas','HI_number_density') in ds.derived_field_list
@@ -426,3 +426,15 @@ def _mixed_field(field, data):
 
     # Access the field
     ds.r[('gas', 'mixed_files')]
+
+ramses_empty_record = "ramses_empty_record/output_00003/info_00003.txt"
+@requires_file(ramses_empty_record)
+def test_ramses_empty_record():
+    # Test that yt can load datasets with empty records
+    ds = yt.load(ramses_empty_record)
+
+    # This should not fail
+    ds.index
+
+    # Access some field
+    ds.r[('gas', 'density')]
\ No newline at end of file