CMS 3D CMS Logo

Public Member Functions | Public Attributes

lumiTime::lumiTime Class Reference

List of all members.

Public Member Functions

def __init__
def DatetimeToStr
def LSDuration
def OrbitDuration
def OrbitToLocalTimestamp
def OrbitToTime
def OrbitToTimeStr
def OrbitToUTCTimestamp
def StrToDatetime
def timestampTodatetimeUTC

Public Attributes

 bunchspace_s
 bunchspace_us
 coraltimefm
 nbx
 pydatetimefm

Detailed Description

Definition at line 4 of file lumiTime.py.


Constructor & Destructor Documentation

def lumiTime::lumiTime::__init__ (   self)

Definition at line 5 of file lumiTime.py.

00006                       :
00007         self.coraltimefm='MM/DD/YY HH24:MI:SS'
00008         self.pydatetimefm='%m/%d/%y %H:%M:%S'
00009         self.nbx=3564
00010         self.bunchspace_us=0.02495 #in microseconds
00011         self.bunchspace_s=24.95e-09 #in seconds
        

Member Function Documentation

def lumiTime::lumiTime::DatetimeToStr (   self,
  timeValue,
  customfm = '' 
)
convert python datetime to string timestamp

Definition at line 60 of file lumiTime.py.

00061                                                  :
00062         '''convert python datetime to string timestamp
00063         '''
00064         result=''
00065         try:
00066             if not customfm:
00067                 result=timeValue.strftime(self.pydatetimefm)
00068             else:
00069                 result=timeValue.strftime(customfm)
00070         except Exception,er:
00071             print str(er)
        return result
def lumiTime::lumiTime::LSDuration (   self,
  norbits 
)

Definition at line 15 of file lumiTime.py.

00016                                 :
00017         return timedelta(microseconds=(self.nbx*norbits*self.bunchspace_us))
    
def lumiTime::lumiTime::OrbitDuration (   self)

Definition at line 18 of file lumiTime.py.

00019                            :
00020         return timedelta(microseconds=(self.nbx*self.bunchspace_us))
    
def lumiTime::lumiTime::OrbitToLocalTimestamp (   self,
  begStrTime,
  orbitnumber,
  begorbit = 0,
  customfm = '' 
)
given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0

Definition at line 31 of file lumiTime.py.

00032                                                                                  :
00033         '''
00034         given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
00035         '''
00036         os.environ['TZ']='CET'
00037         time.tzset()
00038         orbittime=self.OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
00039         return time.mktime(orbittime.timetuple())+orbittime.microsecond/1e6

def lumiTime::lumiTime::OrbitToTime (   self,
  begStrTime,
  orbitnumber,
  begorbit = 0,
  customfm = '' 
)
given a orbit number, return its corresponding time. Default run begin time counting from orbit=0

Definition at line 26 of file lumiTime.py.

00027                                                                        :
00028         '''
00029         given a orbit number, return its corresponding time. Default run begin time counting from orbit=0
00030         '''
        return self.StrToDatetime(begStrTime,customfm=customfm)+(orbitnumber-begorbit)*self.OrbitDuration()
def lumiTime::lumiTime::OrbitToTimeStr (   self,
  begStrTime,
  orbitnumber,
  begorbit = 0,
  customfm = '' 
)
given a orbit number, return its corresponding time. Assuming begin time has orbit=0

Definition at line 21 of file lumiTime.py.

00022                                                                           :
00023         '''
00024         given a orbit number, return its corresponding time. Assuming begin time has orbit=0
00025         '''
        return self.DatetimeToStr(self.StrToDatetime(begStrTime)+(orbitnumber-begorbit)*self.OrbitDuration(),customfm=customfm)
def lumiTime::lumiTime::OrbitToUTCTimestamp (   self,
  begStrTime,
  orbitnumber,
  begorbit = 0,
  customfm = '' 
)
given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0

Definition at line 40 of file lumiTime.py.

00041                                                                                :
00042         '''
00043         given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
00044         '''
00045         os.environ['TZ']='UTC'
00046         time.tzset()
00047         orbittime=self.OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
        return time.mktime(orbittime.timetuple())+(orbittime.microsecond/1e6)
def lumiTime::lumiTime::StrToDatetime (   self,
  strTime,
  customfm = '' 
)
convert string timestamp to python datetime

Definition at line 48 of file lumiTime.py.

00049                                                :
00050         '''convert string timestamp to python datetime
00051         '''
00052         result=''
00053         try:
00054             if not customfm:
00055                 result=datetime.strptime(strTime,self.pydatetimefm)
00056             else:
00057                 result=datetime.strptime(strTime,customfm)
00058         except Exception,er:
00059             print str(er)
        return result
def lumiTime::lumiTime::timestampTodatetimeUTC (   self,
  ts 
)

Definition at line 12 of file lumiTime.py.

00013                                        :
00014         return datetime.fromtimestamp(ts,tz=pytz.utc)
    

Member Data Documentation

Definition at line 5 of file lumiTime.py.

Definition at line 5 of file lumiTime.py.

Definition at line 5 of file lumiTime.py.

Definition at line 5 of file lumiTime.py.

Definition at line 5 of file lumiTime.py.