diff --git a/satpy/readers/aapp_mhs_amsub_l1c.py b/satpy/readers/aapp_mhs_amsub_l1c.py index 39216431f4..f5765545f3 100644 --- a/satpy/readers/aapp_mhs_amsub_l1c.py +++ b/satpy/readers/aapp_mhs_amsub_l1c.py @@ -152,7 +152,7 @@ def _calibrate(data, if calib_type == 'counts': return channel - channel = channel.astype(np.float_) + channel = channel.astype(np.float64) return da.where(mask, channel, np.nan) diff --git a/satpy/readers/hdf4_utils.py b/satpy/readers/hdf4_utils.py index acc86fd64d..fb20c0ce11 100644 --- a/satpy/readers/hdf4_utils.py +++ b/satpy/readers/hdf4_utils.py @@ -69,7 +69,7 @@ def __init__(self, filename, filename_info, filetype_info): def _collect_attrs(self, name, attrs): for key, value in attrs.items(): value = np.squeeze(value) - if issubclass(value.dtype.type, (np.string_, np.unicode_)) and not value.shape: + if issubclass(value.dtype.type, (np.bytes_, np.str_)) and not value.shape: value = value.item() # convert to scalar if not isinstance(value, str): # python 3 - was scalar numpy array of bytes diff --git a/satpy/readers/utils.py b/satpy/readers/utils.py index 31f6dea6d9..e2035af479 100644 --- a/satpy/readers/utils.py +++ b/satpy/readers/utils.py @@ -54,7 +54,7 @@ def np2str(value): """ if hasattr(value, 'dtype') and \ - issubclass(value.dtype.type, (np.str_, np.string_, np.object_)) \ + issubclass(value.dtype.type, (np.str_, np.bytes_, np.object_)) \ and value.size == 1: value = value.item() if not isinstance(value, str): diff --git a/satpy/tests/reader_tests/test_utils.py b/satpy/tests/reader_tests/test_utils.py index 54b156e4c5..fc38e36c88 100644 --- a/satpy/tests/reader_tests/test_utils.py +++ b/satpy/tests/reader_tests/test_utils.py @@ -202,20 +202,20 @@ def test_sub_area(self, adef): def test_np2str(self): """Test the np2str function.""" # byte object - npstring = np.string_('hej') - self.assertEqual(hf.np2str(npstring), 'hej') + npbytes = np.bytes_('hej') + self.assertEqual(hf.np2str(npbytes), 'hej') # single element numpy array - np_arr = np.array([npstring]) + np_arr = np.array([npbytes]) self.assertEqual(hf.np2str(np_arr), 'hej') # scalar numpy array - np_arr = np.array(npstring) + np_arr = np.array(npbytes) self.assertEqual(hf.np2str(np_arr), 'hej') # multi-element array - npstring = np.array([npstring, npstring]) - self.assertRaises(ValueError, hf.np2str, npstring) + npbytes = np.array([npbytes, npbytes]) + self.assertRaises(ValueError, hf.np2str, npbytes) # non-array self.assertRaises(ValueError, hf.np2str, 5) diff --git a/satpy/tests/writer_tests/test_cf.py b/satpy/tests/writer_tests/test_cf.py index a325cb9cc8..a034038663 100644 --- a/satpy/tests/writer_tests/test_cf.py +++ b/satpy/tests/writer_tests/test_cf.py @@ -537,7 +537,7 @@ def get_test_attrs(self): 'numpy_bool': True, 'numpy_void': np.void(0), 'numpy_bytes': np.bytes_('test'), - 'numpy_string': np.string_('test'), + 'numpy_string': np.str_('test'), 'list': [1, 2, np.float64(3)], 'nested_list': ["1", ["2", [3]]], 'bool': True, diff --git a/satpy/writers/cf_writer.py b/satpy/writers/cf_writer.py index b9a24b9292..702e25c2fa 100644 --- a/satpy/writers/cf_writer.py +++ b/satpy/writers/cf_writer.py @@ -192,7 +192,7 @@ if netCDF4 is None and h5netcdf is None: raise ImportError('Ensure that the netCDF4 or h5netcdf package is installed.') -# Numpy datatypes compatible with all netCDF4 backends. ``np.unicode_`` is +# Numpy datatypes compatible with all netCDF4 backends. ``np.str_`` is # excluded because h5py (and thus h5netcdf) has problems with unicode, see # https://github.com/h5py/h5py/issues/624.""" NC4_DTYPES = [np.dtype('int8'), np.dtype('uint8'), @@ -200,7 +200,7 @@ np.dtype('int32'), np.dtype('uint32'), np.dtype('int64'), np.dtype('uint64'), np.dtype('float32'), np.dtype('float64'), - np.string_] + np.bytes_] # Unsigned and int64 isn't CF 1.7 compatible # Note: Unsigned and int64 are CF 1.9 compatible @@ -209,7 +209,7 @@ np.dtype('int32'), np.dtype('float32'), np.dtype('float64'), - np.string_] + np.bytes_] CF_VERSION = 'CF-1.7' @@ -582,7 +582,7 @@ def _remove_satpy_attrs(new_data): def _format_prerequisites_attrs(dataarray): """Reformat prerequisites attribute value to string.""" if 'prerequisites' in dataarray.attrs: - dataarray.attrs['prerequisites'] = [np.string_(str(prereq)) for prereq in dataarray.attrs['prerequisites']] + dataarray.attrs['prerequisites'] = [np.bytes_(str(prereq)) for prereq in dataarray.attrs['prerequisites']] return dataarray diff --git a/setup.py b/setup.py index 612db4fa05..555f299b19 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ from setuptools import find_packages, setup -requires = ['numpy >=1.13', 'pillow', 'pyresample >=1.24.0', 'trollsift', +requires = ['numpy >=1.21', 'pillow', 'pyresample >=1.24.0', 'trollsift', 'trollimage >=1.20', 'pykdtree', 'pyyaml >=5.1', 'xarray >=0.10.1, !=0.13.0', 'dask[array] >=0.17.1', 'pyproj>=2.2', 'zarr', 'donfig', 'appdirs', 'packaging', 'pooch', 'pyorbital']