Public Member Functions | Public Attributes | List of all members
wirecell.gen.sim.Frame Class Reference
Inheritance diagram for wirecell.gen.sim.Frame:

Public Member Functions

def __init__ (self, fp, ident=0, tag='')
 
def plot_ticks (self, tick0=0, tickf=-1, raw=True, chinds=())
 
def plot (self, t0=None, tf=None, raw=True, chinds=())
 

Public Attributes

 channel_boundaries
 

Detailed Description

Definition at line 68 of file sim.py.

Constructor & Destructor Documentation

def wirecell.gen.sim.Frame.__init__ (   self,
  fp,
  ident = 0,
  tag = '' 
)

Definition at line 69 of file sim.py.

69  def __init__(self, fp, ident=0, tag=''):
70  def thing(n):
71  arr = fp['%s_%s_%d' % (n, tag, ident)]
72  if n == 'frame':
73  return arr.T
74  return arr
75 
76  for n in 'frame channels tickinfo'.split():
77  setattr(self, n, thing(n))
78 
80 
def __init__(self, fp, ident=0, tag='')
Definition: sim.py:69
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35

Member Function Documentation

def wirecell.gen.sim.Frame.plot (   self,
  t0 = None,
  tf = None,
  raw = True,
  chinds = () 
)

Definition at line 121 of file sim.py.

121  def plot(self, t0=None, tf=None, raw=True, chinds = ()):
122 
123  frame = self.frame
124  if not raw:
125  frame = baseline_subtract(frame)
126 
127  tstart, tick = self.tickinfo[:2]
128  nticks = frame.shape[1]
129  tend = tstart + nticks*tick
130 
131  if t0 is None or t0 < tstart or t0 > tend:
132  t0 = tstart
133 
134  if tf is None or tf < t0 or tf > tend:
135  tf = tend
136 
137  tick0 = int((t0-tstart)/tick)
138  tickf = int((tf-tstart)/tick)
139 
140  #print ("trange=[%.2f %.2f]ms ticks=[%d,%d]" % (t0/units.ms,tf/units.ms,tick0,tickf))
141 
142  if not chinds:
143  chinds = group_channel_indices(self.channels)
144  ngroups = len(chinds)
145  fig, axes = plt.subplots(nrows=ngroups, ncols=1, sharex = True)
146  if ngroups == 1:
147  axes = [axes] # always list
148 
149  for ax, chind in zip(axes, chinds):
150  ngroups -= 1
151  chind0 = chind[0]
152  chind1 = chind[1]
153 
154  ch1 = self.channels[chind0]
155  ch2 = self.channels[chind1-1]
156 
157  extent = (t0/units.ms, tf/units.ms, ch2, ch1)
158  print ("exent: %s, chind=(%d,%d)" % (str(extent), chind0, chind1) )
159 
160 
161  #print (chind,extent, chind, tick0, tickf, frame.shape)
162  im = ax.imshow(frame[chind0:chind1,tick0:tickf],
163  aspect='auto', extent=extent, interpolation='none')
164  plt.colorbar(im, ax=ax)
165  if not ngroups:
166  ax.set_xlabel('time [ms]')
167 
168  #plt.savefig(outfile)
169  return fig,axes
170 
171  #plt.imshow(fr[ch[0]:ch[1], ti[0]:ti[1]], extent=[ti[0], ti[1], ch[1], ch[0]], aspect='auto', interpolation='none'); plt.colorbar()
172 
173 
174 # f = numpy.load("test-boundaries.npz"); reload(sim);
175 # fo = sim.Frame(f)
176 # fo.plot()
177 # dd = f['depo_data_0']
178 # plt.scatter(dd[2]/units.m, dd[4]/units.m)
179 
def plot(self, t0=None, tf=None, raw=True, chinds=())
Definition: sim.py:121
def baseline_subtract(frame)
Definition: sim.py:15
def group_channel_indices(channels, boundaries=())
Definition: sim.py:30
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
static QCString str
def wirecell.gen.sim.Frame.plot_ticks (   self,
  tick0 = 0,
  tickf = -1,
  raw = True,
  chinds = () 
)
Plot in terms of ticks.  Here, the frame is assumed to be
dense and chinds are taken as channel ranges.

Definition at line 81 of file sim.py.

81  def plot_ticks(self, tick0=0, tickf=-1, raw=True, chinds = ()):
82  '''
83  Plot in terms of ticks. Here, the frame is assumed to be
84  dense and chinds are taken as channel ranges.
85  '''
86  frame = self.frame
87  print ("Frame shape: %s" % str(frame.shape))
88 
89  if not raw:
90  frame = baseline_subtract(frame)
91 
92 
93  if not chinds:
94  chinds = group_channel_indices(self.channels, self.channel_boundaries)
95 
96  tick = self.tickinfo[1]
97  if tickf < 0:
98  tickf += frame.shape[1]
99 
100  ngroups = len(chinds)
101  fig, axes = plt.subplots(nrows=ngroups, ncols=1, sharex = True)
102  if ngroups == 1:
103  axes = [axes] # always list
104 
105  for ax, chind in zip(axes, chinds):
106  ngroups -= 1
107  ch1 = self.channels[chind[0]]
108  ch2 = self.channels[chind[1]-1]
109 
110  extent = (tick0, tickf, ch2, ch1)
111  print ("exent: %s" % str(extent))
112 
113  im = ax.imshow(frame[chind[0]:chind[1],tick0:tickf],
114  aspect='auto', extent=extent, interpolation='none')
115  plt.colorbar(im, ax=ax)
116  if not ngroups:
117  ax.set_xlabel('ticks (%.2f us)' % (tick/units.us),)
118 
119  return fig,axes
120 
def plot_ticks(self, tick0=0, tickf=-1, raw=True, chinds=())
Definition: sim.py:81
def baseline_subtract(frame)
Definition: sim.py:15
def group_channel_indices(channels, boundaries=())
Definition: sim.py:30
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
static QCString str

Member Data Documentation

wirecell.gen.sim.Frame.channel_boundaries

Definition at line 79 of file sim.py.


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