Date aware examples#325
Conversation
255e76d to
fff2666
Compare
stephankramer
left a comment
There was a problem hiding this comment.
Other than that looks fine. Sorry this seems to have sat there a while - not sure you were still intending to merge
| t_end = (end_date - start_date).total_seconds() | ||
| if os.getenv("THETIS_REGRESSION_TEST") is not None: | ||
| t_end = 5 * t_export | ||
| end_date = datetime.datetime(2022, 1, 1, 0, 5, tzinfo=sim_tz) |
There was a problem hiding this comment.
That's 5 minutes past midnight, no? but the timestep is in hours?
|
[Merged in |
|
@joewallwork : could you resolve the conflicts - if you still want this in, I think this is good to go - otherwise could you close? |
I think it should be sufficient to just go with |
|
Whilst you're looking at this, I've made some changes as part of #438 to speed up CI by reducing |
Affects when options.simulation_initial_date is set *and* self.simulation_time is nonzero (i.e. when running from checkpoint with load_state()).
stephankramer
left a comment
There was a problem hiding this comment.
Also added a fix for restarting with simulation_initial_date
| default_start_date = datetime.datetime(2011, 3, 11, 14, 46, tzinfo=sim_tz) | ||
| default_end_date = datetime.datetime(2011, 3, 11, 16, 46, tzinfo=sim_tz) |
There was a problem hiding this comment.
| default_start_date = datetime.datetime(2011, 3, 11, 14, 46, tzinfo=sim_tz) | |
| default_end_date = datetime.datetime(2011, 3, 11, 16, 46, tzinfo=sim_tz) | |
| default_start_date = sim_tz.localize(datetime.datetime(2011, 3, 11, 14, 46)) | |
| default_end_date = sim_tz.localize(datetime.datetime(2011, 3, 11, 16, 46)) |
If you do:
print(datetime.datetime(2011, 3, 11, 14, 46, tzinfo=sim_tz), sim_tz.localize(datetime.datetime(2011, 3, 11, 14, 46)))
you get
2011-03-11 14:46:00+09:19 2011-03-11 14:46:00+09:00
i.e. the former uses a time zone of UTC+9:19 instead of the correct UTC+9. If I understand correctly, datetime in the standard library only has limited support for timezones, and it doesn't handle the fact that timezones change historically (i.e. Japan used to be on UTC+9:19 but is now UTC+9
| if os.getenv("THETIS_REGRESSION_TEST") is not None: | ||
| t_end = 5 * t_export | ||
| model_options["simulation_initial_date"] = default_start_date | ||
| model_options["simulation_end_date"] = datetime.datetime(2011, 3, 11, 14, 51, tzinfo=sim_tz) |
There was a problem hiding this comment.
| model_options["simulation_end_date"] = datetime.datetime(2011, 3, 11, 14, 51, tzinfo=sim_tz) | |
| model_options["simulation_end_date"] = sim_tz.localize(datetime.datetime(2011, 3, 11, 14, 51)) |
A short PR to make the Tohoku example date-aware. I also noticed that the North Sea example wasn't set up properly for testing: a shorter
t_endvalue was set but unused.