3 from wirecell
import units
6 import matplotlib.pyplot
as plt
7 import matplotlib.lines
as lines
11 pr = fr.planes[planeid]
15 ntbins = pr.paths[0].current.size
17 tmax = tmin + ntbins*period
18 tdelta = (tmax-tmin)/ntbins
19 print 'TBINS:', ntbins, tmin, tmax, tdelta, period
21 pitches = [path.pitchpos
for path
in pr.paths]
22 pdelta = pitches[1] - pitches[0]
23 pmax =
max(map(abs, pitches)) + 0.5*pdelta
25 npbins =
int(round((pmax-pmin)/pdelta))
26 print 'PBINS:', npbins, pmin, pmax, pdelta, (pmax-pmin)/pdelta
28 tlin = numpy.linspace(tmin, tmax, ntbins+1)
29 plin = numpy.linspace(pmin, pmax, npbins+1)
34 times, pitches = numpy.meshgrid(tlin, plin)
35 currents = numpy.zeros((npbins, ntbins))
39 pind =
int(round((pitch - pmin)/pdelta))
41 pind =
min(npbins, pind)
43 pind_ref =
int(round((-pitch - pmin)/pdelta))
44 pind_ref =
max(0, pind_ref)
45 pind_ref =
min(npbins, pind_ref)
47 assert path.current.size == ntbins
50 time = tmin + tind*tdelta
51 terr = time - times[pind, tind]
54 center_line = pitches[pind, tind] + 0.5*pdelta
55 perr = pitch - center_line
56 if abs(terr) >= 0.001*tdelta:
57 print 'time:', tind, time, times[pind, tind], terr
58 if abs(perr) >= 0.001*pdelta:
59 print 'pitch:', pind, pitch, pitches[pind, tind], perr
60 assert abs(terr) < 0.001*tdelta
61 assert abs(perr) < 0.001*pdelta
63 print 'pitch:', pind, pitch, pitches[pind, tind], perr
65 currents[pind, tind] = cur
68 currents[pind_ref, tind] = cur
70 return (times, pitches, currents)
75 Plot field response as time vs impact positions. 77 >>> import wirecell.sigproc.response.persist as per 78 >>> fr = per.load("garfield-1d-3planes-21wires-6impacts.json.bz2") 83 fig, axes = plt.subplots(3, 1, sharex=
True, figsize=(8.0, 10.5))
85 fig.subplots_adjust(left=0.05, right=1.0, top=0.95, bottom=0.05)
87 vlims = [0.1, 0.1, 0.1]
89 for planeid
in range(3):
92 print t.shape, p.shape, c.shape
94 ax.axis([65, 90, -20, 20])
95 ax.set_title(
'Induced Current %s-plane' %
'UVW'[planeid])
96 ax.set_ylabel(
'Pitch [mm]')
97 ax.set_xlabel(
'Time [us]')
98 im = ax.pcolormesh(t/units.us, p/units.mm, c/units.picoampere,
99 vmin=-vlim, vmax=vlim,
101 fig.colorbar(im, ax=[ax], shrink=0.9, pad=0.05)
103 for iwire
in range(10):
104 ax.axhline(-iwire*3*units.mm, linewidth=1, color=
'black')
105 ax.axhline(+iwire*3*units.mm, linewidth=1, color=
'black')
106 ax.axhline(-(iwire+0.5)*3*units.mm, linewidth=1, color=
'gray',
108 ax.axhline(+(iwire+0.5)*3*units.mm, linewidth=1, color=
'gray',
112 print (
"Saving to %s" % filename)
113 if filename.endswith(
".pdf"):
114 print (
"warning: saving to PDF takes an awfully long time. Try PNG.")
116 fig.savefig(filename)
def get_plane(fr, planeid, reflect=True)
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def plot_planes(fr, filename=None)
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)