CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
lumiTime.lumiTime Class Reference
Inheritance diagram for lumiTime.lumiTime:

Public Member Functions

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

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.

5 
6  def __init__(self):
7  self.coraltimefm='MM/DD/YY HH24:MI:SS.FF6'
8  self.pydatetimefm='%m/%d/%y %H:%M:%S.%f'
9  self.nbx=3564
10  self.bunchspace_us=0.025 #in microseconds
11  self.bunchspace_s=25e-09 #in seconds

Member Function Documentation

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

Definition at line 57 of file lumiTime.py.

References lumiTime.lumiTime.pydatetimefm.

Referenced by lumiTime.lumiTime.OrbitToTimeStr().

57 
58  def DatetimeToStr(self,timeValue,customfm=''):
59  '''convert python datetime to string timestamp
60  '''
61  result=''
62  try:
63  if not customfm:
64  result=timeValue.strftime(self.pydatetimefm)
65  else:
66  result=timeValue.strftime(customfm)
67  except Exception,er:
68  print str(er)
return result
def lumiTime.lumiTime.LSDuration (   self,
  norbits 
)

Definition at line 12 of file lumiTime.py.

References lumiTime.lumiTime.bunchspace_us, and lumiTime.lumiTime.nbx.

12 
13  def LSDuration(self,norbits):
14  return timedelta(microseconds=(self.nbx*norbits*self.bunchspace_us))
def lumiTime.lumiTime.OrbitDuration (   self)

Definition at line 15 of file lumiTime.py.

References lumiTime.lumiTime.bunchspace_us, and lumiTime.lumiTime.nbx.

Referenced by lumiTime.lumiTime.OrbitToTime(), and lumiTime.lumiTime.OrbitToTimeStr().

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

Definition at line 28 of file lumiTime.py.

References lumiTime.lumiTime.OrbitToTime().

28 
29  def OrbitToLocalTimestamp(self,begStrTime,orbitnumber,begorbit=0):
30  '''
31  given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
32  '''
33  os.environ['TZ']='CET'
34  time.tzset()
35  orbittime=self.OrbitToTime(begStrTime,orbitnumber,begorbit)
36  return time.mktime(orbittime.timetuple())+orbittime.microsecond/1e6
def OrbitToLocalTimestamp
Definition: lumiTime.py:28
def lumiTime.lumiTime.OrbitToTime (   self,
  begStrTime,
  orbitnumber,
  begorbit = 0 
)
given a orbit number, return its corresponding time. Default run begin time counting from orbit=0

Definition at line 23 of file lumiTime.py.

References lumiTime.lumiTime.OrbitDuration(), and lumiTime.lumiTime.StrToDatetime().

Referenced by lumiTime.lumiTime.OrbitToLocalTimestamp(), and lumiTime.lumiTime.OrbitToUTCTimestamp().

23 
24  def OrbitToTime(self,begStrTime,orbitnumber,begorbit=0):
25  '''
26  given a orbit number, return its corresponding time. Default run begin time counting from orbit=0
27  '''
return self.StrToDatetime(begStrTime)+(orbitnumber-begorbit)*self.OrbitDuration()
def lumiTime.lumiTime.OrbitToTimeStr (   self,
  begStrTime,
  orbitnumber,
  begorbit = 0 
)
given a orbit number, return its corresponding time. Assuming begin time has orbit=0

Definition at line 18 of file lumiTime.py.

References lumiTime.lumiTime.DatetimeToStr(), lumiTime.lumiTime.OrbitDuration(), and lumiTime.lumiTime.StrToDatetime().

18 
19  def OrbitToTimeStr(self,begStrTime,orbitnumber,begorbit=0):
20  '''
21  given a orbit number, return its corresponding time. Assuming begin time has orbit=0
22  '''
return self.DatetimeToStr(self.StrToDatetime(begStrTime)+(orbitnumber-begorbit)*self.OrbitDuration())
def lumiTime.lumiTime.OrbitToUTCTimestamp (   self,
  begStrTime,
  orbitnumber,
  begorbit = 0 
)
given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0

Definition at line 37 of file lumiTime.py.

References lumiTime.lumiTime.OrbitToTime().

37 
38  def OrbitToUTCTimestamp(self,begStrTime,orbitnumber,begorbit=0):
39  '''
40  given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
41  '''
42  os.environ['TZ']='UTC'
43  time.tzset()
44  orbittime=self.OrbitToTime(begStrTime,orbitnumber,begorbit)
return time.mktime(orbittime.timetuple())+(orbittime.microsecond/1e6)
def OrbitToUTCTimestamp
Definition: lumiTime.py:37
def lumiTime.lumiTime.StrToDatetime (   self,
  strTime,
  customfm = '' 
)
convert string timestamp to python datetime

Definition at line 45 of file lumiTime.py.

References lumiTime.lumiTime.pydatetimefm.

Referenced by lumiTime.lumiTime.OrbitToTime(), and lumiTime.lumiTime.OrbitToTimeStr().

45 
46  def StrToDatetime(self,strTime,customfm=''):
47  '''convert string timestamp to python datetime
48  '''
49  result=''
50  try:
51  if not customfm:
52  result=datetime.strptime(strTime,self.pydatetimefm)
53  else:
54  result=datetime.strptime(strTime,customfm)
55  except Exception,er:
56  print str(er)
return result

Member Data Documentation

lumiTime.lumiTime.bunchspace_s

Definition at line 10 of file lumiTime.py.

lumiTime.lumiTime.bunchspace_us

Definition at line 9 of file lumiTime.py.

Referenced by lumiTime.lumiTime.LSDuration(), and lumiTime.lumiTime.OrbitDuration().

lumiTime.lumiTime.coraltimefm

Definition at line 6 of file lumiTime.py.

lumiTime.lumiTime.nbx

Definition at line 8 of file lumiTime.py.

Referenced by lumiTime.lumiTime.LSDuration(), and lumiTime.lumiTime.OrbitDuration().

lumiTime.lumiTime.pydatetimefm

Definition at line 7 of file lumiTime.py.

Referenced by lumiTime.lumiTime.DatetimeToStr(), and lumiTime.lumiTime.StrToDatetime().