Skip to content

Commit

Permalink
Fixed datetime import syntax - use custom practice
Browse files Browse the repository at this point in the history
Signed-off-by: Adam.Dybbroe <[email protected]>
  • Loading branch information
Adam.Dybbroe committed Dec 20, 2024
1 parent 05d952e commit 152b45e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions satpy/tests/reader_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions satpy/tests/reader_tests/test_aws1_mwr_l1b.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion satpy/tests/reader_tests/test_aws1_mwr_l1c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 152b45e

Please sign in to comment.