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
 return datetime.fromtimestamp(ts,tz=pytz.utc) return datetime.utcfromtimestamp(ts) More...
 
def OrbitDuration
 
def OrbitToLocalTimestamp
 
def OrbitToTime
 
def OrbitToTimeStr
 
def OrbitToUTCTimestamp
 
def StrToDatetime
 

Public Attributes

 bunchspace_s
 
 bunchspace_us
 
 coraltimefm
 
 nbx
 
 orbits_per_ls
 
 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'
8  self.pydatetimefm='%m/%d/%y %H:%M:%S'
9  self.nbx=3564
10  self.orbits_per_ls=262144 # a lumisection is 2**18 orbits
11  self.bunchspace_us=0.02495 #in microseconds
12  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 64 of file lumiTime.py.

References lumiTime.lumiTime.pydatetimefm.

Referenced by lumiTime.lumiTime.OrbitToTimeStr().

64 
65  def DatetimeToStr(self,timeValue,customfm=''):
66  '''convert python datetime to string timestamp
67  '''
68  result=''
69  try:
70  if not customfm:
71  result=timeValue.strftime(self.pydatetimefm)
72  else:
73  result=timeValue.strftime(customfm)
74  except Exception,er:
75  print str(er)
return result
def lumiTime.lumiTime.LSDuration (   self)

return datetime.fromtimestamp(ts,tz=pytz.utc) return datetime.utcfromtimestamp(ts)

Definition at line 17 of file lumiTime.py.

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

17 
18  def LSDuration(self):
19  return self.OrbitDuration(self.orbits_per_ls)
def LSDuration
return datetime.fromtimestamp(ts,tz=pytz.utc) return datetime.utcfromtimestamp(ts) ...
Definition: lumiTime.py:17
def lumiTime.lumiTime.OrbitDuration (   self,
  norbits = 1 
)

Definition at line 20 of file lumiTime.py.

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

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

20 
21  def OrbitDuration(self, norbits = 1):
22  return timedelta(microseconds=(self.nbx*norbits*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 35 of file lumiTime.py.

References lumiTime.lumiTime.OrbitToTime().

35 
36  def OrbitToLocalTimestamp(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
37  '''
38  given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
39  '''
40  os.environ['TZ']='CET'
41  time.tzset()
42  orbittime=self.OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
43  return time.mktime(orbittime.timetuple())+orbittime.microsecond/1e6
def OrbitToLocalTimestamp
Definition: lumiTime.py:35
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 29 of file lumiTime.py.

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

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

29 
30  def OrbitToTime(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
31  '''
32  given a orbit number, return its corresponding time. Default run begin time counting from orbit=0
33  '''
34  return self.StrToDatetime(begStrTime,customfm=customfm)+self.OrbitDuration(orbitnumber-begorbit)
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 23 of file lumiTime.py.

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

23 
24  def OrbitToTimeStr(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
25  '''
26  given a orbit number, return its corresponding time. Assuming begin time has orbit=0
27  '''
28  return self.DatetimeToStr(self.StrToDatetime(begStrTime)+self.OrbitDuration(orbitnumber-begorbit),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 44 of file lumiTime.py.

References lumiTime.lumiTime.OrbitToTime().

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

Definition at line 52 of file lumiTime.py.

References lumiTime.lumiTime.pydatetimefm.

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

52 
53  def StrToDatetime(self,strTime,customfm=''):
54  '''convert string timestamp to python datetime
55  '''
56  result=''
57  try:
58  if not customfm:
59  result=datetime.strptime(strTime,self.pydatetimefm)
60  else:
61  result=datetime.strptime(strTime,customfm)
62  except Exception,er:
63  print str(er)
return result

Member Data Documentation

lumiTime.lumiTime.bunchspace_s

Definition at line 11 of file lumiTime.py.

lumiTime.lumiTime.bunchspace_us

Definition at line 10 of file lumiTime.py.

Referenced by 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.OrbitDuration().

lumiTime.lumiTime.orbits_per_ls

Definition at line 9 of file lumiTime.py.

Referenced by lumiTime.lumiTime.LSDuration().

lumiTime.lumiTime.pydatetimefm

Definition at line 7 of file lumiTime.py.

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