1 import os,sys,time,calendar
2 from datetime
import datetime,timedelta
24 given a orbit number, return its corresponding time. Assuming begin time has orbit=0
27 def OrbitToTime(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
29 given a orbit number, return its corresponding time. Default run begin time counting from orbit=0
34 given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
36 os.environ[
'TZ']=
'CET'
38 orbittime=self.
OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
39 return time.mktime(orbittime.timetuple())+orbittime.microsecond/1e6
43 given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
45 os.environ[
'TZ']=
'UTC'
47 orbittime=self.
OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
48 return time.mktime(orbittime.timetuple())+(orbittime.microsecond/1e6)
50 '''convert string timestamp to python datetime
57 result=datetime.strptime(strTime,customfm)
62 '''convert python datetime to string timestamp
69 result=timeValue.strftime(customfm)
73 if __name__==
'__main__':
74 begTimeStr=
'03/30/10 10:10:01'
76 print 'orbit 0 : ',c.OrbitToTime(begTimeStr,0,0)
77 print 'orbit 1 : ',c.OrbitToTime(begTimeStr,1,0)
78 print 'orbit 262144 : ',c.OrbitToTime(begTimeStr,262144,0)
79 print 'orbit 0 : ',c.OrbitToUTCTimestamp(begTimeStr,0,0);
80 print 'orbit 0 : ',c.OrbitToLocalTimestamp(begTimeStr,0,0);
def LSDuration
return datetime.fromtimestamp(ts,tz=pytz.utc) return datetime.utcfromtimestamp(ts) ...
def OrbitToLocalTimestamp