tvaLib
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
lib.vis.Analysis Class Reference

Analysis. More...

Public Member Functions

def __init__ (self)
 

Static Public Member Functions

def plotTODSamplingDistribution (site_analyses, saIxs=None, local=None, fig_name='TOD Sampling', verbose=0, figsize=[15.0, kwargs)
 
def plotIndicatorCounts_worker (data, ax=None, fig_name='Indicator counts', verbose=0, figsize=[15.0)
 
def plotIndicatorCounts (data, local=None, fig_name='Indicator counts', verbose=0, figsize=[15.0, kwargs)
 
def plotMethodGrid (datas, prototype, workerArgs=None, set_ylim=None, local=None, fig_name='Grid', verbose=0, fontsize=16, figsize=[15.0, kwargs)
 
def plotTTCdistros_worker (data, ax=None, klusters=None, klusterColors=['r')
 
def plotTTCdistros (data, local=None, dist_type='pdf', set_ylim=None, fig_name='TTC Frequency', verbose=0, figsize=[15.0, kwargs)
 Axes. More...
 
def plotTTCdistros_grid (datas, klusters, local=None, dist_type='pdf', set_ylim=[0.0, fig_name='TTC Frequency', verbose=0, fontsize=16, figsize=[15.0, kwargs)
 
def siteTTC (data, labels=None, colours=['r', b, c, m, k, g, linestyles=['-.', timehorizon=10.0, local=None, fig_name='TTC Frequency', verbose=0, figsize=[15.0)
 

Static Public Attributes

 klusters
 Verify data completeness. More...
 
 method
 Determine method. More...
 
int kluster_depth = 0
 Loop through klusters. More...
 
 largestSampleSize
 
list x_range = [(x+y)/2.0 for x,y in zip(datum.binStops[:-1],datum.binStops[1:])]
 Operate through data chunks (by kluster) More...
 
 ydata = [x+[y] for x, y in zip(ydata, datum.getFreq())]
 
list ydata = [[] for x in x_range]
 
 intensity
 
 color
 Plot average in thick black. More...
 
 alpha
 
 linestyle
 
 marker
 
 linewidth
 
 size
 
 labelSize
 
 horizontalalignment
 
 verticalalignment
 
 mean
 
 median
 
 percent_low
 
 percent_high
 
 stddev
 
 x_range
 Plot combined statistics if enabled. More...
 
 facecolor
 
 colour
 Determine 'average' line color. More...
 

Detailed Description

Analysis.

Definition at line 1837 of file vis.py.

Constructor & Destructor Documentation

◆ __init__()

def lib.vis.Analysis.__init__ (   self)

Definition at line 1838 of file vis.py.

1838  def __init__(self):
1839  return
1840 

Member Function Documentation

◆ plotIndicatorCounts()

def lib.vis.Analysis.plotIndicatorCounts (   data,
  local = None,
  fig_name = 'Indicator counts',
  verbose = 0,
  figsize = [15.0,
  kwargs 
)
static
Plot indicator counts

    Input:
    ======
    data:       a list of three values: ind below threshold, indicators, user pairs

Definition at line 1885 of file vis.py.

1885  def plotIndicatorCounts(data, local=None, fig_name='Indicator counts', verbose=0, figsize=[15.0,12.0], **kwargs):
1886  ''' Plot indicator counts
1887 
1888  Input:
1889  ======
1890  data: a list of three values: ind below threshold, indicators, user pairs
1891  '''
1892  fig, ax = plt.subplots(num=fig_name, figsize=(figsize[0], figsize[1]))
1893  if(not local): local = tvaLocal.Local()
1894 
1895  Analysis.plotIndicatorCounts_worker(data, ax=ax, fig_name=fig_name, verbose=verbose, **kwargs)
1896 
1897 
1898  ax.set_xlabel(local['vis_cp_hist_x'])
1899  ax.set_ylabel(local['vis_hist_y_cdf'])
1900 
1901  return fig
1902 
1903 

◆ plotIndicatorCounts_worker()

def lib.vis.Analysis.plotIndicatorCounts_worker (   data,
  ax = None,
  fig_name = 'Indicator counts',
  verbose = 0,
  figsize = [15.0 
)
static
Plot indicator counts

    Input:
    ======
    data:       a list of three values: ind below threshold, indicators, user pairs

Definition at line 1872 of file vis.py.

1872  def plotIndicatorCounts_worker(data, ax=None, fig_name='Indicator counts', verbose=0, figsize=[15.0,12.0]):
1873  ''' Plot indicator counts
1874 
1875  Input:
1876  ======
1877  data: a list of three values: ind below threshold, indicators, user pairs
1878  '''
1879  rects1 = ax.bar(0, data[0], color='r') rects2 = ax.bar(0, data[1], color='b')
1880  rects3 = ax.bar(0, data[2], color='g')
1881  return True
1882 
1883 

◆ plotMethodGrid()

def lib.vis.Analysis.plotMethodGrid (   datas,
  prototype,
  workerArgs = None,
  set_ylim = None,
  local = None,
  fig_name = 'Grid',
  verbose = 0,
  fontsize = 16,
  figsize = [15.0,
  kwargs 
)
static
Plot graphs ina a grid based on calculation method. 

Definition at line 1905 of file vis.py.

1905  def plotMethodGrid(datas, prototype, workerArgs=None, set_ylim=None, local=None, fig_name='Grid', verbose=0, fontsize=16, figsize=[15.0,12.0], **kwargs):
1906  ''' Plot graphs ina a grid based on calculation method. '''
1907  if(len(datas) != 12): return False
1908  fig, ((ax11, ax12, ax13, ax14), (ax21, ax22, ax23, ax24), (ax31, ax32, ax33, ax34)) = plt.subplots(3, 4, sharex=True, sharey=True, num=fig_name, figsize=(figsize[0], figsize[1]))
1909  if(not local): local = tvaLocal.Local()
1910 
1911  for data, ax in zip(datas, [ax11, ax12, ax13, ax14, ax21, ax22, ax23, ax24, ax31, ax32, ax33, ax34]):
1912  if(workerArgs): workerArg = workerArgs[datas.index(data)]
1913  else: workerArg = {}
1914  prototype(data, ax=ax, verbose=verbose, **workerArg.update(kwargs))
1915 
1916 
1917  ax31.set_xlabel(local['int_all_instants'], fontsize=int(round(fontsize*0.75,0)))
1918  ax32.set_xlabel(local['int_unique_min'], fontsize=int(round(fontsize*0.75,0)))
1919  ax33.set_xlabel(local['int_unique_15th'], fontsize=int(round(fontsize*0.75,0)))
1920  ax34.set_xlabel(local['int_unique_max_prob'], fontsize=int(round(fontsize*0.75,0)))
1921 
1922  ax11.set_ylabel(local['int_const_vel'], fontsize=int(round(fontsize*0.75,0)))
1923  ax21.set_ylabel(local['int_norm_adapt'], fontsize=int(round(fontsize*0.75,0)))
1924  ax31.set_ylabel(local['int_motion_pattern'], fontsize=int(round(fontsize*0.75,0)))
1925 
1926  fig.text(0.5, 0.00, local['vis_cp_hist_x'], ha='center', va='center')
1927  fig.text(0.06, 0.5, local['vis_hist_y_cdf'], ha='center', va='center', rotation='vertical')
1928 
1929 
1930  if(set_ylim): ax11.set_ylim(set_ylim)
1931  return fig
1932 
1933 
1934 

◆ plotTODSamplingDistribution()

def lib.vis.Analysis.plotTODSamplingDistribution (   site_analyses,
  saIxs = None,
  local = None,
  fig_name = 'TOD Sampling',
  verbose = 0,
  figsize = [15.0,
  kwargs 
)
static
Plot the distribution of seqeuences by time of day, showing daily sampling

    Note that the sample is approximate. Each hour is counted once if at least one sequence starts in that hour

    Input:
    ======

Definition at line 1842 of file vis.py.

1842  def plotTODSamplingDistribution(site_analyses, saIxs=None, local=None, fig_name='TOD Sampling', verbose=0, figsize=[15.0,12.0], **kwargs):
1843  ''' Plot the distribution of seqeuences by time of day, showing daily sampling
1844 
1845  Note that the sample is approximate. Each hour is counted once if at least one sequence starts in that hour
1846 
1847  Input:
1848  ======
1849 
1850 
1851  '''
1852  fig, ax = plt.subplots(num=fig_name, figsize=(figsize[0], figsize[1]))
1853 
1854 
1855  hourBins = [0 for x in range(24)]
1856  for saIx in saIxs:
1857  for x in site_analyses[saIx].getCamSeqs_Hourly():
1858  hourBins[x] += 1
1859 
1860 
1861  plt.plot(range(24), hourBins)
1862 
1863 
1864  ax.set_xlabel(local['vis_tod'])
1865  ax.set_ylabel(local['gen_sequences'])
1866 
1867  return fig
1868 
1869 
1870 

◆ plotTTCdistros()

def lib.vis.Analysis.plotTTCdistros (   data,
  local = None,
  dist_type = 'pdf',
  set_ylim = None,
  fig_name = 'TTC Frequency',
  verbose = 0,
  figsize = [15.0,
  kwargs 
)
static

Axes.

Plot TTC distros for all sites

    Input:
    ======
    data = [[[xBins],[yFreqs]],...]    where xBin is one larger than it's corresponding yFreq
    method = 0: automatic
     1: plot all sites in red
     2: plot 25th and 75th quartile

    type = 'pdf'|'cdf'

Definition at line 2024 of file vis.py.

2024  def plotTTCdistros(data, local=None, dist_type='pdf', set_ylim=None, fig_name='TTC Frequency', verbose=0, figsize=[15.0,12.0], **kwargs):
2025  ''' Plot TTC distros for all sites
2026 
2027  Input:
2028  ======
2029  data = [[[xBins],[yFreqs]],...] where xBin is one larger than it's corresponding yFreq
2030  method = 0: automatic
2031  1: plot all sites in red
2032  2: plot 25th and 75th quartile
2033 
2034  type = 'pdf'|'cdf'
2035  '''
2036  fig, ax = plt.subplots(num=fig_name, figsize=(figsize[0], figsize[1]))
2037  if(not local): local = tvaLocal.Local()
2038 
2039  try: binsize, x_range, mean = Analysis.plotTTCdistros_worker(data, ax=ax, dist_type=dist_type, fig_name=fig_name, verbose=verbose, **kwargs)
2040  except:
2041  tvaLib.printWarning('TTC distribution plotting worker failed in figure "'+fig_name+'".', local['gen_warning'])
2042  return False, False, False
2043 
2044 
2045  ax.set_xlabel(local['vis_cp_hist_x'])
2046  if(dist_type=='cdf'): ax.set_ylabel(local['vis_hist_y_cdf'])
2047  else: ax.set_ylabel(local['vis_hist_y_pdf'].format(binsize))
2048 
2049  return fig, x_range, mean
2050 
2051 

◆ plotTTCdistros_grid()

def lib.vis.Analysis.plotTTCdistros_grid (   datas,
  klusters,
  local = None,
  dist_type = 'pdf',
  set_ylim = [0.0,
  fig_name = 'TTC Frequency',
  verbose = 0,
  fontsize = 16,
  figsize = [15.0,
  kwargs 
)
static
Plot TTC distros for all sites. This version differs from
    plotTTCdistros() in that it takes 12 input distributions.
    TODO: refactor with plotMethodGrid ()

Definition at line 2053 of file vis.py.

2053  def plotTTCdistros_grid(datas, klusters, local=None, dist_type='pdf', set_ylim=[0.0,0.2], fig_name='TTC Frequency', verbose=0, fontsize=16, figsize=[15.0,12.0], **kwargs):
2054  ''' Plot TTC distros for all sites. This version differs from
2055  plotTTCdistros() in that it takes 12 input distributions.
2056  TODO: refactor with plotMethodGrid ()
2057  '''
2058  if(len(datas) != 12): return False
2059  fig, ((ax11, ax12, ax13, ax14), (ax21, ax22, ax23, ax24), (ax31, ax32, ax33, ax34)) = plt.subplots(3, 4, sharex=True, sharey=True, num=fig_name, figsize=(figsize[0], figsize[1]))
2060  if(not local): local = tvaLocal.Local()
2061 
2062  for data, kluster_s, ax in zip(datas, klusters, [ax11, ax12, ax13, ax14, ax21, ax22, ax23, ax24, ax31, ax32, ax33, ax34]):
2063  binsize, _, _ = Analysis.plotTTCdistros_worker(data, ax=ax, klusters=kluster_s, dist_type=dist_type, verbose=verbose, **kwargs)
2064 
2065 
2066  ax31.set_xlabel(local['int_all_instants'], fontsize=int(round(fontsize*0.75,0)))
2067  ax32.set_xlabel(local['int_unique_min'], fontsize=int(round(fontsize*0.75,0)))
2068  ax33.set_xlabel(local['int_unique_15th'], fontsize=int(round(fontsize*0.75,0)))
2069  ax34.set_xlabel(local['int_unique_max_prob'], fontsize=int(round(fontsize*0.75,0)))
2070 
2071  ax11.set_ylabel(local['int_const_vel'], fontsize=int(round(fontsize*0.75,0)))
2072  ax21.set_ylabel(local['int_norm_adapt'], fontsize=int(round(fontsize*0.75,0)))
2073  ax31.set_ylabel(local['int_motion_pattern'], fontsize=int(round(fontsize*0.75,0)))
2074 
2075  fig.text(0.5, 0.00, local['vis_cp_hist_x'], ha='center', va='center')
2076  if(dist_type=='cdf'): fig.text(0.06, 0.5, local['vis_hist_y_cdf'], ha='center', va='center', rotation='vertical')
2077  else: fig.text(0.06, 0.5, local['vis_hist_y_pdf'].format(binsize), ha='center', va='center', rotation='vertical')
2078 
2079 
2080  if(dist_type=='pdf' and set_ylim): ax11.set_ylim(set_ylim)
2081 
2082  return fig
2083 

◆ plotTTCdistros_worker()

def lib.vis.Analysis.plotTTCdistros_worker (   data,
  ax = None,
  klusters = None,
  klusterColors = ['r',
  y,
  klusterLinestyles = ['-' 
)
static

Definition at line 1936 of file vis.py.

1936  def plotTTCdistros_worker(data, ax=None, klusters=None, klusterColors=['r',(0.105,0.867,0.617),(0.91796875,0.0859375,0.9453125),(0.875,0.12109375,0.03515625),(0.73828125,0.53515625,0.1640625),(0.588,0.380,0),'y'], klusterLinestyles=['-', '-', '--', ':','-.','-'], klusterMarkers = ['', 'o', '', '','','x'], method=0, plotMedian=False, dist_type='pdf', timehorizon=10.0, set_ylim=None, labelSampleSize=False, labelSize=10, shadeBySampleSize=True, dumpMedianData=False, fig_name='TTC Frequency', verbose=0, figsize=[15.0,12.0]):
1937  ''' Plot TTC distros for all sites
1938 

◆ siteTTC()

def lib.vis.Analysis.siteTTC (   data,
  labels = None,
  colours = ['r',
  b,
  c,
  m,
  k,
  g,
  linestyles = ['-.',
  timehorizon = 10.0,
  local = None,
  fig_name = 'TTC Frequency',
  verbose = 0,
  figsize = [15.0 
)
static
Plot TTC cdfs for one site at a time. 

Definition at line 2085 of file vis.py.

2085  def siteTTC(data, labels=None, colours=['r','b','c','m','k','g'], linestyles=['-.','--','-','-','-','-'], timehorizon=10.0, local=None, fig_name='TTC Frequency', verbose=0, figsize=[15.0,12.0]):
2086  ''' Plot TTC cdfs for one site at a time. '''
2087  fig, ax = plt.subplots(num=fig_name, figsize=(figsize[0], figsize[1]))
2088  if(not local): local = tvaLocal.Local()
2089 
2090  rects = []
2091  for datum in data:
2092  for dat in datum:
2093  try:
2094  xrange = [(x+y)/2.0 for x,y in zip(dat[-1].binStops[:-1],dat[-1].binStops[1:])]
2095  if(labels): label = labels[data.index(datum)][0]+' '+labels[data.index(datum)][1][datum.index(dat)]
2096  else: label = ''
2097  rects.append( ax.plot(xrange, dat[-1].getCDF(), label=label, color=colours[data.index(datum)], linestyle=linestyles[datum.index(dat)], linewidth=1))
2098  except:
2099  pass
2100 
2101 
2102  ax.set_xlim([0.0,timehorizon])
2103  ax.set_ylim([0.0,1.0])
2104 
2105 
2106  ax.set_xlabel(local['vis_cp_hist_x'])
2107  ax.set_ylabel(local['vis_hist_y_cdf'])
2108  handles, labels = ax.get_legend_handles_labels()
2109  ax.legend(handles, labels, loc='lower right', prop={'size':16})
2110 
2111 
2112  return fig
2113 

Member Data Documentation

◆ alpha

lib.vis.Analysis.alpha
static

Definition at line 1983 of file vis.py.

◆ color

lib.vis.Analysis.color
static

Plot average in thick black.

Definition at line 1983 of file vis.py.

◆ colour

lib.vis.Analysis.colour
static

Determine 'average' line color.

Definition at line 1998 of file vis.py.

◆ facecolor

lib.vis.Analysis.facecolor
static

Definition at line 1993 of file vis.py.

◆ horizontalalignment

lib.vis.Analysis.horizontalalignment
static

Definition at line 1984 of file vis.py.

◆ intensity

lib.vis.Analysis.intensity
static

Definition at line 1980 of file vis.py.

◆ kluster_depth

int lib.vis.Analysis.kluster_depth = 0
static

Loop through klusters.

Definition at line 1964 of file vis.py.

◆ klusters

lib.vis.Analysis.klusters
static

Verify data completeness.

Definition at line 1956 of file vis.py.

◆ labelSize

lib.vis.Analysis.labelSize
static

Definition at line 1984 of file vis.py.

◆ largestSampleSize

lib.vis.Analysis.largestSampleSize
static

Definition at line 1966 of file vis.py.

◆ linestyle

lib.vis.Analysis.linestyle
static

Definition at line 1983 of file vis.py.

◆ linewidth

lib.vis.Analysis.linewidth
static

Definition at line 1983 of file vis.py.

◆ marker

lib.vis.Analysis.marker
static

Definition at line 1983 of file vis.py.

◆ mean

lib.vis.Analysis.mean
static

Definition at line 1990 of file vis.py.

◆ median

lib.vis.Analysis.median
static

Definition at line 1990 of file vis.py.

◆ method

lib.vis.Analysis.method
static

Determine method.

Definition at line 1960 of file vis.py.

◆ percent_high

lib.vis.Analysis.percent_high
static

Definition at line 1990 of file vis.py.

◆ percent_low

lib.vis.Analysis.percent_low
static

Definition at line 1990 of file vis.py.

◆ size

lib.vis.Analysis.size
static

Definition at line 1984 of file vis.py.

◆ stddev

lib.vis.Analysis.stddev
static

Definition at line 1990 of file vis.py.

◆ verticalalignment

lib.vis.Analysis.verticalalignment
static

Definition at line 1984 of file vis.py.

◆ x_range [1/2]

list lib.vis.Analysis.x_range = [(x+y)/2.0 for x,y in zip(datum.binStops[:-1],datum.binStops[1:])]
static

Operate through data chunks (by kluster)

Definition at line 1971 of file vis.py.

◆ x_range [2/2]

lib.vis.Analysis.x_range
static

Plot combined statistics if enabled.

Definition at line 1993 of file vis.py.

◆ ydata [1/2]

list lib.vis.Analysis.ydata = [x+[y] for x, y in zip(ydata, datum.getFreq())]
static

Definition at line 1973 of file vis.py.

◆ ydata [2/2]

list lib.vis.Analysis.ydata = [[] for x in x_range]
static

Definition at line 1975 of file vis.py.


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