def plot_all_ranges(ax1,ct): for i in range(len(ct['ct']['data'])): x,y,fo=ct['ct']['x'],ct['ct']['data'][i],ct['ct']['falloff'][i] ax1.step(x, y, label=ct['name']+'ct', color='steelblue', lw=1, where='mid',clip_on=False, alpha=0.5) ax1.axvline(fo, color='steelblue', ls='-',lw=1, alpha=0.5) ax1.set_xlabel('Depth [mm]', fontsize=FONTSIZE) ax1.set_ylabel('PG detected [counts]', fontsize=FONTSIZE) ax1.set_title(plot.sn(ct['nprim'],0)+' primaries', fontsize=Fontsize) plot.texax(ax1) for i in range(len(ct['rpct']['data'])): x,y,fo=ct['rpct']['x'],ct['rpct']['data'][i],ct['rpct']['falloff'][i] ax1.step(x, y, label=ct['name']+'ct', color='indianred', lw=1, where='mid',clip_on=False, alpha=0.5) ax1.axvline(fo, color='indianred', ls='-',lw=1, alpha=0.5) if str(ct['nprim'])[1] == '0': ax1.set_title('PG detection for '+plot.sn_mag(ct['nprim'])+' primaries', fontsize=Fontsize) else: ax1.set_title('PG detection for '+plot.sn(ct['nprim'])+' primaries', fontsize=Fontsize) ax1.set_ylim(bottom=0) ct_labelextra = '' rpct_labelextra = '' if True: ct_labelextra += 'CT DE: '+plot.sn(ct['ct']['detyieldmu']) #yield per prot rpct_labelextra += 'RPCT DE: '+plot.sn(ct['rpct']['detyieldmu']) ax1.text(0.05, 0.95, ct_labelextra , ha='left', va='center', fontsize=Fontsize, transform=ax1.transAxes) ax1.text(0.05, 0.8, rpct_labelextra , ha='left', va='center', fontsize=Fontsize, transform=ax1.transAxes) plot.texax(ax1)
def get_effhist(ax1,image,name=None): colors = plot.colors get_effhist.color_index+=1 data = image.imdata[~np.isnan(image.imdata)].flatten() if np.nanmin(data) == 0: binn = np.logspace(1,np.log10(np.nanmax(data))) label = plot.sn_mag(image.nprim)+" primaries\nMin: "+str(0)+"\nMax: "+plot.sn(np.nanmax(data)) else: binn = np.logspace(np.log10(np.nanmin(data)),np.log10(np.nanmax(data))) label = plot.sn_mag(image.nprim)+" primaries\nMin: "+plot.sn(np.nanmin(data))+"\nMax: "+plot.sn(np.nanmax(data)) hist,bins = np.histogram(data, bins=binn) center = (bins[:-1] + bins[1:]) / 2 bins=center # hist[0] = 0 # hist[-1] = 0 if name is None: ax1.plot(bins,hist/float(hist.max()),label=label,color=colors[get_effhist.color_index],drawstyle='steps') else: ax1.plot(bins,hist/float(hist.max()),label=name+'\nMedian gain: '+plot.sn(np.median(data)),color=colors[get_effhist.color_index],drawstyle='steps') ax1.semilogx() plot.texax(ax1) # print 'Median of efficiency:',np.median(data) # print 'Mean of efficiency:',np.mean(data) return [np.nanmin(data),np.median(data),np.nanmax(data),np.mean(data)]
def get_effhist(ax1, image, name=None): colors = plot.colors get_effhist.color_index += 1 data = image.imdata[~np.isnan(image.imdata)].flatten() if np.nanmin(data) == 0: binn = np.logspace(1, np.log10(np.nanmax(data))) label = plot.sn_mag( image.nprim) + " primaries\nMin: " + str(0) + "\nMax: " + plot.sn( np.nanmax(data)) else: binn = np.logspace(np.log10(np.nanmin(data)), np.log10(np.nanmax(data))) label = plot.sn_mag(image.nprim) + " primaries\nMin: " + plot.sn( np.nanmin(data)) + "\nMax: " + plot.sn(np.nanmax(data)) hist, bins = np.histogram(data, bins=binn) center = (bins[:-1] + bins[1:]) / 2 bins = center # hist[0] = 0 # hist[-1] = 0 if name is None: ax1.plot(bins, hist / float(hist.max()), label=label, color=colors[get_effhist.color_index], drawstyle='steps') else: ax1.plot(bins, hist / float(hist.max()), label=name + '\nMedian gain: ' + plot.sn(np.median(data)), color=colors[get_effhist.color_index], drawstyle='steps') ax1.semilogx() plot.texax(ax1) # print 'Median of efficiency:',np.median(data) # print 'Mean of efficiency:',np.mean(data) return [np.nanmin(data), np.median(data), np.nanmax(data), np.mean(data)]
def get_effhist_oud(ax1, image, name=None): colors = plot.colors get_effhist.color_index += 1 data = image.imdata[~np.isnan(image.imdata)].flatten() # data=data/np.nanmax(data) # with np.errstate(divide='ignore', invalid='ignore'): # data = np.true_divide(data,np.nanmax(data)) #data = np.nonzero(data)] #print image.nprim,np.nanmin(data),np.nanmax(data) if np.nanmin(data) == 0: label = plot.sn_mag( image.nprim) + " primaries\nMin: " + str(0) + "\nMax: " + plot.sn( np.nanmax(data)) y, x, _ = ax1.hist(data, bins=np.logspace(1, np.log10(np.nanmax(data))), label=label, color=colors[get_effhist.color_index], histtype='step', lw=1) else: label = plot.sn_mag(image.nprim) + " primaries\nMin: " + plot.sn( np.nanmin(data)) + "\nMax: " + plot.sn(np.nanmax(data)) y, x, _ = ax1.hist(data, bins=np.logspace(np.log10(np.nanmin(data)), np.log10(np.nanmax(data))), label=label, color=colors[get_effhist.color_index], histtype='step', lw=1) print y.max() # label=str(image.nprim)+" primaries\nMin: "+str(np.nanmin(data))+"\nMax: "+str(np.nanmax(data)) # ax1.hist(data, bins = np.linspace(np.nanmin(data),np.nanmax(data)) ,label=label,color=colors[get_effhist.color_index],histtype='step', lw=1) ax1.semilogx() plot.texax(ax1) # print 'Median of efficiency:',np.median(data) # print 'Mean of efficiency:',np.mean(data) return [np.nanmin(data), np.median(data), np.nanmax(data), np.mean(data)]
def get_effhist_oud(ax1,image,name=None): colors = plot.colors get_effhist.color_index+=1 data = image.imdata[~np.isnan(image.imdata)].flatten() # data=data/np.nanmax(data) # with np.errstate(divide='ignore', invalid='ignore'): # data = np.true_divide(data,np.nanmax(data)) #data = np.nonzero(data)] #print image.nprim,np.nanmin(data),np.nanmax(data) if np.nanmin(data) == 0: label=plot.sn_mag(image.nprim)+" primaries\nMin: "+str(0)+"\nMax: "+plot.sn(np.nanmax(data)) y, x, _=ax1.hist(data, bins = np.logspace(1,np.log10(np.nanmax(data))) ,label=label,color=colors[get_effhist.color_index],histtype='step', lw=1) else: label=plot.sn_mag(image.nprim)+" primaries\nMin: "+plot.sn(np.nanmin(data))+"\nMax: "+plot.sn(np.nanmax(data)) y, x, _=ax1.hist(data, bins = np.logspace(np.log10(np.nanmin(data)),np.log10(np.nanmax(data))) ,label=label,color=colors[get_effhist.color_index],histtype='step', lw=1) print y.max() # label=str(image.nprim)+" primaries\nMin: "+str(np.nanmin(data))+"\nMax: "+str(np.nanmax(data)) # ax1.hist(data, bins = np.linspace(np.nanmin(data),np.nanmax(data)) ,label=label,color=colors[get_effhist.color_index],histtype='step', lw=1) ax1.semilogx() plot.texax(ax1) # print 'Median of efficiency:',np.median(data) # print 'Mean of efficiency:',np.mean(data) return [np.nanmin(data),np.median(data),np.nanmax(data),np.mean(data)]
def plot_single_range(ax1,ct): for i in range(len(ct['ct']['data'])): x,y,fo=ct['ct']['x'],ct['ct']['data'][i],ct['ct']['falloff'][i] ax1.step(x, y, label=ct['name']+'ct', color='steelblue', lw=1, where='mid',clip_on=False, alpha=0.5) ax1.axvline(fo, color='steelblue', ls='-',lw=1, alpha=0.5) break ax1.set_xlabel('Depth [mm]', fontsize=FONTSIZE) ax1.set_ylabel('PG detected [counts]', fontsize=FONTSIZE) ax1.set_title(plot.sn(ct['nprim'],0)+' primaries', fontsize=FONTSIZE) plot.texax(ax1) for i in range(len(ct['rpct']['data'])): x,y,fo=ct['rpct']['x'],ct['rpct']['data'][i],ct['rpct']['falloff'][i] ax1.step(x, y, label=ct['name']+'ct', color='indianred', lw=1, where='mid',clip_on=False, alpha=0.5) ax1.axvline(fo, color='indianred', ls='-',lw=1, alpha=0.5) break ax1.set_title('PG detection for '+plot.sn_mag(ct['nprim'])+'primaries', fontsize=FONTSIZE) ax1.set_ylim(bottom=0) plot.texax(ax1)
# y_tle = [np.nansum(value['var'].imdata/np.sum(mask90pc.imdata)) for key, value in tlerelunc.iteritems()] y_tle = [ np.median(value['var'].imdata[~np.isnan(value['var'].imdata)]) for key, value in tlerelunc.iteritems() ] tle_2pc = tle.get_reluncconv(tl, x_tle / ppstle, y_tle) x_an = np.array(anrelunc.keys()) # y_an = [np.nansum(value['var'].imdata/np.sum(mask90pc.imdata)) for key, value in anrelunc.iteritems()] y_an = [ np.median(value['var'].imdata[~np.isnan(value['var'].imdata)]) for key, value in anrelunc.iteritems() ] an_2pc = tle.get_reluncconv(tl, x_an / ppsan, y_an) tl.set_title('Median relative uncertainty\nGain: ' + plot.sn(an_2pc / tle_2pc)) tl.set_ylabel('Relative Uncertainty [\%]') tl.set_xlabel('Runtime t [s]') tl.semilogx() tl.legend(bbox_to_anchor=(1.1, 1), frameon=False, prop={'size': 6}) #efficiencies + speedups a = tle.get_effhist(tr, tleeff[1e3]['var']) b = tle.get_effhist(tr, tleeff[1e4]['var']) c = tle.get_effhist(tr, tleeff[1e5]['var']) d = tle.get_effhist(tr, tleeff[1e6]['var']) lmin = min([a[0], b[0], c[0], d[0]]) lmed = np.average([a[1], b[1], c[1], d[1]]) lmax = max([a[2], b[2], c[2], d[2]]) lmean = np.average([a[3], b[3], c[3], d[3]]) print 'Glob mean/median:', lmean, lmed
########################################################################################################### #volume_offset=-141.59+7.96#spot sources volume_offset=150-141.59+7.96#spot sources ########################################################################################################### # BOTTOM ROW IBA f, ((ax4,ax5,ax6),(ax1,ax2,ax3)) = plot.subplots(nrows=2, ncols=3, sharex=True, sharey=False) typ = 'iba-auger-notof-3.root' yield_av = auger.plot_all_ranges_2(ax1,auger.getctset(840964615,'fromclus-sorted/layers-beide/run.e8ai','fromclus-sorted/layers-beide/run.96ra',typ,manualshift=volume_offset),firstcolor='steelblue',secondcolor=None) yield_av = auger.plot_all_ranges_2(ax1,auger.getctset(848710335,'fromclus-sorted/layers-beide/run.m4RU','fromclus-sorted/layers-beide/run.tLiY',typ,manualshift=volume_offset),firstcolor='seagreen',secondcolor=None) ax1.set_title('KES, Spot A,\nyield: '+plot.sn(yield_av), fontsize=8) ax1.set_ylabel('PG detected [counts]') yield_av = auger.plot_all_ranges_2(ax2,auger.getctset(1068263318,'fromclus-sorted/layers-beide/run.E2tF','fromclus-sorted/layers-beide/run.qE8o',typ,manualshift=volume_offset),firstcolor='steelblue',secondcolor=None) yield_av = auger.plot_all_ranges_2(ax2,auger.getctset(1071596684,'fromclus-sorted/layers-beide/run.r48i','fromclus-sorted/layers-beide/run.c0rg',typ,manualshift=volume_offset),firstcolor='seagreen',secondcolor=None) ax2.set_title('KES, Spot B,\nyield: '+plot.sn(yield_av), fontsize=8) ax2.set_xlabel('Position [mm]') yield_av = auger.plot_all_ranges_2(ax3,auger.getctset(1068263318,'fromclus-sorted/layers-beide/run.E2tF','fromclus-sorted/layers-beide/run.qE8o',typ,manualshift=volume_offset),firstcolor='steelblue',secondcolor=None) yield_av = auger.plot_all_ranges_2(ax3,auger.getctset(979533764,'fromclus-sorted/layers-beide/run.c4UF','fromclus-sorted/layers-beide/run.bj2R',typ,manualshift=volume_offset),firstcolor='seagreen',secondcolor=None) ax3.set_title('KES, Spot C,\nyield: '+plot.sn(yield_av), fontsize=8) ######## TopRow IPNL typ = 'ipnl-auger-tof-1.root'
f, (tr,tl) = plt.subplots(nrows=1, ncols=2, sharex=False, sharey=False) #swapped #Relative uncertainties 90pc region x_tle = np.array(tlerelunc.keys()) # y_tle = [np.nansum(value['var'].imdata/np.sum(mask90pc.imdata)) for key, value in tlerelunc.iteritems()] y_tle = [np.median(value['var'].imdata[~np.isnan(value['var'].imdata)]) for key, value in tlerelunc.iteritems()] tle_2pc = tle.get_reluncconv(tl,x_tle/ppstle,y_tle) x_an = np.array(anrelunc.keys()) # y_an = [np.nansum(value['var'].imdata/np.sum(mask90pc.imdata)) for key, value in anrelunc.iteritems()] y_an = [np.median(value['var'].imdata[~np.isnan(value['var'].imdata)]) for key, value in anrelunc.iteritems()] an_2pc = tle.get_reluncconv(tl,x_an/ppsan,y_an) tl.set_title('Median relative uncertainty\nGain: '+plot.sn(an_2pc/tle_2pc)) tl.set_ylabel('Relative Uncertainty [\%]') tl.set_xlabel('Runtime t [s]') tl.semilogx() tl.legend(bbox_to_anchor=(1.1, 1),frameon=False,prop={'size':6}) #efficiencies + speedups a=tle.get_effhist(tr,tleeff[1e3]['var']) b=tle.get_effhist(tr,tleeff[1e4]['var']) c=tle.get_effhist(tr,tleeff[1e5]['var']) d=tle.get_effhist(tr,tleeff[1e6]['var']) lmin = min([a[0],b[0],c[0],d[0]]) lmed = np.average([a[1],b[1],c[1],d[1]]) lmax = max([a[2],b[2],c[2],d[2]]) lmean = np.average([a[3],b[3],c[3],d[3]]) print 'Glob mean/median:',lmean,lmed
sharex=False, sharey=False) #,figsize=(28,10)) for axrow, yim, uim, label in zip(axes, imyields, imuncs, labels): print yim, uim, label yim_ = image.image(yim, type='yield') uim_ = image.image( uim, type='relunc' ) #the doseactor outputs relative uncertainties as per Chetty, see GateImageWithStatistic #uim_.applymask(mask90pc) uim_.imdata = uim_.imdata.squeeze() * 100. #fractions to percentages fracties_isocentrum.append(yim_.getcenter().mean()) fracties_totaal.append(yim_.imdata.sum()) axrow[0].imshow(yim_.imdata.squeeze(), extent=[0, 41, 0, 41], cmap='gray') axrow[0].set_title(label + '\n$\sum$ Dose: ' + plot.sn(fracties_totaal[-1])) axrow[1].set_title(label + ' Profile') axrow[1].plot(*yim_.getprofile('y'), color='steelblue', label='x') axrow[1].plot(*yim_.getprofile('x'), color='indianred', label='y') axrow[1].legend(loc='upper right', bbox_to_anchor=(1., 1.), frameon=False) axrow[1].axvline(41. / 2. - 8., color='#999999', ls='--') #10x10 at isoc is 16x16 at epid level axrow[1].axvline(41. / 2. + 8., color='#999999', ls='--') axrow[1].set_xlim(0, 41) plot.set_metric_prefix_y(axrow[1]) axrow[2].set_title(label + ' relunc') plot.plot1dhist(axrow[2], uim_.imdata.flatten(), bins=np.linspace(0, 100, 50),
for spot in rtplan.spots: MSW.append(spot[-1]) #spot_weight_mean = np.median(MSW) spot_weight_mean = np.mean(MSW) nrfields=len(rtplan.fields) fontsize=6 mpl.rcParams['xtick.labelsize'] = fontsize mpl.rcParams['ytick.labelsize'] = fontsize mpl.rcParams['axes.titlesize'] = fontsize mpl.rcParams['axes.labelsize'] = fontsize plotke = plot.subplots(nrows=2, ncols=nrfields, sharex='col', sharey='row') plotke[0].get_axes()[0].annotate('Total nr. of primaries: '+plot.sn(rtplan.TotalMetersetWeight)+'. Mean spot weight: '+plot.sn(spot_weight_mean), (0.5, 0.975), xycoords='figure fraction', ha='center', fontsize=fontsize) if nrfields == 1: spotaxes = [plotke[-1][0]] #0 is eerste kolom layaxes = [plotke[-1][1]] #0 is eerste kolom spotloop= [spotdata[0]] layloop = [layerdata[0]] else: spotaxes = plotke[-1][0] #0 is eerste kolom layaxes = plotke[-1][1] #0 is eerste kolom spotloop = spotdata layloop = layerdata first = True layer_min_y = 1e10 layer_max_y = 1e1
#volume_offset=-141.59+7.96#spot sources volume_offset=0 addnoise = False #addnoise = 'onlynoise' ########################################################################################################### # BOTTOM ROW IBA f, ((ax4,ax5,ax6),(ax1,ax2,ax3)) = plot.subplots(nrows=2, ncols=3, sharex=True, sharey=False) typ = 'iba-auger-tof-1.root' typ = 'iba-auger-notof-3.root' yield_av = auger.plot_all_ranges_2(ax1, auger.getctset(1e9,'run.o5zC','run.o5zC',typ,manualshift=volume_offset,addnoise=addnoise) ) ax1.set_title('KES, 1e9,\nyield: '+plot.sn(yield_av), fontsize=8) ax1.set_ylabel('PG detected [counts]') yield_av = auger.plot_all_ranges_2(ax2, auger.getctset(1e8,'run.fFpk','run.fFpk',typ,manualshift=volume_offset,addnoise=addnoise) ) ax2.set_title('KES, 1e8,\nyield: '+plot.sn(yield_av), fontsize=8) ax2.set_xlabel('Position [mm]') yield_av = auger.plot_all_ranges_2(ax3, auger.getctset(1e7,'run.Gfu4','run.Gfu4',typ,manualshift=volume_offset,addnoise=addnoise) ) ax3.set_title('KES, 1e7\nyield: '+plot.sn(yield_av), fontsize=8) ######## TopRow IPNL typ = 'ipnl-auger-tof-1.root' typ = 'ipnl-auger-notof-3.root' #shift = 13.76-19.44
f, (tr,tl) = plt.subplots(nrows=1, ncols=2, sharex=False, sharey=False) #swapped left and right!!!!!! #Relative uncertainties 90pc region x_tle = np.array(tlerelunc.keys()) # y_tle = [np.nansum(value['var'].imdata/np.sum(mask90pc.imdata)) for key, value in tlerelunc.iteritems()] y_tle = [np.median(value['var'].imdata[~np.isnan(value['var'].imdata)]) for key, value in tlerelunc.iteritems()] tle_2pc = tle.get_reluncconv(tl,x_tle/ppstle,y_tle) x_an = np.array(anrelunc.keys()) # y_an = [np.nansum(value['var'].imdata/np.sum(mask90pc.imdata)) for key, value in anrelunc.iteritems()] y_an = [np.median(value['var'].imdata[~np.isnan(value['var'].imdata)]) for key, value in anrelunc.iteritems()] an_2pc = tle.get_reluncconv(tl,x_an/ppsan,y_an) tl.set_title('Median relative uncertainty\nGain: '+plot.sn(an_2pc/tle_2pc)) tl.set_ylabel('Relative Uncertainty [\%]') tl.set_xlabel('Runtime t [s]') tl.semilogx() tl.legend(bbox_to_anchor=(1.1, 1),frameon=False,prop={'size':6}) #efficiencies + speedups a=tle.get_effhist(tr,tleeff[1e3]['var']) b=tle.get_effhist(tr,tleeff[1e4]['var']) c=tle.get_effhist(tr,tleeff[1e5]['var']) d=tle.get_effhist(tr,tleeff[1e6]['var']) lmin = min([a[0],b[0],c[0],d[0]]) lmed = np.average([a[1],b[1],c[1],d[1]]) lmax = max([a[2],b[2],c[2],d[2]]) lmean = np.average([a[3],b[3],c[3],d[3]]) print 'Glob mean/median:',lmean,lmed
else: shifts.append(shift) pgshifts.append(pgshift) diffshifts.append(diffshift) if args.plotspot is not None and spindex == int(args.plotspot): if args.ctonly: f, ax1 = plot.subplots(nrows=1, ncols=1, sharex=False, sharey=False) ax1.step(x,ct/ct.max(), color='steelblue',lw=1., label='Dose,\nFOP: '+str(auger.get_fop(x,ct))[:4]+' mm') ax1.step(x,pg/pg.max(), color='indianred',lw=1., label='PG production,\nFOP: '+str(auger.get_fop(x,pg))[:4]+' mm') ax1.set_xlabel('Position w.r.t. isocenter [mm]') ax1.set_ylabel('Dose/PG production, rescaled [a.u.]') ax1.legend(frameon = False) ax1.set_xlim(-75,75) f.suptitle('Spotid '+str(spindex)+', '+plot.sn(MSW[spindex][-1])+' protons', fontsize=8) plot.texax(ax1) f.savefig('CT-dose-pg-'+str(args.plotspot)+'.pdf', bbox_inches='tight') plot.close('all') quit() else: f, (ax1,ax2) = plot.subplots(nrows=1, ncols=2, sharex=False, sharey=False) ax1.step(x,ct, color='steelblue',lw=1., label='FOP: '+str(auger.get_fop(x,ct))[:5]) ax1.step(x,rpct, color='indianred',lw=1., label='FOP: '+str(auger.get_fop(x,rpct))[:5]) ax1.set_xlabel('FOP [mm]') ax1.set_ylabel('Integrated Dose [a.u.]') ax1.set_title('Integrated Dose Profile (along x)'+', shift '+str(shift)[:4], fontsize=8) ax1.legend(prop={'size':6},loc='best',frameon = False) #from scipy.ndimage.filters import gaussian_filter
ncols=3, sharex=True, sharey=False) typ = 'iba-auger-tof-1.root' typ = 'iba-auger-notof-3.root' yield_av = auger.plot_all_ranges_2( ax1, auger.getctset(1e9, 'run.o5zC', 'run.o5zC', typ, manualshift=volume_offset, addnoise=addnoise)) ax1.set_title('KES, 1e9,\nyield: ' + plot.sn(yield_av), fontsize=8) ax1.set_ylabel('PG detected [counts]') yield_av = auger.plot_all_ranges_2( ax2, auger.getctset(1e8, 'run.fFpk', 'run.fFpk', typ, manualshift=volume_offset, addnoise=addnoise)) ax2.set_title('KES, 1e8,\nyield: ' + plot.sn(yield_av), fontsize=8) ax2.set_xlabel('Position [mm]') yield_av = auger.plot_all_ranges_2( ax3,
color='steelblue', lw=1., label='Dose,\nFOP: ' + str(auger.get_fop(x, ct))[:4] + ' mm') ax1.step(x, pg / pg.max(), color='indianred', lw=1., label='PG production,\nFOP: ' + str(auger.get_fop(x, pg))[:4] + ' mm') ax1.set_xlabel('Position w.r.t. isocenter [mm]') ax1.set_ylabel('Dose/PG production, rescaled [a.u.]') ax1.legend(frameon=False) ax1.set_xlim(-75, 75) f.suptitle('Spotid ' + str(spindex) + ', ' + plot.sn(MSW[spindex][-1]) + ' protons', fontsize=8) plot.texax(ax1) f.savefig('CT-dose-pg-' + str(args.plotspot) + '.pdf', bbox_inches='tight') plot.close('all') quit() else: f, (ax1, ax2) = plot.subplots(nrows=1, ncols=2, sharex=False, sharey=False) ax1.step(x, ct, color='steelblue', lw=1.,
x_tle = np.array(tle_d.keys()) y_tle = [ sqrt(value['var'][0]) / value['yield'][0] for key, value in tle_d.iteritems() ] tle_2pc = tle.get_reluncconv(tl, x_tle / ppstle, y_tle) x_an = np.array(an_d.keys()) y_an = [ sqrt(value['var'][0]) / value['yield'][0] for key, value in an_d.iteritems() ] an_2pc = tle.get_reluncconv(tl, x_an / ppsan, y_an) tl.set_title('Median relative uncertainty\nGain: ' + plot.sn(an_2pc / tle_2pc)) tl.set_ylabel('Relative Uncertainty [\%]') tl.set_xlabel('Runtime [s]') tl.semilogx() tl.legend(bbox_to_anchor=(1.1, 1), frameon=False, prop={'size': 6}) #efficiencies + speedups a = tle.get_effhist(tr, tleeff[1e3]['var']) b = tle.get_effhist(tr, tleeff[1e4]['var']) c = tle.get_effhist(tr, tleeff[1e5]['var']) d = tle.get_effhist(tr, tleeff[1e6]['var']) lmin = min([a[0], b[0], c[0], d[0]]) lmed = np.average([a[1], b[1], c[1], d[1]]) lmax = max([a[2], b[2], c[2], d[2]]) lmean = np.average([a[3], b[3], c[3], d[3]]) print 'Glob mean/median:', lmean, lmed
tle.seteff(tlebox8) tle.seteff(anbox8) tle.seteffratio(tlebox2,anbox2[max(anbox2.keys())]['var']) tle.seteffratio(tlebox8,anbox8[max(anbox8.keys())]['var']) f, ((tl,tr)) = plt.subplots(nrows=1, ncols=2, sharex=True, sharey=False) a=tle.get_effhist(tl,tlebox2[1e3]['var']) b=tle.get_effhist(tl,tlebox2[1e4]['var']) c=tle.get_effhist(tl,tlebox2[1e5]['var']) d=tle.get_effhist(tl,tlebox2[1e6]['var']) # print [a[1],b[1],c[1],d[1]] lmed2 = np.average([a[1],b[1],c[1],d[1]]) tl.set_title("Medium 2 (Bone)") tl.text(0.05, 0.9,"Median gain: "+plot.sn(lmed2), ha='left', va='center', transform=tl.transAxes, fontsize=6) a=tle.get_effhist(tr,tlebox8[1e3]['var']) b=tle.get_effhist(tr,tlebox8[1e4]['var']) c=tle.get_effhist(tr,tlebox8[1e5]['var']) d=tle.get_effhist(tr,tlebox8[1e6]['var']) # print [a[1],b[1],c[1],d[1]] lmed8 = np.average([a[1],b[1],c[1],d[1]]) tr.set_title("Medium 8 (Muscle)") tr.text(0.05, 0.9,"Median gain: "+plot.sn(lmed8), ha='left', va='center', transform=tr.transAxes, fontsize=6) f.savefig('boxes-eff.pdf', bbox_inches='tight') plt.close('all') ### Reldiff of two boxes. tle_2 = tle4dbox2 #no deepcopy of 4D images
#e_spot_list.append(spindex) #ct61_geo = map(add, ct61_geo, dosespot) ct61_elay = [0] * len(ct[0]) e_spot_list = [] for spindex, (dosespot, spotid) in enumerate(zip(ct, MSW)): if spotid[1] == E61: #in the right elayer e_spot_list.append(spindex) ct61_elay = map(add, ct61_elay, dosespot) f, ax1 = plot.subplots(nrows=1, ncols=1, sharex=False, sharey=False) ax1.step(ct_x, ct61_geo / max(ct61_geo), color='indianred', lw=1., label='Geometric layer ' + plot.sn(new_spot_prot_sum) + ' protons', where='mid') ax1.step(ct_x, ct61_elay / max(ct61_elay), color='steelblue', lw=1., label='Energy Layer' + plot.sn(lay61_prots) + ' protons', where='mid') ax1.set_xlabel('Position [mm]') ax1.set_ylabel('Number of spots') #ax1.set_xlim(-60,16) #ax1.set_ylim(0,110) plot.texax(ax1) ax1.legend( frameon=False, loc='upper right'
ax4.step(x, dose[29] / dose[29].max(), color='steelblue', lw=1., alpha=1, label='CT', where='mid') ax4.step(x, rpdose[29] / rpdose[29].max(), color='indianred', lw=1., alpha=1, label='RPCT', where='mid') ax4.set_title('Spot A, Shift: ' + str(rpct29_fo - ct29_fo)[:3] + ' mm\n' + plot.sn(MSW[29][-1], 1) + ' protons', fontsize=10) ax4.legend(frameon=False, loc='upper left') ax4.set_xlim(-80, 60) ax4.set_ylabel('Scaled Dose [a.u.]') plot.texax(ax4) ax5.step(x, dose[40] / dose[40].max(), color='steelblue', lw=1., alpha=1, label='CT', where='mid') ax5.step(x, rpdose[40] / rpdose[40].max(),
fracties_totaal = [] fracties_isocentrum = [] f, axes = plot.subplots(nrows=len(imyields)+1, ncols=4, sharex=False, sharey=False)#,figsize=(28,10)) for axrow,yim,uim,label in zip(axes,imyields,imuncs,labels): print yim,uim,label yim_ = image.image(yim,type='yield') uim_ = image.image(uim,type='relunc') #the doseactor outputs relative uncertainties as per Chetty, see GateImageWithStatistic #uim_.applymask(mask90pc) uim_.imdata = uim_.imdata.squeeze()*100. #fractions to percentages fracties_isocentrum.append( yim_.getcenter().mean() ) fracties_totaal.append( yim_.imdata.sum() ) axrow[0].imshow( yim_.imdata.squeeze() , extent = [0,41,0,41], cmap='gray') axrow[0].set_title(label + '\n$\sum$ Dose: '+ plot.sn(fracties_totaal[-1])) axrow[1].set_title(label + ' Profile') axrow[1].plot(*yim_.getprofile('y'), color = 'steelblue' , label='x') axrow[1].plot(*yim_.getprofile('x'), color = 'indianred' , label='y') axrow[1].legend(loc='upper right', bbox_to_anchor=(1., 1.),frameon=False) axrow[1].axvline(41./2.-8., color='#999999', ls='--') #10x10 at isoc is 16x16 at epid level axrow[1].axvline(41./2.+8., color='#999999', ls='--') axrow[1].set_xlim(0,41) plot.set_metric_prefix_y(axrow[1]) axrow[2].set_title(label+' relunc') plot.plot1dhist( axrow[2], uim_.imdata.flatten(), bins=np.linspace(0,100,50), log=True) frac_trans=1. frac_nontrans=1.
'fromclus-sorted/layers-beide/run.e8ai', 'fromclus-sorted/layers-beide/run.96ra', typ, manualshift=volume_offset), firstcolor='steelblue', secondcolor=None) yield_av = auger.plot_all_ranges_2(ax1, auger.getctset( 848710335, 'fromclus-sorted/layers-beide/run.m4RU', 'fromclus-sorted/layers-beide/run.tLiY', typ, manualshift=volume_offset), firstcolor='seagreen', secondcolor=None) ax1.set_title('KES, Spot A,\nyield: ' + plot.sn(yield_av), fontsize=8) ax1.set_ylabel('PG detected [counts]') yield_av = auger.plot_all_ranges_2(ax2, auger.getctset( 1068263318, 'fromclus-sorted/layers-beide/run.E2tF', 'fromclus-sorted/layers-beide/run.qE8o', typ, manualshift=volume_offset), firstcolor='steelblue', secondcolor=None) yield_av = auger.plot_all_ranges_2(ax2, auger.getctset( 1071596684, 'fromclus-sorted/layers-beide/run.r48i',
ct61_geo = map(add, ct61_geo, ct[spindex]) #for spindex,(dosespot,spotid) in enumerate(zip(ct,MSW)): #if spotid[1]==E61: #in the right elayer #e_spot_list.append(spindex) #ct61_geo = map(add, ct61_geo, dosespot) ct61_elay = [0]*len(ct[0]) e_spot_list = [] for spindex,(dosespot,spotid) in enumerate(zip(ct,MSW)): if spotid[1]==E61: #in the right elayer e_spot_list.append(spindex) ct61_elay = map(add, ct61_elay, dosespot) f, ax1 = plot.subplots(nrows=1, ncols=1, sharex=False, sharey=False) ax1.step(ct_x,ct61_geo/max(ct61_geo), color='indianred',lw=1., label='Geometric layer '+plot.sn(new_spot_prot_sum)+' protons', where='mid') ax1.step(ct_x,ct61_elay/max(ct61_elay), color='steelblue',lw=1., label='Energy Layer'+plot.sn(lay61_prots)+' protons', where='mid') ax1.set_xlabel('Position [mm]') ax1.set_ylabel('Number of spots') #ax1.set_xlim(-60,16) #ax1.set_ylim(0,110) plot.texax(ax1) ax1.legend(frameon = False,loc = 'upper right')#,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'upper right') f.savefig('rtplan.geogroup.pdf', bbox_inches='tight') plot.close('all') print 'geoplan protcount',new_spot_prot_sum print 'eplan protcount',lay61_prots rtplan.rtplan([rtpfile],noproc=True,spotlist=e_spot_list,fieldind=field,relayername='elayspot'+str(SPOTID_GROUPAROUND))