From 152b45ec947a3a5fbc250f34ba2a340e55d6469e Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Fri, 20 Dec 2024 12:05:07 +0100 Subject: [PATCH] Fixed datetime import syntax - use custom practice Signed-off-by: Adam.Dybbroe --- satpy/tests/reader_tests/conftest.py | 24 +++++++++---------- satpy/tests/reader_tests/test_aws1_mwr_l1b.py | 6 ++--- satpy/tests/reader_tests/test_aws1_mwr_l1c.py | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/satpy/tests/reader_tests/conftest.py b/satpy/tests/reader_tests/conftest.py index c78cf5ae1b..241f00f28f 100644 --- a/satpy/tests/reader_tests/conftest.py +++ b/satpy/tests/reader_tests/conftest.py @@ -18,8 +18,8 @@ """Setup and configuration for all reader tests.""" +import datetime as dt import os -from datetime import datetime as dt from datetime import timedelta from random import randrange @@ -106,9 +106,9 @@ def aws_eps_sterna_mwr_l1bfile(fake_mwr_data_array, eps_sterna=True): geo_size = 10 * 145 * 4 ds = DataTree() - start_time = dt(2024, 9, 1, 12, 0) + start_time = dt.datetime(2024, 9, 1, 12, 0) ds.attrs["sensing_start_time_utc"] = start_time.strftime(DATETIME_FORMAT) - end_time = dt(2024, 9, 1, 12, 15) + end_time = dt.datetime(2024, 9, 1, 12, 15) ds.attrs["sensing_end_time_utc"] = end_time.strftime(DATETIME_FORMAT) instrument = "MWR" @@ -146,10 +146,10 @@ def eps_sterna_mwr_file(tmp_path_factory, fake_mwr_data_array): ds = aws_eps_sterna_mwr_l1bfile(fake_mwr_data_array, eps_sterna=True) tmp_dir = tmp_path_factory.mktemp("eps_sterna_mwr_l1b_tests") - start_time = dt.fromisoformat(ds.attrs["sensing_start_time_utc"]) - end_time = dt.fromisoformat(ds.attrs["sensing_end_time_utc"]) + start_time = dt.datetime.fromisoformat(ds.attrs["sensing_start_time_utc"]) + end_time = dt.datetime.fromisoformat(ds.attrs["sensing_end_time_utc"]) platform_name = "AWS1" - processing_time = random_date(dt(2024, 9, 1, 13), dt(2030, 6, 1)) + processing_time = random_date(dt.datetime(2024, 9, 1, 13), dt.datetime(2030, 6, 1)) filename = tmp_dir / compose(file_pattern, dict(country="XX", organisation="EUMETSAT", location="Darmstadt", @@ -167,10 +167,10 @@ def aws_mwr_file(tmp_path_factory, fake_mwr_data_array): ds = aws_eps_sterna_mwr_l1bfile(fake_mwr_data_array, eps_sterna=False) tmp_dir = tmp_path_factory.mktemp("aws_l1b_tests") - start_time = dt.fromisoformat(ds.attrs["sensing_start_time_utc"]) - end_time = dt.fromisoformat(ds.attrs["sensing_end_time_utc"]) + start_time = dt.datetime.fromisoformat(ds.attrs["sensing_start_time_utc"]) + end_time = dt.datetime.fromisoformat(ds.attrs["sensing_end_time_utc"]) platform_name = "AWS1" - processing_time = random_date(dt(2024, 9, 1, 13), dt(2030, 6, 1)) + processing_time = random_date(dt.datetime(2024, 9, 1, 13), dt.datetime(2030, 6, 1)) filename = tmp_dir / compose(file_pattern, dict(country="SE", organisation="SMHI", location="Norrkoping", @@ -190,11 +190,11 @@ def aws_mwr_l1c_file(tmp_path_factory, fake_mwr_data_array): geo_size = 10 * 145 ds = DataTree() - start_time = dt(2024, 9, 1, 12, 0) + start_time = dt.datetime(2024, 9, 1, 12, 0) ds.attrs["sensing_start_time_utc"] = start_time.strftime(DATETIME_FORMAT) - end_time = dt(2024, 9, 1, 12, 15) + end_time = dt.datetime(2024, 9, 1, 12, 15) ds.attrs["sensing_end_time_utc"] = end_time.strftime(DATETIME_FORMAT) - processing_time = random_date(dt(2024, 6, 1), dt(2030, 6, 1)) + processing_time = random_date(dt.datetime(2024, 6, 1), dt.datetime(2030, 6, 1)) ds.attrs["instrument"] = "MWR" ds.attrs["orbit_start"] = 9991 diff --git a/satpy/tests/reader_tests/test_aws1_mwr_l1b.py b/satpy/tests/reader_tests/test_aws1_mwr_l1b.py index a88cd8e062..cfecfd4a66 100644 --- a/satpy/tests/reader_tests/test_aws1_mwr_l1b.py +++ b/satpy/tests/reader_tests/test_aws1_mwr_l1b.py @@ -1,6 +1,6 @@ """Tests for aws l1b filehandlers.""" -from datetime import datetime as dt +import datetime as dt from enum import Enum import numpy as np @@ -24,8 +24,8 @@ def test_start_end_time(aws_mwr_handler): """Test that start and end times are read correctly.""" - assert aws_mwr_handler.start_time == dt(2024, 9, 1, 12, 0) - assert aws_mwr_handler.end_time == dt(2024, 9, 1, 12, 15) + assert aws_mwr_handler.start_time == dt.datetime(2024, 9, 1, 12, 0) + assert aws_mwr_handler.end_time == dt.datetime(2024, 9, 1, 12, 15) def test_orbit_number_start_end(aws_mwr_handler): diff --git a/satpy/tests/reader_tests/test_aws1_mwr_l1c.py b/satpy/tests/reader_tests/test_aws1_mwr_l1c.py index 5ef44a9636..9fe034a76d 100644 --- a/satpy/tests/reader_tests/test_aws1_mwr_l1c.py +++ b/satpy/tests/reader_tests/test_aws1_mwr_l1c.py @@ -30,7 +30,7 @@ geo_dims = ["n_scans", "n_fovs"] -geo_size = 10*145 +geo_size = 10 * 145 fake_lon_data, fake_lat_data = make_fake_mwr_l1c_lonlats(geo_size, geo_dims) fake_sun_azi_data = make_fake_angles(geo_size, geo_dims, shape=(10, 145)) fake_sun_zen_data = make_fake_angles(geo_size, geo_dims, shape=(10, 145))