XENON1T / cax

Simple data management tool
ISC License
1 stars 2 forks source link

Corrections wrong by several hours due to botched timestamp handling #111

Closed coderdj closed 7 years ago

coderdj commented 7 years ago

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.

coderdj commented 7 years ago

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