From 80d5837b5bb6d4626ecd2f89f4e7eaf90dc2858f Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 23 Jun 2022 16:46:36 +0100 Subject: [PATCH 1/3] Fix CDL headers for tests.stock.netcdf. --- .../tests/stock/file_headers/xios_2D_face_half_levels.cdl | 4 ++++ .../tests/stock/file_headers/xios_3D_face_full_levels.cdl | 4 ++++ .../tests/stock/file_headers/xios_3D_face_half_levels.cdl | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/lib/iris/tests/stock/file_headers/xios_2D_face_half_levels.cdl b/lib/iris/tests/stock/file_headers/xios_2D_face_half_levels.cdl index b135546f2d..ba3522b491 100644 --- a/lib/iris/tests/stock/file_headers/xios_2D_face_half_levels.cdl +++ b/lib/iris/tests/stock/file_headers/xios_2D_face_half_levels.cdl @@ -55,4 +55,8 @@ variables: :name = "${DATASET_NAME}" ; // original name = "lfric_ngvat_2D_1t_face_half_levels_main_conv_rain" :Conventions = "UGRID" ; + +// data +data: + time_instant = 0 ; } diff --git a/lib/iris/tests/stock/file_headers/xios_3D_face_full_levels.cdl b/lib/iris/tests/stock/file_headers/xios_3D_face_full_levels.cdl index e4f32de7b7..a87e3055c9 100644 --- a/lib/iris/tests/stock/file_headers/xios_3D_face_full_levels.cdl +++ b/lib/iris/tests/stock/file_headers/xios_3D_face_full_levels.cdl @@ -58,4 +58,8 @@ variables: :name = "${DATASET_NAME}" ; // original name = "lfric_ngvat_3D_1t_full_level_face_grid_main_u3" :Conventions = "UGRID" ; + +// data +data: + time_instant = 0 ; } diff --git a/lib/iris/tests/stock/file_headers/xios_3D_face_half_levels.cdl b/lib/iris/tests/stock/file_headers/xios_3D_face_half_levels.cdl index a193dbe451..f9c9c148dd 100644 --- a/lib/iris/tests/stock/file_headers/xios_3D_face_half_levels.cdl +++ b/lib/iris/tests/stock/file_headers/xios_3D_face_half_levels.cdl @@ -58,4 +58,8 @@ variables: :name = "${DATASET_NAME}" ; // original name = "lfric_ngvat_3D_1t_half_level_face_grid_derived_theta_in_w3" :Conventions = "UGRID" ; + +// data +data: + time_instant = 0 ; } From e84d7fb7d94709b28247a2607eb8c6cc79bc1e6c Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 23 Jun 2022 16:50:02 +0100 Subject: [PATCH 2/3] Whats new entry. --- docs/src/whatsnew/latest.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index a955604c3e..1dca323820 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -226,6 +226,11 @@ This document explains the changes made to Iris for this release bin in the system PATH. (:pull:`4794`) +#. `@trexfeathers`_ and `@pp-mo`_ fixed the CDL headers for + :mod:`iris.tests.stock.netcdf` to allow generation of NetCDF-4 files with an + unlimited time dimension. + (:pull:`4827`) + .. comment Whatsnew author names (@github name) in alphabetical order. Note that, From 7cd154c797e4af805d2853025b5f215ed1e5aaec Mon Sep 17 00:00:00 2001 From: Martin Yeo Date: Thu, 23 Jun 2022 17:39:14 +0100 Subject: [PATCH 3/3] Improved unlimited dimension check in stock NetCDF generation. --- lib/iris/tests/stock/netcdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iris/tests/stock/netcdf.py b/lib/iris/tests/stock/netcdf.py index 3e95fce95e..c5ec5ce446 100644 --- a/lib/iris/tests/stock/netcdf.py +++ b/lib/iris/tests/stock/netcdf.py @@ -103,7 +103,7 @@ def _add_standard_data(nc_path, unlimited_dim_size=0): ds = netCDF4.Dataset(nc_path, "r+") unlimited_dim_names = [ - dim for dim in ds.dimensions if ds.dimensions[dim].size == 0 + dim for dim in ds.dimensions if ds.dimensions[dim].isunlimited() ] # Data addition dependent on this assumption: assert len(unlimited_dim_names) < 2