File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -414,7 +414,7 @@ def _get_climo_dataset(self, season: str) -> xr.Dataset:
414414 return ds
415415
416416 def _add_cf_attrs_to_z_axes (self , ds : xr .Dataset ) -> xr .Dataset :
417- """Add CF attributes to the Z axes of the dataset.
417+ """Add CF attributes to the Z axis of the dataset if the Z axis exists .
418418
419419 This method is a temporary solution to enable xCDAT to properly
420420 retrieve bounds for Z axes that do not have CF attributes, which
@@ -430,12 +430,15 @@ def _add_cf_attrs_to_z_axes(self, ds: xr.Dataset) -> xr.Dataset:
430430 xr.Dataset
431431 The dataset with CF attributes added to the Z axes.
432432 """
433- dim = xc .get_dim_keys (ds , axis = "Z" )
434-
435- axis_attr = ds [dim ].attrs .get ("axis" )
433+ try :
434+ dim = xc .get_dim_keys (ds , axis = "Z" )
435+ except KeyError :
436+ pass
437+ else :
438+ axis_attr = ds [dim ].attrs .get ("axis" )
436439
437- if axis_attr is None :
438- ds [dim ].attrs ["axis" ] = "Z"
440+ if axis_attr is None :
441+ ds [dim ].attrs ["axis" ] = "Z"
439442
440443 return ds
441444
You can’t perform that action at this time.
0 commit comments