Skip to content

Commit

Permalink
Merge pull request #4915 from chrishavlin/cf_radial_validation
Browse files Browse the repository at this point in the history
add check for Sub_conventions for CFradial
  • Loading branch information
matthewturk authored Jul 9, 2024
2 parents 2b68a48 + 4cb2db2 commit e08736f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions yt/frontends/cf_radial/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,14 @@ def _is_valid(cls, filename: str, *args, **kwargs) -> bool:
nc4_file = NetCDF4FileHandler(filename)
with nc4_file.open_ds(keepweakref=True) as ds:
con = "Conventions" # the attribute to check for file conventions
# note that the attributes here are potentially space- or
# comma-delimited strings, so we concatenate a single string
# to search for a substring.
cons = "" # the value of the Conventions attribute
for c in [con, con.lower()]:
for c in [con, con.lower(), "Sub_" + con.lower()]:
if hasattr(ds, c):
cons += getattr(ds, c)
is_cfrad = "CF/Radial" in cons
is_cfrad = "CF/Radial" in cons or "CF-Radial" in cons
except (OSError, AttributeError, ImportError):
return False

Expand Down

0 comments on commit e08736f

Please sign in to comment.