Open gerritholl opened 4 years ago
There are two possible solutions to this, right?
I am not against the idea of adding UTC time zones in Satpy, at least in principle. The main complication I see is that we often have datetimes created from filenames. These datetimes are given to satpy from trollsift which I don't think has any knowledge of timezones (uses datetime.strptime
). Additionally, many data filenames don't have a timezone included and are expected to be UTC.
My main question for whether or not this should be added is: does it provide any functionality/utility to Satpy users. I think the answer is no. It theoretically slows down processing (adding UTC time zone, every datetime comparison now has to check the timezone, etc). Additionally, other pytroll packages will need to support time zones (ex. pyorbital). This seems like a lot of work for solution 2 when the work for solution 1 is one line of code (ok 2 for start and end) and is a single up-front cost.
I'm not sold on it, but like I said not completely against it in the sense that it is more information, so Satpy provides a more complete set of metadata.
I agree that this is low priority. I just wanted to put it here in case anyone else runs into it.
Note that if any data filenames do have timezone included then strptime
can result in a timezone-aware datetime
:
datetime.datetime.strptime("20200101000000Z", "%Y%m%d%H%M%S%z")
gives
datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
but I'm not sure if any satellite products that Satpy supports have timezone information in filenames.
How about just converting to naive while issuing a warni g? That keeps the existing functionality and implies only a small change to the code.
Feature Request
Is your feature request related to a problem? Please describe.
If my
datetime
is timezone-aware, Satpy can't use it:Results in:
Describe the solution you'd like
In a satellite context, perhaps all times that don't have timezone info could be assumed UTC. This may be risky if users use times in non-UTC timezones, although with timezone-naive times the risk of mixups already exists.
Describe any changes to existing user workflow
I think none.
Additional context
I got my timezone-aware datetime because I started out with a pandas datetime constructed from the string
2020-01-01T00:00:00Z
. As a workaround it is easy to strip away the timezone info.