CIRA-Pulsars-and-Transients-Group / vcstools

A suite of tools for processing MWA-VCS data
Other
8 stars 8 forks source link

GPS time in voltage filename converted to Perth local time #251

Closed dipietrantonio closed 1 year ago

dipietrantonio commented 1 year ago

EDIT: this comment was wrong, see below.

Hi All,

I just wanted to make sure and confirm that the following is what you intended to do. That is, the TIME value passed to the correlator is local to PERTH (GMT+08) and not UTC. I am referring to the following bit of code

https://github.com/CIRA-Pulsars-and-Transients-Group/vcstools/blob/830ad225c33e54a4673cf9007db49cd713954e1f/scripts/process_vcs.py#L359

Here are some experiments I did in Python to confirm this:

>>> from astropy.time import Time
>>> gpstime=1276619418
>>> t = Time(int(gpstime), format='gps', scale='utc')
>>> t.unix
1592584200.0
>>> datetime = t.to_datetime()
>>> datetime.astimezone().isoformat()
'2020-06-19T16:30:00+08:00'
>>> from datetime import timezone
>>> datetime.astimezone(timezone.utc).isoformat()
'2020-06-19T08:30:00+00:00'
>>> datetime_utc = datetime.astimezone(timezone.utc)       
>>> datetime_utc.timestamp()
1592555400.0

You can get the last value also using this (C++) code

time_t gps_to_unix(time_t gps){
    const time_t gps_epoch_in_unix_time {315936000ll};
    const time_t gps_leap_seconds {18ll}; // since 31/12/2016
    return gps_epoch_in_unix_time + gps - gps_leap_seconds;
}
dipietrantonio commented 1 year ago

Hi guys,

sorry for opening this issue. My calculations were wrong, should not work on a Saturday night.

in particular, the line

>>> datetime = t.to_datetime()

messed up all the subsequent commands.

Also,

const time_t gps_epoch_in_unix_time {315936000ll};

should be

const time_t gps_epoch_in_unix_time {315964800ll};

sorry for the confusion, I will close this ticket.