CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
lumiTime.lumiTime Class Reference
Inheritance diagram for lumiTime.lumiTime:

Public Member Functions

def __init__ (self)
 
def DatetimeToStr (self, timeValue, customfm='')
 
def LSDuration (self)
 return datetime.fromtimestamp(ts,tz=pytz.utc) return datetime.utcfromtimestamp(ts) More...
 
def OrbitDuration (self, norbits=1)
 
def OrbitToLocalTimestamp (self, begStrTime, orbitnumber, begorbit=0, customfm='')
 
def OrbitToTime (self, begStrTime, orbitnumber, begorbit=0, customfm='')
 
def OrbitToTimeStr (self, begStrTime, orbitnumber, begorbit=0, customfm='')
 
def OrbitToUTCTimestamp (self, begStrTime, orbitnumber, begorbit=0, customfm='')
 
def StrToDatetime (self, strTime, customfm='')
 

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  def __init__(self):
6  self.coraltimefm='MM/DD/YY HH24:MI:SS'
7  self.pydatetimefm='%m/%d/%y %H:%M:%S'
8  self.nbx=3564
9  self.orbits_per_ls=262144 # a lumisection is 2**18 orbits
10  self.bunchspace_us=0.02495 #in microseconds
11  self.bunchspace_s=24.95e-09 #in seconds
12 
def __init__(self)
Definition: lumiTime.py:5

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, and str.

Referenced by lumiTime.lumiTime.OrbitToTimeStr().

64  def DatetimeToStr(self,timeValue,customfm=''):
65  '''convert python datetime to string timestamp
66  '''
67  result=''
68  try:
69  if not customfm:
70  result=timeValue.strftime(self.pydatetimefm)
71  else:
72  result=timeValue.strftime(customfm)
73  except Exception as er:
74  print str(er)
75  return result
def DatetimeToStr(self, timeValue, customfm='')
Definition: lumiTime.py:64
#define str(s)
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  def LSDuration(self):
18  return self.OrbitDuration(self.orbits_per_ls)
19 
def OrbitDuration(self, norbits=1)
Definition: lumiTime.py:20
def LSDuration(self)
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  def OrbitDuration(self, norbits = 1):
21  return timedelta(microseconds=(self.nbx*norbits*self.bunchspace_us))
22 
def OrbitDuration(self, norbits=1)
Definition: lumiTime.py:20
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  def OrbitToLocalTimestamp(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
36  '''
37  given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
38  '''
39  os.environ['TZ']='CET'
40  time.tzset()
41  orbittime=self.OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
42  return time.mktime(orbittime.timetuple())+orbittime.microsecond/1e6
43 
def OrbitToTime(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:29
def OrbitToLocalTimestamp(self, begStrTime, orbitnumber, begorbit=0, customfm='')
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  def OrbitToTime(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
30  '''
31  given a orbit number, return its corresponding time. Default run begin time counting from orbit=0
32  '''
33  return self.StrToDatetime(begStrTime,customfm=customfm)+self.OrbitDuration(orbitnumber-begorbit)
34 
def OrbitToTime(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:29
def OrbitDuration(self, norbits=1)
Definition: lumiTime.py:20
def StrToDatetime(self, strTime, customfm='')
Definition: lumiTime.py:52
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  def OrbitToTimeStr(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
24  '''
25  given a orbit number, return its corresponding time. Assuming begin time has orbit=0
26  '''
27  return self.DatetimeToStr(self.StrToDatetime(begStrTime)+self.OrbitDuration(orbitnumber-begorbit),customfm=customfm)
28 
def DatetimeToStr(self, timeValue, customfm='')
Definition: lumiTime.py:64
def OrbitDuration(self, norbits=1)
Definition: lumiTime.py:20
def StrToDatetime(self, strTime, customfm='')
Definition: lumiTime.py:52
def OrbitToTimeStr(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:23
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  def OrbitToUTCTimestamp(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
45  '''
46  given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
47  '''
48  os.environ['TZ']='UTC'
49  time.tzset()
50  orbittime=self.OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
51  return time.mktime(orbittime.timetuple())+(orbittime.microsecond/1e6)
def OrbitToTime(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:29
def OrbitToUTCTimestamp(self, begStrTime, orbitnumber, begorbit=0, customfm='')
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, and str.

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

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

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().