From 6569aacb0a938f22a66736fafaa70bf32a527349 Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Mon, 13 Jan 2025 17:30:45 +0000 Subject: [PATCH 1/3] Prevent UnboundLocalError in read from UGRID mesh report --- cfdm/read_write/netcdf/netcdfread.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cfdm/read_write/netcdf/netcdfread.py b/cfdm/read_write/netcdf/netcdfread.py index e6ab57bf5..f279ad2c0 100644 --- a/cfdm/read_write/netcdf/netcdfread.py +++ b/cfdm/read_write/netcdf/netcdfread.py @@ -10,6 +10,7 @@ from dataclasses import dataclass, field from functools import reduce from math import nan, prod +from pprint import pformat from typing import Any from urllib.parse import urlparse from uuid import uuid4 @@ -3787,9 +3788,10 @@ def _create_field_or_domain( ugrid = False logger.warning( "There was a problem parsing the UGRID mesh " - f"topology variable {mesh.mesh_ncvar!r}: " - f"Ignoring the UGRID mesh for {field_ncvar!r}." + "topology variable. Ignoring the UGRID mesh " + f"for {field_ncvar!r}." ) + logger.debug(f"Mesh dictionary is: {pformat(g['mesh'])}") if ugrid: # The UGRID specification is OK, so get the auxiliary From fac532c69e9234052d256a6185a90e307bb0ea28 Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Mon, 13 Jan 2025 18:07:08 +0000 Subject: [PATCH 2/3] Update Changelog for PR to close #315 --- Changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.rst b/Changelog.rst index 5b47696a5..14c827254 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -22,6 +22,9 @@ Version NEXTVERSION * Fix bug that caused `cfdm.write` to fail when a parametric Z dimension coordinate did not have a ``computed_standard_name`` attribute (https://github.com/NCAS-CMS/cfdm/issues/303) +* Fix bug that caused `cfdm.read` to fail to read at all + datasets including variables with badly-encoded UGRID meshes + (https://github.com/NCAS-CMS/cfdm/issues/315) * New class `cfdm.H5netcdfArray` * New class `cfdm.NetCDF4Array` * New dependency: ``h5netcdf>=1.3.0`` From f89726e8f169edd807721309ec9242f4d229a3b0 Mon Sep 17 00:00:00 2001 From: "Sadie L. Bartholomew" Date: Tue, 21 Jan 2025 11:37:42 +0000 Subject: [PATCH 3/3] Update netcdfread.py to remove duplicate import --- cfdm/read_write/netcdf/netcdfread.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cfdm/read_write/netcdf/netcdfread.py b/cfdm/read_write/netcdf/netcdfread.py index 8b8b27ccd..be1e37b37 100644 --- a/cfdm/read_write/netcdf/netcdfread.py +++ b/cfdm/read_write/netcdf/netcdfread.py @@ -9,7 +9,6 @@ from copy import deepcopy from dataclasses import dataclass, field from functools import reduce -from math import nan, prod from pprint import pformat from math import log, nan, prod from numbers import Integral