From ba928a32d3266309379cf96f2a52de205f643627 Mon Sep 17 00:00:00 2001 From: chrishavlin Date: Thu, 30 May 2024 15:09:40 -0500 Subject: [PATCH 1/2] add check for Sub_conventions for CFradial --- yt/frontends/cf_radial/data_structures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yt/frontends/cf_radial/data_structures.py b/yt/frontends/cf_radial/data_structures.py index 436517b3004..25592e6a2d5 100644 --- a/yt/frontends/cf_radial/data_structures.py +++ b/yt/frontends/cf_radial/data_structures.py @@ -311,10 +311,10 @@ def _is_valid(cls, filename: str, *args, **kwargs) -> bool: with nc4_file.open_ds(keepweakref=True) as ds: con = "Conventions" # the attribute to check for file conventions 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 From 4cb2db2093184080874525f16c06b36520039d86 Mon Sep 17 00:00:00 2001 From: chavlin Date: Fri, 31 May 2024 10:30:29 -0500 Subject: [PATCH 2/2] add comment on string attributes in cf_radial _is_valid --- yt/frontends/cf_radial/data_structures.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yt/frontends/cf_radial/data_structures.py b/yt/frontends/cf_radial/data_structures.py index 25592e6a2d5..1c1309510d0 100644 --- a/yt/frontends/cf_radial/data_structures.py +++ b/yt/frontends/cf_radial/data_structures.py @@ -310,6 +310,9 @@ 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(), "Sub_" + con.lower()]: if hasattr(ds, c):