tvaLib
Public Member Functions | Public Attributes | List of all members
lib.vis.interactionTimeseries Class Reference
Inheritance diagram for lib.vis.interactionTimeseries:
lib.vis.basicPlot

Public Member Functions

def __init__ (self, userPairs, fps, alpha=0.1, fig_name='TTC timeseries', kwargs)
 
def addTimeseries (self, userPairs, fps)
 
def computeAverage (self)
 
def plotExpectation (self)
 
def setAxes (self)
 
def get (self)
 
- Public Member Functions inherited from lib.vis.basicPlot
def __init__ (self, fig_rows=1, fig_columns=1, local=None, sharex=False, sharey=False, fig_name='Basic Figure', verbose=0, figsize=[15.0, kwargs)
 
def setAxes (self, x_lavbel=['x'], y_lavbel=['y'])
 
def compileFigure (self)
 
def get (self)
 

Public Attributes

 alpha
 
 avgVal
 
 avgValWeight
 
 expectationIntercept
 
- Public Attributes inherited from lib.vis.basicPlot
 local
 
 verbose
 
 axes
 

Detailed Description

Definition at line 1592 of file vis.py.

Constructor & Destructor Documentation

◆ __init__()

def lib.vis.interactionTimeseries.__init__ (   self,
  userPairs,
  fps,
  alpha = 0.1,
  fig_name = 'TTC timeseries',
  kwargs 
)

Definition at line 1593 of file vis.py.

1593  def __init__(self, userPairs, fps, alpha=0.1, fig_name='TTC timeseries', **kwargs):
1594  basicPlot.__init__(self, fig_name=fig_name, **kwargs)
1595  self.alpha = alpha
1596  self.avgVal = {}
1597  self.avgValWeight = {}
1598  self.expectationIntercept = 8
1599  self.addTimeseries(userPairs, fps)
1600 
1601 

Member Function Documentation

◆ addTimeseries()

def lib.vis.interactionTimeseries.addTimeseries (   self,
  userPairs,
  fps 
)

Definition at line 1602 of file vis.py.

1602  def addTimeseries(self, userPairs, fps):
1603  if(userPairs):
1604  for userPair in userPairs:
1605  point_list = userPair.getPointList()
1606  if(point_list):
1607  point_list = sorted(point_list, key=lambda x: x[4])
1608  # Select offset style
1609  #ti = 0 # first indicator
1610  min_ttc = min([x[0] for x in point_list])
1611  ti = [x for x,y in zip(range(len(point_list)),point_list) if y[0] == min_ttc][0]# minimum TTC
1612  # ti +TTC_ti -intercept
1613  offset = point_list[ti][4]/float(fps)+point_list[ti][0]/float(fps)-self.expectationIntercept
1614  for t,ttc in zip([x[4]/float(fps)-offset for x in point_list], [x[0]/float(fps) for x in point_list]):
1615  t = round(t, 1)
1616  try: self.avgVal[t] += ttc
1617  except: self.avgVal[t] = ttc
1618  try: self.avgValWeight[t] += 1
1619  except: self.avgValWeight[t] = 1
1620  self.axes.plot([x[4]/float(fps)-offset for x in point_list], [x[0]/float(fps) for x in point_list], color='b', alpha=self.alpha)
1621 

◆ computeAverage()

def lib.vis.interactionTimeseries.computeAverage (   self)

Definition at line 1622 of file vis.py.

1622  def computeAverage(self):
1623  try: maxSampleSize = max(self.avgValWeight.values())
1624  except ValueError: return False
1625  x = sorted(self.avgVal.keys())
1626  y = [self.avgVal[t]/float(self.avgValWeight[t]) if (self.avgValWeight[t] > maxSampleSize*0.05) else None for t in x]
1627  self.axes.plot(x, y, linewidth=3, color='k', zorder=9000, label=self.local['gen_average'])
1628 

◆ get()

def lib.vis.interactionTimeseries.get (   self)

Definition at line 1638 of file vis.py.

1638  def get(self):
1639  self.plotExpectation()
1640  self.computeAverage()
1641  self.axes.legend()
1642  return basicPlot.get(self)
1643 
1644 

◆ plotExpectation()

def lib.vis.interactionTimeseries.plotExpectation (   self)

Definition at line 1629 of file vis.py.

1629  def plotExpectation(self):
1630  self.axes.plot([0,self.expectationIntercept], [self.expectationIntercept,0], c='k', linewidth=2, alpha=0.5, linestyle='dashed', label=self.local['vis_expected_evolution'])
1631 

◆ setAxes()

def lib.vis.interactionTimeseries.setAxes (   self)

Definition at line 1632 of file vis.py.

1632  def setAxes(self):
1633  self.axes.set_xlabel(self.local['vis_timeseries_x'])
1634  self.axes.set_ylabel(self.local['vis_cp_hist_x_v2'])
1635  self.axes.set_xlim(0, self.expectationIntercept*1.3)
1636  self.axes.set_ylim(0, self.expectationIntercept*1.3)
1637 

Member Data Documentation

◆ alpha

lib.vis.interactionTimeseries.alpha

Definition at line 1595 of file vis.py.

◆ avgVal

lib.vis.interactionTimeseries.avgVal

Definition at line 1596 of file vis.py.

◆ avgValWeight

lib.vis.interactionTimeseries.avgValWeight

Definition at line 1597 of file vis.py.

◆ expectationIntercept

lib.vis.interactionTimeseries.expectationIntercept

Definition at line 1598 of file vis.py.


The documentation for this class was generated from the following file: