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
 
 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.bunchspace_us=0.02495 #in microseconds
11  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 61 of file lumiTime.py.

References lumiTime.lumiTime.pydatetimefm.

Referenced by lumiTime.lumiTime.OrbitToTimeStr().

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

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

Definition at line 16 of file lumiTime.py.

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

16 
17  def LSDuration(self,norbits):
18  return timedelta(microseconds=(self.nbx*norbits*self.bunchspace_us))
def LSDuration
return datetime.fromtimestamp(ts,tz=pytz.utc) return datetime.utcfromtimestamp(ts) ...
Definition: lumiTime.py:16
def lumiTime.lumiTime.OrbitDuration (   self)

Definition at line 19 of file lumiTime.py.

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

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

19 
20  def OrbitDuration(self):
21  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 32 of file lumiTime.py.

References lumiTime.lumiTime.OrbitToTime().

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

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

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

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

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

22 
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  '''
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 41 of file lumiTime.py.

References lumiTime.lumiTime.OrbitToTime().

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

Definition at line 49 of file lumiTime.py.

References lumiTime.lumiTime.pydatetimefm.

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

49 
50  def StrToDatetime(self,strTime,customfm=''):
51  '''convert string timestamp to python datetime
52  '''
53  result=''
54  try:
55  if not customfm:
56  result=datetime.strptime(strTime,self.pydatetimefm)
57  else:
58  result=datetime.strptime(strTime,customfm)
59  except Exception,er:
60  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().