diff --git a/satpy/composites/crefl_utils.py b/satpy/composites/crefl_utils.py index ed89b7810e..6978a0ad42 100644 --- a/satpy/composites/crefl_utils.py +++ b/satpy/composites/crefl_utils.py @@ -417,7 +417,7 @@ def run_crefl(refl, coeffs, # Get digital elevation map data for our granule, set ocean fill value to 0 if avg_elevation is None: LOG.debug("No average elevation information provided in CREFL") - # height = np.zeros(lon.shape, dtype=np.float) + # height = np.zeros(lon.shape, dtype=np.float64) height = 0. else: LOG.debug("Using average elevation information provided to CREFL") diff --git a/satpy/composites/viirs.py b/satpy/composites/viirs.py index ea404df241..7f6a9c03d1 100644 --- a/satpy/composites/viirs.py +++ b/satpy/composites/viirs.py @@ -90,7 +90,7 @@ def __call__(self, datasets, optional_datasets, **info): nc = NCDataset(self.dem_file, "r") # average elevation is stored as a 16-bit signed integer but with # scale factor 1 and offset 0, convert it to float here - avg_elevation = nc.variables[self.dem_sds][:].astype(np.float) + avg_elevation = nc.variables[self.dem_sds][:].astype(np.float64) if isinstance(avg_elevation, np.ma.MaskedArray): avg_elevation = avg_elevation.filled(np.nan) else: diff --git a/satpy/readers/aapp_l1b.py b/satpy/readers/aapp_l1b.py index 3392969942..eac9b3726e 100644 --- a/satpy/readers/aapp_l1b.py +++ b/satpy/readers/aapp_l1b.py @@ -495,7 +495,7 @@ def _vis_calibrate(data, if calib_type == 'counts': return channel - channel = channel.astype(np.float) + channel = channel.astype(np.float64) if calib_type == 'radiance': logger.info("Radiances are not yet supported for " + @@ -556,7 +556,7 @@ def _ir_calibrate(header, data, irchn, calib_type, mask=True): # Mask unnaturally low values mask &= count != 0 - count = count.astype(np.float) + count = count.astype(np.float64) k1_ = da.from_array(data['calir'][:, irchn, 0, 0], chunks=LINE_CHUNK) / 1.0e9 k2_ = da.from_array(data['calir'][:, irchn, 0, 1], chunks=LINE_CHUNK) / 1.0e6 diff --git a/satpy/readers/ghrsst_l3c_sst.py b/satpy/readers/ghrsst_l3c_sst.py index 9d3cf569c7..5b8f86f4c6 100644 --- a/satpy/readers/ghrsst_l3c_sst.py +++ b/satpy/readers/ghrsst_l3c_sst.py @@ -68,7 +68,7 @@ def get_dataset(self, dataset_id, ds_info, out=None): if out is None: out = np.ma.empty(shape, dtype=dtype) - out.mask = np.zeros(shape, dtype=np.bool) + out.mask = np.zeros(shape, dtype=bool) out.data[:] = np.require(self[var_path][0][::-1], dtype=dtype) valid_min = self[var_path + '/attr/valid_min'] diff --git a/satpy/readers/hrpt.py b/satpy/readers/hrpt.py index b0070e2fcf..df23cc5548 100644 --- a/satpy/readers/hrpt.py +++ b/satpy/readers/hrpt.py @@ -206,7 +206,7 @@ def calibrate_thermal_channel(self, data, key): from pygac.calibration import calibrate_thermal line_numbers = ( np.round((self.times - self.times[-1]) / - np.timedelta64(166666667, 'ns'))).astype(np.int) + np.timedelta64(166666667, 'ns'))).astype(int) line_numbers -= line_numbers[0] prt, ict, space = self.telemetry index = _get_channel_index(key) diff --git a/satpy/readers/msi_safe.py b/satpy/readers/msi_safe.py index 151a0c7b35..8d9b6ca03f 100644 --- a/satpy/readers/msi_safe.py +++ b/satpy/readers/msi_safe.py @@ -187,7 +187,7 @@ def _get_coarse_dataset(self, key, info): if key['name'] in ['solar_zenith_angle', 'solar_azimuth_angle']: elts = angles.findall(info['xml_tag'] + '/Values_List/VALUES') return np.array([[val for val in elt.text.split()] for elt in elts], - dtype=np.float) + dtype=np.float64) elif key['name'] in ['satellite_zenith_angle', 'satellite_azimuth_angle']: arrays = [] @@ -195,7 +195,7 @@ def _get_coarse_dataset(self, key, info): for elt in elts: items = elt.findall(info['xml_item'] + '/Values_List/VALUES') arrays.append(np.array([[val for val in item.text.split()] for item in items], - dtype=np.float)) + dtype=np.float64)) return np.nanmean(np.dstack(arrays), -1) return None diff --git a/satpy/readers/olci_nc.py b/satpy/readers/olci_nc.py index 1f7b15b2e5..74e8229ef5 100644 --- a/satpy/readers/olci_nc.py +++ b/satpy/readers/olci_nc.py @@ -86,12 +86,12 @@ def __getitem__(self, item): data = self._value if isinstance(data, xr.DataArray): data = data.data - res = ((data >> pos) % 2).astype(np.bool) + res = ((data >> pos) % 2).astype(bool) res = xr.DataArray(res, coords=self._value.coords, attrs=self._value.attrs, dims=self._value.dims) else: - res = ((data >> pos) % 2).astype(np.bool) + res = ((data >> pos) % 2).astype(bool) return res diff --git a/satpy/readers/seviri_base.py b/satpy/readers/seviri_base.py index 09a9e30263..7e85a1fd9d 100644 --- a/satpy/readers/seviri_base.py +++ b/satpy/readers/seviri_base.py @@ -384,9 +384,9 @@ def get(self): record = [ ('MPEF_File_Id', np.int16), ('MPEF_Header_Version', np.uint8), - ('ManualDissAuthRequest', np.bool), - ('ManualDisseminationAuth', np.bool), - ('DisseminationAuth', np.bool), + ('ManualDissAuthRequest', bool), + ('ManualDisseminationAuth', bool), + ('DisseminationAuth', bool), ('NominalTime', time_cds_short), ('ProductQuality', np.uint8), ('ProductCompleteness', np.uint8), @@ -417,7 +417,7 @@ def images_used(self): record = [ ('Padding1', 'S2'), ('ExpectedImage', time_cds_short), - ('ImageReceived', np.bool), + ('ImageReceived', bool), ('Padding2', 'S1'), ('UsedImageStart_Day', np.uint16), ('UsedImageStart_Millsec', np.uint32), diff --git a/satpy/readers/seviri_l1b_hrit.py b/satpy/readers/seviri_l1b_hrit.py index f3fe326073..905e8910a0 100644 --- a/satpy/readers/seviri_l1b_hrit.py +++ b/satpy/readers/seviri_l1b_hrit.py @@ -276,10 +276,12 @@ def get_satpos(self): x, y, z = self._get_satpos_cart() # Transform to geodetic coordinates - geocent = pyproj.Proj(proj='geocent') a, b = self.get_earth_radii() - latlong = pyproj.Proj(proj='latlong', a=a, b=b, units='m') - lon, lat, alt = pyproj.transform(geocent, latlong, x, y, z) + geocent_crs = pyproj.CRS.from_string('+proj=geocent') + latlong_crs = pyproj.CRS.from_string( + '+proj=latlong +a={} +b={} +units=m'.format(a, b)) + transformer = pyproj.Transformer.from_crs(geocent_crs, latlong_crs) + lon, lat, alt = transformer.transform(x, y, z) except NoValidOrbitParams as err: logger.warning(err) lon = lat = alt = None diff --git a/satpy/readers/seviri_l1b_native_hdr.py b/satpy/readers/seviri_l1b_native_hdr.py index f840bd9421..86a77c777c 100644 --- a/satpy/readers/seviri_l1b_native_hdr.py +++ b/satpy/readers/seviri_l1b_native_hdr.py @@ -64,7 +64,7 @@ class GSDTRecords(object): # 16 bytes gp_pk_sh1 = [ ('SubHeaderVersionNo', np.uint8), - ('ChecksumFlag', np.bool), + ('ChecksumFlag', bool), ('Acknowledgement', (np.uint8, 4)), ('ServiceType', gp_svce_type), ('ServiceSubtype', np.uint8), @@ -220,11 +220,11 @@ def satellite_status(self): # 28 bytes satellite_operations = [ - ('LastManoeuvreFlag', np.bool), + ('LastManoeuvreFlag', bool), ('LastManoeuvreStartTime', time_cds_short), ('LastManoeuvreEndTime', time_cds_short), ('LastManoeuvreType', np.uint8), - ('NextManoeuvreFlag', np.bool), + ('NextManoeuvreFlag', bool), ('NextManoeuvreStartTime', time_cds_short), ('NextManoeuvreEndTime', time_cds_short), ('NextManoeuvreType', np.uint8)] @@ -325,7 +325,7 @@ def image_acquisition(self): ('RefocusingLines', np.uint16), ('RefocusingDirection', np.uint8), ('RefocusingPosition', np.uint16), - ('ScanRefPosFlag', np.bool), + ('ScanRefPosFlag', bool), ('ScanRefPosNumber', np.uint16), ('ScanRefPosVal', np.float32), ('ScanFirstLine', np.uint16), @@ -333,15 +333,15 @@ def image_acquisition(self): ('RetraceStartLine', np.uint16)] decontamination = [ - ('DecontaminationNow', np.bool), + ('DecontaminationNow', bool), ('DecontaminationStart', time_cds_short), ('DecontaminationEnd', time_cds_short)] radiometer_operations = [ - ('LastGainChangeFlag', np.bool), + ('LastGainChangeFlag', bool), ('LastGainChangeTime', time_cds_short), ('Decontamination', decontamination), - ('BBCalScheduled', np.bool), + ('BBCalScheduled', bool), ('BBCalibrationType', np.uint8), ('BBFirstLine', np.uint16), ('BBLastLine', np.uint16), @@ -445,12 +445,12 @@ def image_description(self): def radiometric_processing(self): """Get radiometric processing data.""" rp_summary = [ - ('RadianceLinearization', (np.bool, 12)), - ('DetectorEqualization', (np.bool, 12)), - ('OnboardCalibrationResult', (np.bool, 12)), - ('MPEFCalFeedback', (np.bool, 12)), - ('MTFAdaptation', (np.bool, 12)), - ('StrayLightCorrection', (np.bool, 12))] + ('RadianceLinearization', (bool, 12)), + ('DetectorEqualization', (bool, 12)), + ('OnboardCalibrationResult', (bool, 12)), + ('MPEFCalFeedback', (bool, 12)), + ('MTFAdaptation', (bool, 12)), + ('StrayLightCorrection', (bool, 12))] level_15_image_calibration = [ ('CalSlope', np.float64), diff --git a/satpy/readers/viirs_l1b.py b/satpy/readers/viirs_l1b.py index 37189a1aeb..0d17f38b65 100644 --- a/satpy/readers/viirs_l1b.py +++ b/satpy/readers/viirs_l1b.py @@ -212,7 +212,7 @@ def get_dataset(self, dataset_id, ds_info): lut_var_path = ds_info.get('lut', var_path + '_brightness_temperature_lut') data = self[var_path] # we get the BT values from a look up table using the scaled radiance integers - index_arr = data.data.astype(np.int) + index_arr = data.data.astype(int) coords = data.coords data.data = self[lut_var_path].data[index_arr.ravel()].reshape(data.shape) data = data.assign_coords(**coords) diff --git a/satpy/readers/xmlformat.py b/satpy/readers/xmlformat.py index 47af809e54..2e0f5bc733 100644 --- a/satpy/readers/xmlformat.py +++ b/satpy/readers/xmlformat.py @@ -58,7 +58,7 @@ def process_field(elt, ascii=False): except ValueError: scale = (10 / np.array( elt.get("scaling-factor").replace("^", "e").split(","), - dtype=np.float)) + dtype=np.float64)) return ((elt.get("name"), current_type, scale)) diff --git a/satpy/resample.py b/satpy/resample.py index 58a6712fdf..73df9a97aa 100644 --- a/satpy/resample.py +++ b/satpy/resample.py @@ -566,7 +566,7 @@ def load_neighbour_info(self, cache_dir, mask=None, **kwargs): cache = np.array(fid[idx_name]) if idx_name == 'valid_input_index': # valid input index array needs to be boolean - cache = cache.astype(np.bool) + cache = cache.astype(bool) except ValueError: raise IOError cache = self._apply_cached_index(cache, idx_name) diff --git a/satpy/tests/reader_tests/test_fci_l2_nc.py b/satpy/tests/reader_tests/test_fci_l2_nc.py index 5bb80c9730..03b67acfa4 100644 --- a/satpy/tests/reader_tests/test_fci_l2_nc.py +++ b/satpy/tests/reader_tests/test_fci_l2_nc.py @@ -75,7 +75,7 @@ def setUp(self): two_layers_dataset[0, :, :] = np.ones((100, 10)) two_layers_dataset[1, :, :] = 2 * np.ones((100, 10)) - mtg_geos_projection = nc.createVariable('mtg_geos_projection', np.int, dimensions=()) + mtg_geos_projection = nc.createVariable('mtg_geos_projection', int, dimensions=()) mtg_geos_projection.longitude_of_projection_origin = 10.0 mtg_geos_projection.semi_major_axis = 6378137. mtg_geos_projection.semi_minor_axis = 6356752. @@ -403,7 +403,7 @@ def setUp(self): x.standard_name = 'projection_y_coordinate' y[:] = np.arange(1) - mtg_geos_projection = nc_byte.createVariable('mtg_geos_projection', np.int, dimensions=()) + mtg_geos_projection = nc_byte.createVariable('mtg_geos_projection', int, dimensions=()) mtg_geos_projection.longitude_of_projection_origin = 10.0 mtg_geos_projection.semi_major_axis = 6378137. mtg_geos_projection.semi_minor_axis = 6356752. diff --git a/satpy/tests/reader_tests/test_iasi_l2_so2_bufr.py b/satpy/tests/reader_tests/test_iasi_l2_so2_bufr.py index 06ab241c52..5ca3ad3e0f 100644 --- a/satpy/tests/reader_tests/test_iasi_l2_so2_bufr.py +++ b/satpy/tests/reader_tests/test_iasi_l2_so2_bufr.py @@ -53,7 +53,7 @@ 1007, 1031, 25060, 2019, 2020, 4001, 4002, 4003, 4004, 4005, 4006, 5040, 201133, 5041, 201000, 5001, 6001, 5043, 7024, 5021, 7025, 5022, 7007, 40068, 7002, 15045, 12080, 102000, 31001, 7007, - 15045], dtype=np.int), + 15045], dtype=int), '#1#satelliteIdentifier': 4, '#1#centre': 254, '#1#softwareIdentification': 605, diff --git a/satpy/tests/reader_tests/test_seviri_base.py b/satpy/tests/reader_tests/test_seviri_base.py index c64f0641b6..5fb0d80fb1 100644 --- a/satpy/tests/reader_tests/test_seviri_base.py +++ b/satpy/tests/reader_tests/test_seviri_base.py @@ -122,7 +122,7 @@ def test_pad_data_vertically(): def test_get_padding_area_float(): """Test padding area generator for floats.""" shape = (10, 10) - dtype = np.float + dtype = np.float64 res = get_padding_area(shape, dtype) expected = da.full(shape, np.nan, dtype=dtype, chunks=CHUNK_SIZE) np.testing.assert_array_equal(res, expected) @@ -131,7 +131,7 @@ def test_get_padding_area_float(): def test_get_padding_area_int(): """Test padding area generator for integers.""" shape = (10, 10) - dtype = np.int + dtype = np.int64 res = get_padding_area(shape, dtype) expected = da.full(shape, 0, dtype=dtype, chunks=CHUNK_SIZE) np.testing.assert_array_equal(res, expected) diff --git a/satpy/tests/reader_tests/test_utils.py b/satpy/tests/reader_tests/test_utils.py index 2378047067..0a7a605c4d 100644 --- a/satpy/tests/reader_tests/test_utils.py +++ b/satpy/tests/reader_tests/test_utils.py @@ -154,7 +154,7 @@ def test_geostationary_mask(self): (-6498000.088960204, -6498000.088960204, 6502000.089024927, 6502000.089024927)) - mask = hf.get_geostationary_mask(area).astype(np.int).compute() + mask = hf.get_geostationary_mask(area).astype(int).compute() # Check results along a couple of lines # a) Horizontal diff --git a/satpy/tests/test_composites.py b/satpy/tests/test_composites.py index e1c589195f..f64e23db9a 100644 --- a/satpy/tests/test_composites.py +++ b/satpy/tests/test_composites.py @@ -290,7 +290,7 @@ def setUp(self): start_time = datetime(2018, 1, 1, 18, 0, 0) # RGB - a = np.zeros((3, 2, 2), dtype=np.float) + a = np.zeros((3, 2, 2), dtype=np.float64) a[:, 0, 0] = 0.1 a[:, 0, 1] = 0.2 a[:, 1, 0] = 0.3 @@ -298,7 +298,7 @@ def setUp(self): a = da.from_array(a, a.shape) self.data_a = xr.DataArray(a, attrs={'test': 'a', 'start_time': start_time}, coords={'bands': bands}, dims=('bands', 'y', 'x')) - b = np.zeros((3, 2, 2), dtype=np.float) + b = np.zeros((3, 2, 2), dtype=np.float64) b[:, 0, 0] = np.nan b[:, 0, 1] = 0.25 b[:, 1, 0] = 0.50 diff --git a/satpy/tests/test_resample.py b/satpy/tests/test_resample.py index d9cdc14b58..ba1eeed929 100644 --- a/satpy/tests/test_resample.py +++ b/satpy/tests/test_resample.py @@ -141,7 +141,6 @@ class TestKDTreeResampler(unittest.TestCase): def test_kd_resampling(self, xr_resampler, create_filename, zarr_open, xr_dset, cnc): """Test the kd resampler.""" - import numpy as np import dask.array as da from satpy.resample import KDTreeResampler data, source_area, swath_data, source_swath, target_area = get_test_data() @@ -149,7 +148,7 @@ def test_kd_resampling(self, xr_resampler, create_filename, zarr_open, xr_dset.return_value = mock_dset resampler = KDTreeResampler(source_swath, target_area) resampler.precompute( - mask=da.arange(5, chunks=5).astype(np.bool), cache_dir='.') + mask=da.arange(5, chunks=5).astype(bool), cache_dir='.') xr_resampler.assert_called_once() resampler.resampler.get_neighbour_info.assert_called() # swath definitions should not be cached @@ -300,7 +299,7 @@ def test_2d_ewa(self, get_lonlats, ll2cr, fornav): self.assertIn('x', new_data.coords) self.assertIn('crs', new_data.coords) self.assertIsInstance(new_data.coords['crs'].item(), CRS) - self.assertIn('lcc', new_data.coords['crs'].item().to_proj4()) + self.assertIn('lambert', new_data.coords['crs'].item().coordinate_operation.method_name.lower()) self.assertEqual(new_data.coords['y'].attrs['units'], 'meter') self.assertEqual(new_data.coords['x'].attrs['units'], 'meter') self.assertEqual(target_area.crs, new_data.coords['crs'].item()) @@ -350,7 +349,7 @@ def test_3d_ewa(self, get_lonlats, ll2cr, fornav): self.assertIn('bands', new_data.coords) self.assertIn('crs', new_data.coords) self.assertIsInstance(new_data.coords['crs'].item(), CRS) - self.assertIn('lcc', new_data.coords['crs'].item().to_proj4()) + self.assertIn('lambert', new_data.coords['crs'].item().coordinate_operation.method_name.lower()) self.assertEqual(new_data.coords['y'].attrs['units'], 'meter') self.assertEqual(new_data.coords['x'].attrs['units'], 'meter') np.testing.assert_equal(new_data.coords['bands'].values, @@ -400,7 +399,7 @@ def test_expand_dims(self): self.assertIn('x', new_data.coords) self.assertIn('crs', new_data.coords) self.assertIsInstance(new_data.coords['crs'].item(), CRS) - self.assertIn('lcc', new_data.coords['crs'].item().to_proj4()) + self.assertIn('lambert', new_data.coords['crs'].item().coordinate_operation.method_name.lower()) self.assertEqual(new_data.coords['y'].attrs['units'], 'meter') self.assertEqual(new_data.coords['x'].attrs['units'], 'meter') self.assertEqual(target_area.crs, new_data.coords['crs'].item()) @@ -424,7 +423,7 @@ def test_expand_dims_3d(self): ['R', 'G', 'B']) self.assertIn('crs', new_data.coords) self.assertIsInstance(new_data.coords['crs'].item(), CRS) - self.assertIn('lcc', new_data.coords['crs'].item().to_proj4()) + self.assertIn('lambert', new_data.coords['crs'].item().coordinate_operation.method_name.lower()) self.assertEqual(new_data.coords['y'].attrs['units'], 'meter') self.assertEqual(new_data.coords['x'].attrs['units'], 'meter') self.assertEqual(target_area.crs, new_data.coords['crs'].item()) @@ -442,7 +441,7 @@ def test_expand_without_dims(self): self.assertTrue(np.all(new_data == new_data2)) self.assertIn('crs', new_data.coords) self.assertIsInstance(new_data.coords['crs'].item(), CRS) - self.assertIn('lcc', new_data.coords['crs'].item().to_proj4()) + self.assertIn('lambert', new_data.coords['crs'].item().coordinate_operation.method_name.lower()) self.assertEqual(target_area.crs, new_data.coords['crs'].item()) def test_expand_without_dims_4D(self): @@ -464,7 +463,6 @@ class TestBilinearResampler(unittest.TestCase): def test_bil_resampling(self, xr_resampler, create_filename, move_existing_caches): """Test the bilinear resampler.""" - import numpy as np import dask.array as da import xarray as xr from satpy.resample import BilinearResampler @@ -473,7 +471,7 @@ def test_bil_resampling(self, xr_resampler, create_filename, # Test that bilinear resampling info calculation is called resampler = BilinearResampler(source_swath, target_area) resampler.precompute( - mask=da.arange(5, chunks=5).astype(np.bool)) + mask=da.arange(5, chunks=5).astype(bool)) resampler.resampler.load_resampling_info.assert_not_called() resampler.resampler.get_bil_info.assert_called_once() resampler.resampler.reset_mock() @@ -489,7 +487,7 @@ def test_bil_resampling(self, xr_resampler, create_filename, self.assertIn('x', new_data.coords) self.assertIn('crs', new_data.coords) self.assertIsInstance(new_data.coords['crs'].item(), CRS) - self.assertIn('lcc', new_data.coords['crs'].item().to_proj4()) + self.assertIn('lambert', new_data.coords['crs'].item().coordinate_operation.method_name.lower()) self.assertEqual(new_data.coords['y'].attrs['units'], 'meter') self.assertEqual(new_data.coords['x'].attrs['units'], 'meter') self.assertEqual(target_area.crs, new_data.coords['crs'].item()) @@ -670,7 +668,7 @@ def test_swath_def_coordinates(self): self.assertIn('crs', new_data_arr.coords) crs = new_data_arr.coords['crs'].item() self.assertIsInstance(crs, CRS) - self.assertIn('longlat', crs.to_proj4()) + assert crs.is_geographic self.assertIsInstance(new_data_arr.coords['crs'].item(), CRS) diff --git a/satpy/tests/test_writers.py b/satpy/tests/test_writers.py index d7ae77bdae..1000b78368 100644 --- a/satpy/tests/test_writers.py +++ b/satpy/tests/test_writers.py @@ -310,15 +310,6 @@ def test_enhance_with_sensor_no_entry(self): {os.path.abspath(self.ENH_FN2), os.path.abspath(self.ENH_ENH_FN2)}) - def test_deprecated_enhance_with_file_specified(self): - """Test enhancing an image when config file is specified.""" - from satpy.writers import get_enhanced_image - from xarray import DataArray - ds = DataArray(np.arange(1, 11.).reshape((2, 5)), - attrs=dict(name='test1', sensor='test_sensor', mode='L'), - dims=['y', 'x']) - get_enhanced_image(ds, enhancement_config_file=self.ENH_ENH_FN) - def test_no_enhance(self): """Test turning off enhancements.""" from satpy.writers import get_enhanced_image diff --git a/satpy/tests/writer_tests/test_awips_tiled.py b/satpy/tests/writer_tests/test_awips_tiled.py index f7681530ca..f69c9c16e6 100644 --- a/satpy/tests/writer_tests/test_awips_tiled.py +++ b/satpy/tests/writer_tests/test_awips_tiled.py @@ -449,14 +449,13 @@ def test_lettered_tiles_bad_filename(self): from satpy.writers.awips_tiled import AWIPSTiledWriter from xarray import DataArray from pyresample.geometry import AreaDefinition - from pyresample.utils import proj4_str_to_dict w = AWIPSTiledWriter(base_dir=self.base_dir, compress=True, filename="{Bad Key}.nc") area_def = AreaDefinition( 'test', 'test', 'test', - proj4_str_to_dict('+proj=lcc +datum=WGS84 +ellps=WGS84 +lon_0=-95. ' - '+lat_0=25 +lat_1=25 +units=m +no_defs'), + ('+proj=lcc +datum=WGS84 +ellps=WGS84 +lon_0=-95. ' + '+lat_0=25 +lat_1=25 +units=m +no_defs'), 1000, 2000, (-1000000., -1500000., 1000000., 1500000.), @@ -486,14 +485,13 @@ def test_basic_numbered_tiles_rgb(self): import xarray as xr from xarray import DataArray from pyresample.geometry import AreaDefinition - from pyresample.utils import proj4_str_to_dict w = AWIPSTiledWriter(base_dir=self.base_dir, compress=True) area_def = AreaDefinition( 'test', 'test', 'test', - proj4_str_to_dict('+proj=lcc +datum=WGS84 +ellps=WGS84 +lon_0=-95. ' - '+lat_0=25 +lat_1=25 +units=m +no_defs'), + ('+proj=lcc +datum=WGS84 +ellps=WGS84 +lon_0=-95. ' + '+lat_0=25 +lat_1=25 +units=m +no_defs'), 100, 200, (-1000., -1500., 1000., 1500.), diff --git a/satpy/tests/writer_tests/test_cf.py b/satpy/tests/writer_tests/test_cf.py index 79844e60a6..0c8ca03ac7 100644 --- a/satpy/tests/writer_tests/test_cf.py +++ b/satpy/tests/writer_tests/test_cf.py @@ -458,7 +458,7 @@ def get_test_attrs(self): 'none': None, # should be dropped 'numpy_int': np.uint8(1), 'numpy_float': np.float32(1), - 'numpy_bool': np.bool(True), + 'numpy_bool': True, 'numpy_void': np.void(0), 'numpy_bytes': np.bytes_('test'), 'numpy_string': np.string_('test'), diff --git a/satpy/tests/writer_tests/test_geotiff.py b/satpy/tests/writer_tests/test_geotiff.py index 49e194c8ff..a29069250d 100644 --- a/satpy/tests/writer_tests/test_geotiff.py +++ b/satpy/tests/writer_tests/test_geotiff.py @@ -106,7 +106,7 @@ def test_float_write(self): from satpy.writers.geotiff import GeoTIFFWriter datasets = self._get_test_datasets() w = GeoTIFFWriter(base_dir=self.base_dir, - enhancement_config=False, + enhance=False, dtype=np.float32) w.save_datasets(datasets) diff --git a/satpy/writers/__init__.py b/satpy/writers/__init__.py index 28f0b6fb61..560944a377 100644 --- a/satpy/writers/__init__.py +++ b/satpy/writers/__init__.py @@ -392,8 +392,8 @@ def add_decorate(orig, fill_value=None, **decorate): return img -def get_enhanced_image(dataset, enhance=None, enhancement_config_file=None, - overlay=None, decorate=None, fill_value=None): +def get_enhanced_image(dataset, enhance=None, overlay=None, decorate=None, + fill_value=None): """Get an enhanced version of `dataset` as an :class:`~trollimage.xrimage.XRImage` instance. Args: @@ -406,7 +406,6 @@ def get_enhanced_image(dataset, enhance=None, enhancement_config_file=None, `False` so that no enhancments are performed. This can also be an instance of the :class:`~satpy.writers.Enhancer` class if further custom enhancement is needed. - enhancement_config_file (str): Deprecated. overlay (dict): Options for image overlays. See :func:`add_overlay` for available options. decorate (dict): Options for decorating the image. See @@ -426,16 +425,12 @@ def get_enhanced_image(dataset, enhance=None, enhancement_config_file=None, instead. """ - if enhancement_config_file is not None: - warnings.warn("'enhancement_config_file' has been deprecated. Pass an instance of the " - "'Enhancer' class to the 'enhance' keyword argument instead.", DeprecationWarning) - if enhance is False: # no enhancement enhancer = None elif enhance is None or enhance is True: # default enhancement - enhancer = Enhancer(enhancement_config_file) + enhancer = Enhancer() else: # custom enhancer enhancer = enhance @@ -740,7 +735,7 @@ def save_dataset(self, dataset, filename=None, fill_value=None, class ImageWriter(Writer): """Base writer for image file formats.""" - def __init__(self, name=None, filename=None, base_dir=None, enhance=None, enhancement_config=None, **kwargs): + def __init__(self, name=None, filename=None, base_dir=None, enhance=None, **kwargs): """Initialize image writer object. Args: @@ -769,7 +764,6 @@ def __init__(self, name=None, filename=None, base_dir=None, enhance=None, enhanc `False` so that no enhancments are performed. This can also be an instance of the :class:`~satpy.writers.Enhancer` class if further custom enhancement is needed. - enhancement_config (str): Deprecated. kwargs (dict): Additional keyword arguments to pass to the :class:`~satpy.writer.Writer` base class. @@ -782,17 +776,12 @@ def __init__(self, name=None, filename=None, base_dir=None, enhance=None, enhanc """ super(ImageWriter, self).__init__(name, filename, base_dir, **kwargs) - if enhancement_config is not None: - warnings.warn("'enhancement_config' has been deprecated. Pass an instance of the " - "'Enhancer' class to the 'enhance' keyword argument instead.", DeprecationWarning) - else: - enhancement_config = self.info.get("enhancement_config", None) - if enhance is False: # No enhancement self.enhancer = False elif enhance is None or enhance is True: # default enhancement + enhancement_config = self.info.get("enhancement_config", None) self.enhancer = Enhancer(enhancement_config_file=enhancement_config) else: # custom enhancer