diff --git a/doc/source/conf.py b/doc/source/conf.py index 2e41793c15..f98986a728 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -117,7 +117,7 @@ def __getattr__(cls, name): # General information about the project. project = u"Satpy" -copyright = u"2009-{}, The PyTroll Team".format(dt.datetime.utcnow().strftime("%Y")) # noqa: A001 +copyright = u"2009-{}, The PyTroll Team".format(dt.datetime.now(dt.UTC).strftime("%Y")) # noqa: A001 # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/satpy/readers/hrpt.py b/satpy/readers/hrpt.py index cac8b9cd3d..68d43c7b38 100644 --- a/satpy/readers/hrpt.py +++ b/satpy/readers/hrpt.py @@ -131,7 +131,7 @@ def __init__(self, filename, filename_info, filetype_info): self.channels = {i: None for i in AVHRR_CHANNEL_NAMES} self.units = {i: "counts" for i in AVHRR_CHANNEL_NAMES} - self.year = filename_info.get("start_time", dt.datetime.utcnow()).year + self.year = filename_info.get("start_time", dt.datetime.now(dt.UTC)).year @cached_property def times(self): diff --git a/satpy/tests/reader_tests/test_satpy_cf_nc.py b/satpy/tests/reader_tests/test_satpy_cf_nc.py index 56acccdeb9..7cd77d933f 100644 --- a/satpy/tests/reader_tests/test_satpy_cf_nc.py +++ b/satpy/tests/reader_tests/test_satpy_cf_nc.py @@ -265,7 +265,7 @@ def cf_scene(datasets, common_attrs): @pytest.fixture def nc_filename(tmp_path): """Create an nc filename for viirs m band.""" - now = dt.datetime.utcnow() + now = dt.datetime.now(dt.UTC) filename = f"testingcfwriter{now:%Y%j%H%M%S}-viirs-mband-20201007075915-20201007080744.nc" return str(tmp_path / filename) @@ -273,7 +273,7 @@ def nc_filename(tmp_path): @pytest.fixture def nc_filename_i(tmp_path): """Create an nc filename for viirs i band.""" - now = dt.datetime.utcnow() + now = dt.datetime.now(dt.UTC) filename = f"testingcfwriter{now:%Y%j%H%M%S}-viirs-iband-20201007075915-20201007080744.nc" return str(tmp_path / filename) diff --git a/satpy/tests/reader_tests/test_viirs_vgac_l1c_nc.py b/satpy/tests/reader_tests/test_viirs_vgac_l1c_nc.py index 2dd52786b2..93492b1008 100644 --- a/satpy/tests/reader_tests/test_viirs_vgac_l1c_nc.py +++ b/satpy/tests/reader_tests/test_viirs_vgac_l1c_nc.py @@ -34,7 +34,7 @@ @pytest.fixture def nc_filename(tmp_path): """Create an nc test data file and return its filename.""" - now = dt.datetime.utcnow() + now = dt.datetime.now(dt.UTC) filename = f"VGAC_VJ10XMOD_A{now:%Y%j_%H%M}_n004946_K005.nc" filename_str = str(tmp_path / filename) # Create test data diff --git a/satpy/tests/scene_tests/test_saving.py b/satpy/tests/scene_tests/test_saving.py index b67f41cc2e..ca74204b5a 100644 --- a/satpy/tests/scene_tests/test_saving.py +++ b/satpy/tests/scene_tests/test_saving.py @@ -72,7 +72,7 @@ def test_save_datasets_bad_writer(self, tmp_path): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow()} + "start_time": dt.datetime.now(dt.UTC)} ) scn = Scene() scn["test"] = ds1 diff --git a/satpy/tests/writer_tests/test_geotiff.py b/satpy/tests/writer_tests/test_geotiff.py index d0e879c4b2..198104a441 100644 --- a/satpy/tests/writer_tests/test_geotiff.py +++ b/satpy/tests/writer_tests/test_geotiff.py @@ -42,7 +42,7 @@ def _get_test_datasets_2d(): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "units": "K", "area": adef} ) @@ -72,7 +72,7 @@ def _get_test_datasets_3d(): dims=("bands", "y", "x"), coords={"bands": ["R", "G", "B"]}, attrs={"name": "test", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "area": adef} ) return [ds1] diff --git a/satpy/tests/writer_tests/test_mitiff.py b/satpy/tests/writer_tests/test_mitiff.py index 1642510583..e358f0a660 100644 --- a/satpy/tests/writer_tests/test_mitiff.py +++ b/satpy/tests/writer_tests/test_mitiff.py @@ -68,7 +68,7 @@ def _get_test_datasets(self): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "1", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "TEST_SENSOR_NAME", "area": area_def, @@ -91,7 +91,7 @@ def _get_test_datasets(self): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "4", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "TEST_SENSOR_NAME", "area": area_def, @@ -132,7 +132,7 @@ def _get_test_datasets_sensor_set(self): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "1", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": {"TEST_SENSOR_NAME"}, "area": area_def, @@ -155,7 +155,7 @@ def _get_test_datasets_sensor_set(self): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "4", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": {"TEST_SENSOR_NAME"}, "area": area_def, @@ -197,7 +197,7 @@ def _get_test_dataset(self, bands=3): da.zeros((bands, 100, 200), chunks=50), dims=("bands", "y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "TEST_SENSOR_NAME", "area": area_def, @@ -226,7 +226,7 @@ def _get_test_one_dataset(self): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "avhrr", "area": area_def, @@ -255,7 +255,7 @@ def _get_test_one_dataset_sensor_set(self): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": {"avhrr"}, "area": area_def, @@ -288,7 +288,7 @@ def _get_test_dataset_with_bad_values(self, bands=3): ds1 = xr.DataArray(rgb_data, dims=("bands", "y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "TEST_SENSOR_NAME", "area": area_def, @@ -350,7 +350,7 @@ def _get_test_dataset_calibration(self, bands=6): bands.append(p.attrs["name"]) data["bands"] = list(bands) new_attrs = {"name": "datasets", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "test-sensor", "area": area_def, @@ -427,7 +427,7 @@ def _get_test_dataset_calibration_one_dataset(self, bands=1): for p in scene: calibration.append(p.attrs["calibration"]) new_attrs = {"name": "datasets", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "test-sensor", "area": area_def, @@ -472,7 +472,7 @@ def _get_test_dataset_three_bands_two_prereq(self, bands=3): coords=[["R", "G", "B"], list(range(100)), list(range(200))], dims=("bands", "y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "TEST_SENSOR_NAME", "area": area_def, @@ -504,7 +504,7 @@ def _get_test_dataset_three_bands_prereq(self, bands=3): coords=[["R", "G", "B"], list(range(100)), list(range(200))], dims=("bands", "y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow(), + "start_time": dt.datetime.now(dt.UTC), "platform_name": "TEST_PLATFORM_NAME", "sensor": "TEST_SENSOR_NAME", "area": area_def, diff --git a/satpy/tests/writer_tests/test_simple_image.py b/satpy/tests/writer_tests/test_simple_image.py index 6a4eba95e3..b7eb2f817c 100644 --- a/satpy/tests/writer_tests/test_simple_image.py +++ b/satpy/tests/writer_tests/test_simple_image.py @@ -46,7 +46,7 @@ def _get_test_datasets(): da.zeros((100, 200), chunks=50), dims=("y", "x"), attrs={"name": "test", - "start_time": dt.datetime.utcnow()} + "start_time": dt.datetime.now(dt.UTC)} ) return [ds1] diff --git a/satpy/writers/awips_tiled.py b/satpy/writers/awips_tiled.py index f697f8902d..7572802890 100644 --- a/satpy/writers/awips_tiled.py +++ b/satpy/writers/awips_tiled.py @@ -1775,7 +1775,7 @@ def create_debug_lettered_tiles(**writer_kwargs): sector_info = writer.awips_sectors[sector_id] area_def, arr = _create_debug_array(sector_info, save_kwargs["num_subtiles"]) - now = dt.datetime.utcnow() + now = dt.datetime.now(dt.UTC) product = xr.DataArray(da.from_array(arr, chunks="auto"), attrs=dict( name="debug_{}".format(sector_id), platform_name="DEBUG",