From 0b355c962915ddc109096427f16a79a209d66965 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:50:03 -0500 Subject: [PATCH 1/2] ENH: Add axis attribute to 1-D latitude and longitude coordinates Recommended at the end of CF section 4: https://cfconventions.org/Data/cf-conventions/cf-conventions-1.12/cf-conventions.html#coordinate-types --- cfgrib/dataset.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cfgrib/dataset.py b/cfgrib/dataset.py index e213a728..f3ad4acf 100644 --- a/cfgrib/dataset.py +++ b/cfgrib/dataset.py @@ -414,6 +414,9 @@ def build_geography_coordinates( data=np.array(first["distinctLongitudes"], ndmin=1), attributes=COORD_ATTRS["longitude"], ) + # latitude and longitude are dimension coordinates + geo_coord_vars["latitude"].attrs["axis"] = "Y" + geo_coord_vars["longitude"].attrs["axis"] = "X" elif "geography" in encode_cf and grid_type in GRID_TYPES_2D_NON_DIMENSION_COORDS: geo_dims = ("y", "x") geo_shape = (first["Ny"], first["Nx"]) From c711227900163c21f0c6b34a5de16ed75a90b6f5 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Tue, 12 May 2026 10:56:45 -0400 Subject: [PATCH 2/2] BUG,MAINT: Variables have attributes, not attrs Fix spelling for attribute dictionary --- cfgrib/dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cfgrib/dataset.py b/cfgrib/dataset.py index f3ad4acf..ade27744 100644 --- a/cfgrib/dataset.py +++ b/cfgrib/dataset.py @@ -415,8 +415,8 @@ def build_geography_coordinates( attributes=COORD_ATTRS["longitude"], ) # latitude and longitude are dimension coordinates - geo_coord_vars["latitude"].attrs["axis"] = "Y" - geo_coord_vars["longitude"].attrs["axis"] = "X" + geo_coord_vars["latitude"].attributes["axis"] = "Y" + geo_coord_vars["longitude"].attributes["axis"] = "X" elif "geography" in encode_cf and grid_type in GRID_TYPES_2D_NON_DIMENSION_COORDS: geo_dims = ("y", "x") geo_shape = (first["Ny"], first["Nx"])