1 import os,sys,time,calendar
2 from datetime
import datetime,timedelta
25 given a orbit number, return its corresponding time. Assuming begin time has orbit=0
29 def OrbitToTime(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
31 given a orbit number, return its corresponding time. Default run begin time counting from orbit=0
37 given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
39 os.environ[
'TZ']=
'CET'
41 orbittime=self.
OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
42 return time.mktime(orbittime.timetuple())+orbittime.microsecond/1e6
46 given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
48 os.environ[
'TZ']=
'UTC'
50 orbittime=self.
OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
51 return time.mktime(orbittime.timetuple())+(orbittime.microsecond/1e6)
53 '''convert string timestamp to python datetime
60 result=datetime.strptime(strTime,customfm)
61 except Exception
as er:
65 '''convert python datetime to string timestamp
72 result=timeValue.strftime(customfm)
73 except Exception
as er:
76 if __name__==
'__main__':
77 begTimeStr=
'03/30/10 10:10:01'
79 print 'orbit 0 : ',c.OrbitToTime(begTimeStr,0,0)
80 print 'orbit 1 : ',c.OrbitToTime(begTimeStr,1,0)
81 print 'orbit 262144 : ',c.OrbitToTime(begTimeStr,262144,0)
82 print 'orbit 0 : ',c.OrbitToUTCTimestamp(begTimeStr,0,0);
83 print 'orbit 0 : ',c.OrbitToLocalTimestamp(begTimeStr,0,0);
def LSDuration
return datetime.fromtimestamp(ts,tz=pytz.utc) return datetime.utcfromtimestamp(ts) ...
def OrbitToLocalTimestamp