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 5 of file lumiTime.py.

Constructor & Destructor Documentation

def lumiTime.lumiTime.__init__ (   self)

Definition at line 6 of file lumiTime.py.

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
13 
def __init__(self)
Definition: lumiTime.py:6

Member Function Documentation

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

Definition at line 65 of file lumiTime.py.

References edm.print(), lumiTime.lumiTime.pydatetimefm, and str.

Referenced by lumiTime.lumiTime.OrbitToTimeStr().

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 as er:
75  print(str(er))
76  return result
def DatetimeToStr(self, timeValue, customfm='')
Definition: lumiTime.py:65
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
#define str(s)
def lumiTime.lumiTime.LSDuration (   self)

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

Definition at line 18 of file lumiTime.py.

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

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

Definition at line 21 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().

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

References lumiTime.lumiTime.OrbitToTime().

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
44 
def OrbitToTime(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:30
def OrbitToLocalTimestamp(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:36
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 30 of file lumiTime.py.

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

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

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)
35 
def OrbitToTime(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:30
def OrbitDuration(self, norbits=1)
Definition: lumiTime.py:21
def StrToDatetime(self, strTime, customfm='')
Definition: lumiTime.py:53
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 24 of file lumiTime.py.

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

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)
29 
def DatetimeToStr(self, timeValue, customfm='')
Definition: lumiTime.py:65
def OrbitDuration(self, norbits=1)
Definition: lumiTime.py:21
def StrToDatetime(self, strTime, customfm='')
Definition: lumiTime.py:53
def OrbitToTimeStr(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:24
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 45 of file lumiTime.py.

References lumiTime.lumiTime.OrbitToTime().

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)
52  return time.mktime(orbittime.timetuple())+(orbittime.microsecond/1e6)
def OrbitToTime(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:30
def OrbitToUTCTimestamp(self, begStrTime, orbitnumber, begorbit=0, customfm='')
Definition: lumiTime.py:45
def lumiTime.lumiTime.StrToDatetime (   self,
  strTime,
  customfm = '' 
)
convert string timestamp to python datetime

Definition at line 53 of file lumiTime.py.

References edm.print(), lumiTime.lumiTime.pydatetimefm, and str.

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

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 as er:
63  print(str(er))
64  return result
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def StrToDatetime(self, strTime, customfm='')
Definition: lumiTime.py:53
#define str(s)

Member Data Documentation

lumiTime.lumiTime.bunchspace_s

Definition at line 12 of file lumiTime.py.

lumiTime.lumiTime.bunchspace_us

Definition at line 11 of file lumiTime.py.

Referenced by lumiTime.lumiTime.OrbitDuration().

lumiTime.lumiTime.coraltimefm

Definition at line 7 of file lumiTime.py.

lumiTime.lumiTime.nbx

Definition at line 9 of file lumiTime.py.

Referenced by lumiTime.lumiTime.OrbitDuration().

lumiTime.lumiTime.orbits_per_ls

Definition at line 10 of file lumiTime.py.

Referenced by lumiTime.lumiTime.LSDuration().

lumiTime.lumiTime.pydatetimefm

Definition at line 8 of file lumiTime.py.

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