diff --git a/Changelog.rst b/Changelog.rst index 3ec1572b6a..0635b7242e 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -11,8 +11,8 @@ version NEXT (https://github.com/NCAS-CMS/cf-python/issues/715) * Improve `cf.Field.collapse` performance by lazily computing reduced axis coordinates (https://github.com/NCAS-CMS/cf-python/issues/741) -* Reduce output CFA file size with by tailoring the HDF5 chunk sizes - to fit exactly the CFA instruction variables +* Reduce output CFA netCDF file size by setting the HDF5 chunksizes of + CFA variables to be no larger than required (https://github.com/NCAS-CMS/cf-python/issues/739) * Fix misleading error message when it is not possible to create area weights requested from `cf.Field.collapse` diff --git a/cf/read_write/netcdf/netcdfwrite.py b/cf/read_write/netcdf/netcdfwrite.py index 746ca73229..8890fe4da1 100644 --- a/cf/read_write/netcdf/netcdfwrite.py +++ b/cf/read_write/netcdf/netcdfwrite.py @@ -914,6 +914,7 @@ def _cfa_aggregation_instructions(self, data, cfvar): aggregation_format = [] for indices in data.chunk_indices(): file_details = self._cfa_get_file_details(data[indices]) + if len(file_details) != 1: if file_details: raise ValueError( @@ -972,6 +973,8 @@ def _cfa_aggregation_instructions(self, data, cfvar): ): n = n_trailing - len(filenames) if n: + # This chunk has fewer fragment files than some + # others, so some padding is required. pad = ("",) * n aggregation_file[i] = filenames + pad aggregation_format[i] = formats + pad