From 21730658f0d35e5b6a6ed31dc6cb43837a2a4efa Mon Sep 17 00:00:00 2001 From: Bryan Harter <41062454+bryan-harter@users.noreply.github.com> Date: Fri, 10 Jan 2025 18:44:33 +0000 Subject: [PATCH] Removing support for cdf_uint8 (which never actually existed) --- cdflib/cdfwrite.py | 4 ++-- cdflib/xarray/xarray_to_cdf.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cdflib/cdfwrite.py b/cdflib/cdfwrite.py index 989d4b4..354c7ce 100644 --- a/cdflib/cdfwrite.py +++ b/cdflib/cdfwrite.py @@ -1417,14 +1417,14 @@ def _datatype_define(self, value: Union[str, int, float, complex, np.ndarray]) - return numElems, self.CDF_INT8 elif value.dtype.type == np.complex128: return numElems, self.CDF_EPOCH16 - elif value.dtype.type in (np.uint8, np.uint16, np.uint32, np.uint64): + elif value.dtype.type in (np.uint8, np.uint16, np.uint32): return numElems, self.CDF_UINT4 elif value.dtype.type in (np.float16, np.float32, np.float64): return numElems, self.CDF_DOUBLE elif value.dtype.type == np.str_: return numElems, self.CDF_CHAR else: - logger.warning("Invalid data type for data.... Skip") + logger.warning(f"Invalid data type for data {value.dtype.type}.... Skip") return None, None else: logger.warning("Invalid data type for data.... Skip") diff --git a/cdflib/xarray/xarray_to_cdf.py b/cdflib/xarray/xarray_to_cdf.py index 28a3949..def0649 100644 --- a/cdflib/xarray/xarray_to_cdf.py +++ b/cdflib/xarray/xarray_to_cdf.py @@ -166,7 +166,11 @@ def _dtype_to_cdf_type(var: xr.DataArray, terminate_on_warning: bool = False) -> elif numpy_data_type == np.uint32: cdf_data_type = "CDF_UINT4" elif numpy_data_type == np.uint64: - cdf_data_type = "CDF_UINT8" + _warn_or_except( + f"CONVERSION ERROR: Data in variable {var.name} is a 64bit unsigned integer. CDF does not currently support this data type. See documentation for supported xarray/numpy data types.", + terminate_on_warning, + ) + cdf_data_type = "CDF_UINT4" elif numpy_data_type == np.complex128: cdf_data_type = "CDF_EPOCH16" elif numpy_data_type.type in (np.str_, np.bytes_): @@ -1020,7 +1024,6 @@ def xarray_to_cdf( np.uint8 CDF_UINT1 np.uint16 CDF_UINT2 np.uint32 CDF_UINT4 - np.uint64 CDF_UINT8 np.complex_ CDF_EPOCH16 np.str_ CDF_CHAR np.bytes_ CDF_CHAR