Skip to content

Commit

Permalink
Merge pull request #2080 from MartinDix/valid_dtype_NETCDF4_CLASSIC
Browse files Browse the repository at this point in the history
Add NETCDF4_CLASSIC to the check for formats that don't support int64…
  • Loading branch information
pelson authored Oct 24, 2017
2 parents a0dc883 + a925cb1 commit bffa9a2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/iris/fileformats/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,12 +1383,13 @@ def _cf_coord_identity(coord):
return coord.standard_name, coord.long_name, units

def _ensure_valid_dtype(self, values, src_name, src_object):
# NetCDF3 does not support int64 or unsigned ints, so we check
# if we can store them as int32 instead.
# NetCDF3 and NetCDF4 classic do not support int64 or unsigned ints,
# so we check if we can store them as int32 instead.
if ((np.issubdtype(values.dtype, np.int64) or
np.issubdtype(values.dtype, np.unsignedinteger)) and
self._dataset.file_format in ('NETCDF3_CLASSIC',
'NETCDF3_64BIT')):
'NETCDF3_64BIT',
'NETCDF4_CLASSIC')):
# Cast to an integer type supported by netCDF3.
if not np.can_cast(values.max(), np.int32) or \
not np.can_cast(values.min(), np.int32):
Expand Down

0 comments on commit bffa9a2

Please sign in to comment.