XENON1T / cax

Simple data management tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Corrections wrong by several hours due to botched timestamp handling

coderdj opened this issue · comments

Shingo noticed today gains are calculated with the wrong timestamps. The run docs use UTC, the gain function uses UTC, but cax seems not to.

In the corrections.py file there are three instances where datetime.timestamp() is called. Only one of these provides a timezone (as it should). If a timezone-naive datetime is provided to .timestamp() it assumes local time of wherever it is being run. This means the faulty calls give a +2 to -5 hour offset depending on site.

Here for electron lifetime (wrong): https://github.com/XENON1T/cax/blob/master/cax/tasks/corrections.py#L159
Here in gain pulling function (right, but...):
https://github.com/XENON1T/cax/blob/master/cax/tasks/corrections.py#L159
Here where gain evaluated (wrong again):
https://github.com/XENON1T/cax/blob/master/cax/tasks/corrections.py#L159

I'll make a PR where we just add the tzinfo to the two 'wrong' ones above. But maybe someone with an idea wants to have a look.

Fix was merged so this can be closed. Careful with those timezones!