nimgs = flow_v.size() print("number of flow crops: ", nimgs) print("number of adc crops: ", cropped_v.size()) c = rt.TCanvas("c", "LArFlow", 1500, 400) c.Divide(3, 1) for iset in xrange(nimgs): srcimg = cropped_v.at(iset * 3 + 2) if flowdir == 'y2u': tarimg = cropped_v.at(iset * 3 + 0) else: tarimg = cropped_v.at(iset * 3 + 1) hsrc = larcv.as_th2d(srcimg, "hsrc_set{}".format(iset)) htar = larcv.as_th2d(tarimg, "htar_set{}".format(iset)) hsrc.GetZaxis().SetRangeUser(0, 100) htar.GetZaxis().SetRangeUser(0, 100) hsrc.SetTitle("Source Plane Y: Set {};wire;tick".format(iset)) if flowdir == 'y2u': htar.SetTitle("Target Plane U: Set {};wire;tick".format(iset)) else: htar.SetTitle("Target Plane V: Set {};wire;tick".format(iset)) # prepare flow image flow = flow_v.at(iset) src_np = larcv.as_ndarray(srcimg) flow_np = larcv.as_ndarray(flow).astype(np.int) colidx = np.arange(src_np.shape[0], dtype=np.int) for row in xrange(src_np.shape[1]):
import ROOT as rt from larcv import larcv larcv.load_rootutil() rt.gStyle.SetOptStat(0) rfile = sys.argv[1] tree = sys.argv[2] entry = int(sys.argv[3]) index = int(sys.argv[4]) io = larcv.IOManager(larcv.IOManager.kREAD) io.add_in_file(rfile) io.initialize() io.read_entry(entry) evimg2d = io.get_data(larcv.kProductImage2D, tree) img = evimg2d.as_vector().at(index) c = rt.TCanvas("c", "c", 1000, 400) c.Draw() himg = larcv.as_th2d(img, "tree_%d_%d" % (entry, index)) himg.Draw("COLZ") c.Update() print "Printed" raw_input()
nplanes = wholeview_v.size() ncrops = 0 crop_v = [] crop_meta_v = [] crop_img2d_v = [] c = rt.TCanvas("c", "c", 800, 600) for plane in xrange(nplanes): if plane not in [2]: continue wholeimg = wholeview_v.at(plane) for roi in roi_v: bbox = roi.BB(plane) #std::cout << "crop from the whole image" << std::endl; crop = wholeimg.crop(bbox) h2d = larcv.as_th2d(crop, "roi%d" % (ncrops)) c.Draw() h2d.Draw("colz") c.Update() print "[enter to continue]" raw_input() crop_np = larcv.as_ndarray(crop) np.nan_to_num(crop_np, copy=False) crop_np[crop_np < 10.0] = 0.0 crop_np[crop_np > 100.0] = 100.0 print crop_np.shape, ":", crop.meta().dump() #crop_np = np.transpose( crop_np, (0,1,3,2)) if debug_w_png: scipy.misc.toimage(crop_np, cmin=0.0, cmax=100.0).\ save("adc_crop%d.png"%(ncrops))
for p in xrange(3): cropped_adc_v.push_back( adc_v.at( 3*i + p ) ) hvis = std.vector("TH2D")() #lfcrop_algo.check_cropped_images( 2, cropped_adc_v, ev_status, # thresholds_v, cropped_flow_v, cropped_visi_v, hvis, has_visi, vis_check ) flow_vv.append( cropped_flow_v ) if VIS_FLOWS: # first row and column: ADC images h_v = {} canvspot = [1,2,0] htitle = ["TARGET1","TARGET2","SOURCE"] for j in range(3): cflow.cd(canvspot[j]+1) h_v[j] = larcv.as_th2d( cropped_adc_v.at(j), "test%d_%d"%(i,j) ) h_v[j].GetZaxis().SetRangeUser(-10,250) h_v[j].SetTitle("%s"%(htitle[j])) h_v[j].Draw("COLZ") # first col as well for matrix cflow.cd(3+1) h_v[2].Draw("COLZ") cflow.cd(6+1) h_v[2].Draw("COLZ") # second row, the flows for j in xrange(0,2): cflow.cd(3+j+2) h_v[3+j] = larcv.as_th2d( cropped_flow_v.at(j), "flow%d_%d"%(i,j) ) h_v[3+j].GetZaxis().SetRangeUser(-832,832) h_v[3+j].Draw("COLZ")
IMAGE_HEIGHT, IMAGE_WIDTH, 2) srcmetas.append(meta) meta = larcv.ImageMeta(srcmeta[b, 0, 0, 0], srcmeta[b, 0, 0, 1], srcmeta[b, 0, 0, 2], srcmeta[b, 0, 0, 3], IMAGE_HEIGHT, IMAGE_WIDTH, 2) targetumetas.append(meta) meta = larcv.ImageMeta(srcmeta[b, 1, 0, 0], srcmeta[b, 1, 0, 1], srcmeta[b, 1, 0, 2], srcmeta[b, 1, 0, 3], IMAGE_HEIGHT, IMAGE_WIDTH, 2) targetvmetas.append(meta) # check image2d input img_adc = larcv.as_image2d_meta( source[0, 0, :, :].detach().cpu().numpy().transpose((1, 0)), srcmetas[0]) hadc = larcv.as_th2d(img_adc, "hadc_input") c.cd(1) hadc.SetTitle("source y") hadc.Draw("COLZ") c.Update() #c.SaveAs("hadc_input_%d.png"%(ientry)) #cv.imwrite( "cvadc_input_%d.png"%(ientry), source[0,0,:,:].detach().cpu().numpy() ) img_targetu = larcv.as_image2d_meta( target1[0, 0, :, :].detach().cpu().numpy().transpose((1, 0)), targetumetas[0]) htargetu = larcv.as_th2d(img_targetu, "htargetu_input") c.cd(2) htargetu.SetTitle("target u") htargetu.Draw("COLZ")
io = larcv.IOManager(larcv.IOManager.kREAD) io.add_in_file("out_dense_ublarflow_test.root") #io.add_in_file( "flowtest.root" ) io.initialize() io.read_entry(0) #cfg = larcv.CreatePSetFromFile( "ubsplit.cfg","UBSplitDetector") #splitalgo = ublarcvapp.UBSplitDetector() #splitalgo.configure(cfg) #splitalgo.initialize() ev_larflow_y2u = io.get_data(larcv.kProductImage2D, "larflow_y2u") y2u_v = ev_larflow_y2u.as_vector() ncrops = y2u_v.size() print "num crops: ", ncrops c = rt.TCanvas("c", "c", 800, 600) c.Draw() for iimg in xrange(ncrops): print "IMG: ", iimg img = y2u_v.at(iimg) c.Clear() hist = larcv.as_th2d(img, "y2u_%02d" % (iimg)) hist.Draw("COLZ") c.Update() raw_input()