def plot_select_channels(ctx, labels, json_file, pdf_file, channels): ''' Plot wires for select channels from a WCT JSON(.bz2) wire file ''' import wirecell.util.wires.persist as wpersist import wirecell.util.wires.plot as wplot wires = wpersist.load(json_file) wplot.select_channels(wires, pdf_file, channels, labels=labels)
def plot_wires(ctx, json_file, pdf_file): ''' Plot wires from a WCT JSON(.bz2) wire file ''' import wirecell.util.wires.persist as wpersist import wirecell.util.wires.plot as wplot wires = wpersist.load(json_file) wplot.allplanes(wires, pdf_file)
def wires_info(ctx, json_file): ''' Print information about a wires file (.json or .json.bz2) ''' import wirecell.util.wires.persist as wpersist import wirecell.util.wires.info as winfo wires = wpersist.load(json_file) dat = winfo.summary(wires) print('\n'.join(dat))
def wire_summary(output, wires): ''' Produce a summary of detector response and wires. ''' import wirecell.util.wires.persist as wpersist wstore = wpersist.load(wires) import wirecell.util.wires.info as winfo wdict = winfo.summary_dict(wstore) with open(output, "w") as fp: fp.write(json.dumps(wdict, indent=4))
def convert_uboon_wire_regions(ctx, wire_json_file, csvfile, region_json_file): ''' Convert CSV file to WCT format for wire regions. Example is one as saved from MicroBooNE_ShortedWireList.xlsx. Use ,-separated and remove quoting. ''' import wirecell.util.wires.persist as wpersist import wirecell.util.wires.regions as reg store = wpersist.load(wire_json_file) ubs = reg.uboone_shorted(store, csvfile) wpersist.dump(region_json_file, ubs)
def wires_volumes(ctx, anode, response, cathode, json_file): ''' Print a parms.det.volumes JSON fragment for the given wires file. You very likely want to carefully supply ALL command line options. ''' import wirecell.util.wires.persist as wpersist import wirecell.util.wires.info as winfo wires = wpersist.load(json_file) jv = winfo.jsonnet_volumes(wires, anode*units.cm, response*units.cm, cathode*units.cm) click.echo(str(jv))
def wire_channel_map(ctx, input_file): ''' Debug command, generate a WCT channel map wires file. ''' from collections import defaultdict import wirecell.util.wires.persist as wpersist s = wpersist.load(input_file) channel_map = defaultdict(list) for anode in s.anodes: for iface in anode.faces: face = s.faces[iface] for iplane in face.planes: plane = s.planes[iplane] for iwire in plane.wires: wire = s.wires[iwire] # fixme: why isn't wire.ident changing? channel_map[(plane.ident, wire.channel)].append(iwire) for c, wires in sorted(channel_map.items()): if c[1] in range(4210, 4235): wires.sort() click.echo("%s\t%s" % (c, wires))
def plot_wire_regions(ctx, wire_json_file, region_json_file, pdf_file): import wirecell.util.wires.persist as wpersist import wirecell.util.wires.plot as wplot from matplotlib.backends.backend_pdf import PdfPages import matplotlib.pyplot as plt from matplotlib.patches import Polygon from matplotlib.collections import PatchCollection store = wpersist.load(wire_json_file) regions = wpersist.load(region_json_file) def pt2xy(pt): 'Point id to xy tuple' ptobj = store.points[pt] return (ptobj.z, ptobj.y) def wo2pg(wo1, wo2): 'wire objects to polygon' return numpy.asarray([ pt2xy(wo1.tail), pt2xy(wo1.head), pt2xy(wo2.head), pt2xy(wo2.tail) ]) colors = ['red', 'green', 'blue'] def get_polygons(shorted, triples): ret = list() for trip in triples: for one in trip: pl, wip1, wip2 = one["plane"], one["wire1"], one["wire2"] if pl != shorted: continue # fixme: this line assumes only 1 face plobj = store.planes[pl] wobj1 = store.wires[plobj.wires[wip1]] wobj2 = store.wires[plobj.wires[wip2]] assert wobj1.channel == one['ch1'] assert wobj2.channel == one['ch2'] verts = wo2pg(wobj1, wobj2) #print (verts) pg = Polygon(verts, closed=True, facecolor=colors[pl], alpha=0.3, fill=True, linewidth=.1, edgecolor='black') ret.append(pg) return ret pgs = [get_polygons(int(s), t) for s, t in regions.items()] pgs2 = [get_polygons(int(s), t) for s, t in regions.items()] pgs.append(pgs2[0] + pgs2[1]) zlimits = [(0, 4100), (6900, 7500), (0, 7500)] with PdfPages(pdf_file) as pdf: for pgl, zlim in zip(pgs, zlimits): fig, ax = plt.subplots(nrows=1, ncols=1) for pg in pgl: ax.add_patch(pg) ax.set_xlim(*zlim) ax.set_ylim(-1500, 1500) ax.set_title('Dead wires') ax.set_xlabel('Z [mm]') ax.set_ylabel('Y [mm]') pdf.savefig(fig) plt.close() return