116 Plot slice information as criss crossing wires and blob regions. 118 from .
import converter
120 snodes = cm.find(
's', ident=sliceid)
122 print (
"Unexpected number of slices with ID: %d, found %d" % (sliceid, len(snodes)))
125 by_face = defaultdict(list)
126 sdata = cm.gr.nodes[snode]
127 for cdat,cval
in sdata[
"activity"].items():
129 cnode = cm.channel(chid)
130 cdata = cm.gr.nodes[cnode]
131 wnodes = cm.neighbors_oftype(cnode,
'w')
133 print(
"No wires for channel %d" % chid)
135 wdat = cm.gr.nodes[wnode]
138 by_face[f].append((cval, wdat))
140 blob_xs_byface = defaultdict(list)
141 blob_ys_byface = defaultdict(list)
142 blob_cs_byface = defaultdict(list)
143 for bnode
in cm.neighbors_oftype(snode,
'b'):
144 bdata = cm.gr.nodes[bnode]
147 cpoints = converter.orderpoints(bdata[
'corners'])
148 for cp
in cpoints + [cpoints[0]]:
149 cx.append(cp[2]/units.m)
150 cy.append(cp[1]/units.m)
151 faceid = bdata[
'faceid']
152 blob_xs_byface[faceid].append(cx)
153 blob_ys_byface[faceid].append(cy)
154 blob_cs_byface[faceid].append(bdata[
'value'])
157 cmap = plt.get_cmap(
'gist_rainbow')
159 fig,axes = plt.subplots(nrows=1, ncols=len(by_face))
163 for ind, (faceid, wdats)
in enumerate(sorted(by_face.items())):
165 ax.set_title(
"face %d" % faceid)
166 ax.set_xlabel(
"Z [m]")
167 ax.set_ylabel(
"Y [m]")
172 for cval, wdat
in wdats:
176 c = [0.5*(h[i]+t[i])
for i
in range(3)]
183 toffset = (chid%5) * 0.2
187 ax.text(t[2]/units.m, t[1]/units.m + toffset,
"C%d" %chid, fontsize=0.2, rotation=90, va=
'top')
189 ax.text(c[2]/units.m, c[1]/units.m-toffset,
"P%d WID%d WIP%d" %(p,wid,wip), fontsize=0.2, rotation=90, va=
'top')
190 ax.plot([c[2]/units.m,c[2]/units.m], [c[1]/units.m, c[1]/units.m-toffset],
191 color=
'black', linewidth = 0.1, alpha=0.5)
195 ax.text(h[2]/units.m, h[1]/units.m - toffset,
"C%d" %chid, fontsize=0.2, rotation=90, va=
'bottom')
196 ax.plot([h[2]/units.m,h[2]/units.m], [h[1]/units.m - toffset, h[1]/units.m],
197 color=
'black', linewidth = 0.1, alpha=0.5)
199 ax.text(c[2]/units.m+toffset, c[1]/units.m,
"P%d WID%d WIP%d" %(p,wid,wip), fontsize=0.2, rotation=0, va=
'top')
200 ax.plot([c[2]/units.m+toffset,c[2]/units.m], [c[1]/units.m, c[1]/units.m],
201 color=
'black', linewidth = 0.1, alpha=0.5)
203 xs.append([t[2]/units.m, h[2]/units.m])
204 ys.append([t[1]/units.m, h[1]/units.m])
207 segments = [numpy.column_stack([x,y])
for x,y
in zip(xs, ys)]
208 lc = LineCollection(segments, cmap=cmap, linewidth=linewidth, alpha=0.5, norm=LogNorm())
209 lc.set_array(numpy.asarray(cs))
210 ax.add_collection(lc)
212 fig.colorbar(lc, ax=ax)
214 segments = [numpy.column_stack([x,y])
for x,y
in zip(blob_xs_byface[faceid], blob_ys_byface[faceid])]
215 lc = LineCollection(segments, linewidth=2*linewidth, alpha=0.5)
216 lc.set_array(numpy.asarray(blob_cs_byface[faceid]))
217 ax.add_collection(lc)
225 auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def wire_blob_slice(cm, sliceid)
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.