MazinLab / MKIDCore

Core Tools
GNU General Public License v3.0
4 stars 0 forks source link

Time stamps/values already in UTC being converted to UTC as if they are referenced to the time zone you are running the code in. #3

Closed nswimmer closed 1 month ago

nswimmer commented 2 years ago

In parse_obslog() in metadata.py, line 204 ingests a UTC string of the form YmdHMS (e.g. 20211016045736) that is already in UTC time. In line 218 of the same function, that UTC time is converted to a timestamp without regards for time zones, which ends up (when running this in Santa Barbara) to push the output utc.timestep() up by 7 (or 8, depending on time of year) hours.

def parse_obslog(file):
    with open(file, 'r') as f:
        lines = f.readlines()
    dat = {}
    for l in lines:
        ldict = json.loads(l)
(204)utc = datetime.strptime(ldict['utc'], "%Y%m%d%H%M%S")
        for k in ldict:
            if k.upper() not in MEC_KEY_INFO:
                continue
            val = ldict[k]
            try:
                dat[k.upper()].add(utc.timestamp(), val)
            except KeyError:
(218)           dat[k.upper()] = MetadataSeries(times=[utc.timestamp()], values=[val])
    return dat
ld-cd commented 1 month ago

@michaelarena See if this was ever resolved

nzivkov commented 1 month ago

Issue was resolved, see lines 258-294 in metadata.py