Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cdflib/cdfwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 5 additions & 2 deletions cdflib/xarray/xarray_to_cdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_):
Expand Down Expand Up @@ -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
Expand Down
Loading