alan-turing-institute / DTBase

A starting point from which digital twins can be developed.
MIT License
11 stars 4 forks source link

Fix timezone issue in Arima data preparation #197

Closed mhauru closed 7 months ago

mhauru commented 7 months ago

This was causing some trouble in comparing times, because the old way lost timezone information.

mhauru commented 7 months ago

Yes, that's correct, this changes the source of the timezone from the time to the date. It's a good question to ask if that's what we want, it forced me to think about this in more detail.

The reason I think this makes sense is that this function takes some datetime for when a model run should start (or something like that, I don't understand it fully), and replaces the given time with a fixed time like "always make it be noon", because that's how the farm cycle operates. I think the change in this time of day should still stay within the timezone of the original time, i.e. be "timezone relative", so "always make it be noon in the local time zone, in which you expressed the original time".

Currently the time part, farm_cycle_start_time, is timezoneless, which made the output of this be timezoneless. This messed with comparing datetimes, because even if all other datetimes had timezone information, once you ran this "change it to be noon" function the output didn't have a timezone, and then comparisons started to error out saying can't compare timezone-aware and unaware datetimes.

EdwinB12 commented 7 months ago

Okay understood. I think this is a sensible change and therefore should be merged.