From fddcfa6a3c0c3f3886cf47ea26db296dbde2d1a3 Mon Sep 17 00:00:00 2001 From: David Hassell Date: Mon, 19 Jun 2023 12:22:08 +0100 Subject: [PATCH 1/2] dev --- cf/__init__.py | 2 +- cf/read_write/netcdf/netcdfread.py | 26 ++++++++++++++++++++------ docs/source/installation.rst | 2 +- requirements.txt | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/cf/__init__.py b/cf/__init__.py index c83099f9d1..6d77ab8900 100644 --- a/cf/__init__.py +++ b/cf/__init__.py @@ -193,7 +193,7 @@ ) # Check the version of cfdm -_minimum_vn = "1.10.1.0" +_minimum_vn = "1.10.1.1" _maximum_vn = "1.10.2.0" _cfdm_version = Version(cfdm.__version__) if not Version(_minimum_vn) <= _cfdm_version < Version(_maximum_vn): diff --git a/cf/read_write/netcdf/netcdfread.py b/cf/read_write/netcdf/netcdfread.py index b0adcf46aa..251d043bf1 100644 --- a/cf/read_write/netcdf/netcdfread.py +++ b/cf/read_write/netcdf/netcdfread.py @@ -154,6 +154,7 @@ def _create_data( parent_ncvar=None, coord_ncvar=None, cfa_term=None, + compression_index=False, ): """Create data for a netCDF or CFA-netCDF variable. @@ -181,6 +182,12 @@ def _create_data( .. versionadded:: 3.15.0 + compression_index: `str`, optional + True if the data being created are compression + indices. + + .. versionadded:: 3.15.2 + :Returns: `Data` @@ -201,12 +208,19 @@ def _create_data( # one dask chunk if data.npartitions == 1: data._cfa_set_write(True) - - if self.implementation.get_construct_type(construct) != "field": - # Only cache values from non-field data, on the - # assumption that field data is, in general, so large - # that finding the cached values takes too long. See - # method `_cache_data_elements` for details. + if ( + not compression_index + and self.implementation.get_construct_type(construct) + != "field" + ): + # Only cache values from non-field data and + # non-compression-index data, on the assumptions that: + # + # a) Field data is, in general, so large that finding + # the cached values takes too long. + # + # b) Cached values are never really required for + # compression index data. self._cache_data_elements(data, ncvar) return data diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 53215e8dda..ceef730908 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -201,7 +201,7 @@ Required * `cftime `_, version 1.6.2 or newer (note that this package may be installed with netCDF4). -* `cfdm `_, version 1.10.1.0 or up to, +* `cfdm `_, version 1.10.1.1 or up to, but not including, 1.10.2.0. * `cfunits `_, version 3.3.6 or newer. diff --git a/requirements.txt b/requirements.txt index 1a69e67d3f..6a3d10b0e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ netCDF4>=1.5.4 cftime>=1.6.2 numpy>=1.22 -cfdm>=1.10.1.0, <1.10.2.0 +cfdm>=1.10.1.1, <1.10.2.0 psutil>=0.6.0 cfunits>=3.3.6 dask>=2022.12.1 From 968f5a285ec4e39540b7de081ab657c477e67248 Mon Sep 17 00:00:00 2001 From: David Hassell Date: Tue, 20 Jun 2023 08:47:16 +0100 Subject: [PATCH 2/2] Typo Co-authored-by: Sadie L. Bartholomew --- cf/read_write/netcdf/netcdfread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cf/read_write/netcdf/netcdfread.py b/cf/read_write/netcdf/netcdfread.py index 251d043bf1..f8437349c6 100644 --- a/cf/read_write/netcdf/netcdfread.py +++ b/cf/read_write/netcdf/netcdfread.py @@ -182,7 +182,7 @@ def _create_data( .. versionadded:: 3.15.0 - compression_index: `str`, optional + compression_index: `bool`, optional True if the data being created are compression indices.