Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ def test_normalize():
def test_millis_to_datetime():
"""Test that a datetime can be correctly converted from milliseconds"""
test_millis = 1594535594000
test_datetime = datetime.datetime(2020, 7, 12, 6, 33, 14)
test_datetime = datetime.datetime(
2020, 7, 12, 6, 33, 14, 0, tzinfo=datetime.timezone.utc
)

result = wxee.utils._millis_to_datetime(test_millis)

Expand Down
10 changes: 6 additions & 4 deletions wxee/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ def _dataset_from_files(files: List[str], masked: bool, nodata: int) -> xr.Datas

try:
# Allow conflicting values if one is null, take the non-null value
merged = xr.merge(das, compat="no_conflicts")
except xr.core.merge.MergeError:
merged = xr.merge(das, join="outer", compat="no_conflicts")
except xr.MergeError:
# If non-null conflicting values occur, take the first value and warn the user
merged = xr.merge(das, compat="override")
merged = xr.merge(das, join="outer", compat="override")
warnings.warn(
"Different non-null values were encountered for the same variable at the same time coordinate. The first value was taken."
)
Expand Down Expand Up @@ -206,7 +206,9 @@ def _parse_time(time: str) -> Union[datetime.datetime, str]:

def _millis_to_datetime(millis: str) -> datetime.datetime:
"""Convert a timestamp in UTC milliseconds (e.g. from Earth Engine) to a datetime object."""
return datetime.datetime.utcfromtimestamp(int(millis) / 1000.0)
return datetime.datetime.fromtimestamp(
int(millis) / 1000.0, tz=datetime.timezone.utc
)


def _replace_if_null(val: Union[ee.String, ee.Number], replacement: Any) -> Any:
Expand Down