Formats for Time

From CASA Guides
Jump to navigationJump to search


Overview

Here is some example code to convert different time formats into a more human-readable form -- specifically, to Year/Month/Day Hours:Minutes:Seconds (UTC) The following function will operate on a single value, or a list of values, and return the corresponding human-readable time.


def time_convert(mytime, myunit='s'):
    if type(mytime).__name__ <> 'list': mytime=[mytime]
    myTimestr = []
    for time in mytime:
        q1=qa.quantity(time,myunit)
        time1=qa.time(q1,form='ymd')
        myTimestr.append(time1)
    return myTimestr


converting from MJD seconds

This time format is often used by CASA, for instance in the measurement set and calibration tables. This will be a double-precision float on the order of 4e+09.

#in CASA
time_convert(mytime):


converting from MJD days

This time format is often used by the EVLA, for instance in the reference pointing solutions, scheduling block names, and (possibly) the online flags. This will be a double-precision float on the order of 5e+04.

#in CASA
time_convert(mytime, myunit='d'):