Skip to content

Commit

Permalink
Updated _is_valid
Browse files Browse the repository at this point in the history
Newer (post Apr 2021) versions of gizmo export GIZMO_version=year_of_last_commit as a header variable. We should use this in preference to checking the gas metallicity, which might not exist. Since the names of the omegas have changed, we don't want to fall back to the gadget loader in the comoving case (in the non-cosmo case it shouldn't matter?)
  • Loading branch information
mtryan83 committed Jul 17, 2023
1 parent 680c412 commit fdc78e8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions yt/frontends/gizmo/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ def _is_valid(cls, filename, *args, **kwargs):
valid = all(ng in fh["/"] for ng in need_groups) and not any(
vg in fh["/"] for vg in veto_groups
)
dmetal = "/PartType0/Metallicity"
if dmetal not in fh or (fh[dmetal].ndim > 1 and fh[dmetal].shape[1] < 11):
valid = False
# From Apr 2021, 7f1f06f, public gizmo includes a header variable
# GIZMO_version, which is set to the year of the most recent commit
# We should prefer this to checking the metallicity, which might
# not exist
if "GIZMO_version" not in fh["/Header"].attrs:
dmetal = "/PartType0/Metallicity"
if dmetal not in fh or (fh[dmetal].ndim > 1 and fh[dmetal].shape[1] < 11):
valid = False
fh.close()
except Exception:
valid = False
Expand Down

0 comments on commit fdc78e8

Please sign in to comment.