Skip to content

Commit b371a89

Browse files
authored
Removing support for cdf_uint8 (which never actually existed) (#285)
1 parent e3df5d2 commit b371a89

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

cdflib/cdfwrite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,14 +1417,14 @@ def _datatype_define(self, value: Union[str, int, float, complex, np.ndarray]) -
14171417
return numElems, self.CDF_INT8
14181418
elif value.dtype.type == np.complex128:
14191419
return numElems, self.CDF_EPOCH16
1420-
elif value.dtype.type in (np.uint8, np.uint16, np.uint32, np.uint64):
1420+
elif value.dtype.type in (np.uint8, np.uint16, np.uint32):
14211421
return numElems, self.CDF_UINT4
14221422
elif value.dtype.type in (np.float16, np.float32, np.float64):
14231423
return numElems, self.CDF_DOUBLE
14241424
elif value.dtype.type == np.str_:
14251425
return numElems, self.CDF_CHAR
14261426
else:
1427-
logger.warning("Invalid data type for data.... Skip")
1427+
logger.warning(f"Invalid data type for data {value.dtype.type}.... Skip")
14281428
return None, None
14291429
else:
14301430
logger.warning("Invalid data type for data.... Skip")

cdflib/xarray/xarray_to_cdf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ def _dtype_to_cdf_type(var: xr.DataArray, terminate_on_warning: bool = False) ->
166166
elif numpy_data_type == np.uint32:
167167
cdf_data_type = "CDF_UINT4"
168168
elif numpy_data_type == np.uint64:
169-
cdf_data_type = "CDF_UINT8"
169+
_warn_or_except(
170+
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.",
171+
terminate_on_warning,
172+
)
173+
cdf_data_type = "CDF_UINT4"
170174
elif numpy_data_type == np.complex128:
171175
cdf_data_type = "CDF_EPOCH16"
172176
elif numpy_data_type.type in (np.str_, np.bytes_):
@@ -1020,7 +1024,6 @@ def xarray_to_cdf(
10201024
np.uint8 CDF_UINT1
10211025
np.uint16 CDF_UINT2
10221026
np.uint32 CDF_UINT4
1023-
np.uint64 CDF_UINT8
10241027
np.complex_ CDF_EPOCH16
10251028
np.str_ CDF_CHAR
10261029
np.bytes_ CDF_CHAR

0 commit comments

Comments
 (0)