Formats for Time: Difference between revisions
From CASA Guides
Jump to navigationJump to search
Created page with "tbd" |
No edit summary |
||
Line 1: | Line 1: | ||
[[Category:EVLA]] | |||
== 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. | |||
<source lang="python"> | |||
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 | |||
</source> | |||
== 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. | |||
<source lang="python"> | |||
#in CASA | |||
time_convert(mytime): | |||
</source> | |||
== 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. | |||
<source lang="python"> | |||
#in CASA | |||
time_convert(mytime, myunit='d'): | |||
</source> |
Latest revision as of 21:02, 18 March 2011
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'):