SNABSuite  0.x
Spiking Neural Architecture Benchmark Suite
Functions | Variables
2dim_plot Namespace Reference

Functions

def cm2inch (value)
 
def round_to_divisable (value, divisable)
 
def plot_measure2d (xs, ys, zs, xlabel, ylabel, zlabel="", zmin=None, zmax=None, qualitative=False, contour=True, title=None)
 

Variables

 parser = argparse.ArgumentParser(description='Plot two-dimensional images')
 
 type
 
 float
 
 help
 
 int
 
 default
 
 action
 
 required
 
 True
 
 metavar
 
 nargs
 
 args = parser.parse_args()
 
 simulator = target_file.split('_')[-1].split('.csv')[0]
 
 experiment = target_file.split('/')[-1].split(simulator)[0]
 
 results = np.genfromtxt(target_file, delimiter=',', names=True)
 
 keys = results.dtype.names
 
 data = np.zeros((results.shape[0], len(keys)))
 
 fig
 
 format
 
 bbox_inches
 

Function Documentation

def 2dim_plot.cm2inch (   value)

Definition at line 54 of file 2dim_plot.py.

54 def cm2inch(value):
55  return value / 2.54
56 
57 
def cm2inch(value)
Definition: 2dim_plot.py:54
def 2dim_plot.plot_measure2d (   xs,
  ys,
  zs,
  xlabel,
  ylabel,
  zlabel = "",
  zmin = None,
  zmax = None,
  qualitative = False,
  contour = True,
  title = None 
)

Definition at line 75 of file 2dim_plot.py.

75  zmax=None, qualitative=False, contour=True, title=None):
76  fig = plt.figure(figsize=(cm2inch(5.5), cm2inch(5.5)))
77 
78  ax1 = fig.add_axes([0.0, 0.25, 1.0, 0.85])
79  if title is not None:
80  plt.title(title)
81  ax2 = fig.add_axes([0.0, 0.0, 1.0, 0.05])
82 
83 
84  _, steps_x = np.unique(xs, return_counts=True)
85  _, steps_y = np.unique(ys, return_counts=True)
86  steps_x = np.max(steps_x)
87  steps_y = np.max(steps_y)
88  xs = xs.reshape((steps_y, steps_x))
89  ys = ys.reshape((steps_y, steps_x))
90  zs = zs.reshape((steps_y, steps_x))
91  zs = zs.transpose()
92 
93  # Auto-scale
94  idcs = np.isfinite(zs)
95  if np.sum(idcs) == 0:
96  return
97  if zmin is None:
98  zmin = np.min(zs[idcs])
99  if 0 < zmin < 1:
100  zmin = 0
101  else:
102  zmin = int(zmin)
103  if zmax is None:
104  zmax = round_to_divisable(np.max(zs[idcs]), args.nl - 1)
105  if zmin > 0:
106  zmax = zmax + zmin
107  if 0 < zmax < 1:
108  zmax = 1
109 
110  # Select the colormap
111  if qualitative:
112  cmap = plt.cm.rainbow
113  else:
114  #cmap = plt.cm.Purples
115  # if zmin < 0.0:
116  cmap = plt.cm.PuOr
117  cmap.set_bad('black', 1.)
118 
119  extent = (np.min(xs), np.max(xs), np.min(ys), np.max(ys))
120  ax1.imshow(zs, aspect='auto', origin='lower', extent=extent, cmap=cmap,
121  vmin=zmin, vmax=zmax, interpolation="none")
122 
123  levels = np.linspace(zmin, zmax, args.nl)
124  zs = zs.transpose()
125  if contour:
126  CS2 = ax1.contour(xs, ys, zs, levels, linewidths=0.25,
127  colors='k', vmin=zmin, vmax=zmax)
128  ax1.grid(color='black', linestyle=':', linewidth=0.25)
129  ax1.set_xlabel(xlabel)
130  ax1.set_ylabel(ylabel)
131  cbar = matplotlib.colorbar.ColorbarBase(ax2, cmap=cmap,
132  orientation='horizontal', ticks=levels,
133  norm=matplotlib.colors.Normalize(zmin, zmax))
134  cbar.set_label(zlabel)
135  return fig
136 
137 
def cm2inch(value)
Definition: 2dim_plot.py:54
def round_to_divisable(value, divisable)
Definition: 2dim_plot.py:58
def 2dim_plot.round_to_divisable (   value,
  divisable 
)

Definition at line 58 of file 2dim_plot.py.

58 def round_to_divisable(value, divisable):
59  if value == 0:
60  return 0
61  temp = np.abs(value)
62  a = 0
63  while temp < divisable:
64  temp *= 10.0
65  a += 1
66  if temp % divisable == 0:
67  return value
68  res = old_div((temp - (temp % divisable) + divisable), (10.0**a))
69  if value < 0:
70  return -res
71  return res
72 
73 
def round_to_divisable(value, divisable)
Definition: 2dim_plot.py:58

Variable Documentation

2dim_plot.action

Definition at line 36 of file 2dim_plot.py.

2dim_plot.args = parser.parse_args()

Definition at line 44 of file 2dim_plot.py.

2dim_plot.bbox_inches

Definition at line 163 of file 2dim_plot.py.

2dim_plot.data = np.zeros((results.shape[0], len(keys)))

Definition at line 148 of file 2dim_plot.py.

2dim_plot.default

Definition at line 35 of file 2dim_plot.py.

2dim_plot.experiment = target_file.split('/')[-1].split(simulator)[0]

Definition at line 143 of file 2dim_plot.py.

2dim_plot.fig
Initial value:
1 = plot_measure2d(data[:, 0], data[:, 1], data[:, args.z],
2  xlabel=get_label(keys[0]), ylabel=get_label(keys[1]),
3  zlabel=get_label(keys[args.z]), zmin=args.zmin,
4  zmax=args.zmax, qualitative=args.q, contour=args.c,
5  title=SIMULATOR_LABELS[simulator])
def get_label(key)
Definition: dim_labels.py:82
def plot_measure2d(xs, ys, zs, xlabel, ylabel, zlabel="", zmin=None, zmax=None, qualitative=False, contour=True, title=None)
Definition: 2dim_plot.py:75

Definition at line 152 of file 2dim_plot.py.

2dim_plot.float

Definition at line 32 of file 2dim_plot.py.

2dim_plot.format

Definition at line 162 of file 2dim_plot.py.

2dim_plot.help

Definition at line 32 of file 2dim_plot.py.

2dim_plot.int

Definition at line 35 of file 2dim_plot.py.

2dim_plot.keys = results.dtype.names

Definition at line 147 of file 2dim_plot.py.

2dim_plot.metavar

Definition at line 42 of file 2dim_plot.py.

2dim_plot.nargs

Definition at line 42 of file 2dim_plot.py.

2dim_plot.parser = argparse.ArgumentParser(description='Plot two-dimensional images')

Definition at line 29 of file 2dim_plot.py.

2dim_plot.required

Definition at line 41 of file 2dim_plot.py.

2dim_plot.results = np.genfromtxt(target_file, delimiter=',', names=True)

Definition at line 146 of file 2dim_plot.py.

2dim_plot.simulator = target_file.split('_')[-1].split('.csv')[0]

Definition at line 142 of file 2dim_plot.py.

2dim_plot.True

Definition at line 41 of file 2dim_plot.py.

2dim_plot.type

Definition at line 32 of file 2dim_plot.py.