def new(self, event=None, with_dialog=True, title="Math Inspector"): if with_dialog: if not messagebox.askokcancel("MathInspector", "Are you sure you want to start a new file? Any unsaved data will be lost."): return plot.close() self.app.title(title) object_keys = list(self.app.objects.store.keys()) module_keys = list(self.app.modules.store.keys()) for i in object_keys: del self.app.objects[i] for j in module_keys: del self.app.modules[j] children = self.app.modules.get_children() for k in children: self.app.modules.delete(k) self.app.modules.rootfolder = None self.app.modules.stop_observer() self.app.console.clear() self.app.node.zoom = 1 self.app.console.prompt.history.clear() self.app.horizontal_panel.sashpos(0,0) self.app.vertical_panel.sashpos(0,0) self.app.console.do_greet()
a = plot.plot2dhist( ax3, phot_scatter['X'], phot_scatter['Y'], xbins=xbins,ybins=ybins, log=True) a = plot.plot2dhist( ax4, phot_other['X'], phot_other['Y'], xbins=xbins,ybins=ybins, log=True) a = plot.plot2dhist( ax5, nonphot['X'], nonphot['Y'], xbins=xbins,ybins=ybins, log=True) #,norm=matplotlib.colors.LogNorm(),vmin=1e0,vmax=1e2) plot.plot1dhist(ax6,all_E,count=True) plot.plot1dhist(ax7,phot_trans_E,count=True) plot.plot1dhist(ax8,phot_scatter_E,count=True) plot.plot1dhist(ax9,phot_other_E,count=True) ax9.set_xlim(0,2) plot.plot1dhist(ax10,nonphot_E,count=True) d = { 'e-':'Electron', 'e+':'Positron', 'gamma':'Photon' } plot.plotbar(ax14,partname,relabel=d,log=True) plot.plotbar(ax15,['Total Counts' for i in range(len(all['X']))]+['Prim Trans' for i in range(len(phot_trans['X']))]+['Prim Scat' for i in range(len(phot_scatter['X']))]+['Secon Phot' for i in range(len(phot_other['X']))],rotation=30) ax15.text(0.05, 0.95, 'Trans/Total: '+str( len(phot_trans['X'])/float(len(all['X'])) ) , ha='left', va='center', transform=ax15.transAxes) #cb = f.colorbar(a, ax=(ax1,ax2,ax3,ax4))#, aspect=50) #cb.outline.set_visible(False) #cb.set_label('Hits', rotation=270) f.savefig(rootfile+'.pdf', bbox_inches='tight') plot.close('all')
'fromclus-sorted/layers-beide/run.7coj', 'fromclus-sorted/layers-beide/run.ptEe', typ, manualshift=volume_offset), firstcolor='steelblue', secondcolor=None) yield_av = auger.plot_all_ranges_2(ax6, auger.getctset( 979533764, 'fromclus-sorted/layers-beide/run.8aMd', 'fromclus-sorted/layers-beide/run.wM5z', typ, manualshift=volume_offset), firstcolor='seagreen', secondcolor=None) ax6.set_title('MPS, Spot C,\nyield: ' + plot.sn(yield_av), fontsize=8) ax4.xaxis.set_visible(False) ax5.xaxis.set_visible(False) ax6.xaxis.set_visible(False) ax5.yaxis.set_visible(False) ax6.yaxis.set_visible(False) ax2.yaxis.set_visible(False) ax3.yaxis.set_visible(False) f.subplots_adjust(hspace=0.3) f.savefig('layerprofiles.results.pdf', bbox_inches='tight') plot.close('all')
def megaplot(ctsets, studyname, emisfops=None, labels=["$10^9$", "$10^8$", "$10^7$", "$10^6$"], axlabel='Primaries [nr]'): # if emisfops is not None: # for emisfop in emisfops: # emisfop[0]+=15.863 # emisfop[1]+=15.863 # print 'FOP shift all overlaid' if len(ctsets) == 4: f, ((ax1, ax2), (ax3, ax4)) = plot.subplots(nrows=2, ncols=2, sharex=False, sharey=False) auger.plot_all_ranges(ax1, ctsets[0]) auger.plot_all_ranges(ax2, ctsets[1]) auger.plot_all_ranges(ax3, ctsets[2]) auger.plot_all_ranges(ax4, ctsets[3]) if not 'Primaries' in axlabel: ax1.set_title(labels[0]) ax2.set_title(labels[1]) ax3.set_title(labels[2]) ax4.set_title(labels[3]) f.subplots_adjust(hspace=.5) ax1.set_xlabel('') ax2.set_xlabel('') ax2.set_ylabel('') ax4.set_ylabel('') f.savefig(studyname + '-' + typ + '-FOP.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# print 'FOP shift distributions' from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i, ctset in enumerate(ctsets): auger.plotfodiffdist(ax1, ctset, i, emisfops, labels, axlabel) if not emisfops == None: fopshifts = [] for fopset in emisfops: fopshifts.append(fopset[-1] - fopset[0]) ax1.set_xlim3d(np.mean(fopshifts) - 20, np.mean(fopshifts) + 20) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname + ', $Shift_{em}$ = ' + str(emisfops[0][-1] - emisfops[0][0]), y=1.08) #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T fig.savefig(studyname + '-' + typ + '-FOP-shift.pdf') #, bbox_inches='tight') plt.close('all') ############################################################################################# print 'FOP distributions' fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i, ctset in enumerate(ctsets): auger.plotfodist(ax1, ctset, i, emisfops, labels, axlabel) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname + ', $CT_{FOP_{em}}$ = ' + str(emisfops[0][0])[:5] + ', $RPCT_{FOP_{em}}$ = ' + str(emisfops[0][1])[:5], y=1.08) #plt.legend()#shadow = True,frameon = True,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'lower right') #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T plt.savefig(studyname + '-' + typ + '-FOP-dist.pdf') #, bbox_inches='tight') plt.close('all')
def megaplot(ctsets, studyname, emisfops=None, labels=["$10^9$", "$10^8$", "$10^7$", "$10^6$"], axlabel='Primaries [nr]'): # print 'FOP FOW Contrast DE averages over 10e9 ctset' # removed 2nd deriv from plot f, (ax1, ax2) = plot.subplots(nrows=2, ncols=1, sharex=False, sharey=False) x = ctsets[0]['ct']['x'] y = ctsets[0]['ct']['av'] if 'iba' in ctsets[0]['name']: # ctset['name'] == typ mm = 4 / 0.8 if 'ipnl' in ctsets[0]['name']: mm = 8 falloff_pos, g_fwhm, contrast = auger.get_fop_fow_contrast( x, y, plot='wut', ax=ax1, ax2=ax2, smooth=0.2, filename=ctsets[0]['ct']['path'], contrast_divisor=ctsets[0]['nprim'] * len(ctsets[0]['ct']['files']) * mm, fitlines=False) # some cosmetics maxyrounded = int(math.ceil(max(y) / 100.0)) * 100 ticks = np.arange(0, maxyrounded, 100) if len(ticks) > 10: ticks = np.arange(0, maxyrounded + 100, 200) if len(ticks) > 10: ticks = np.arange(0, maxyrounded + 200, 400) ax1.set_yticks(ticks) minor_locator = AutoMinorLocator(2) minor_locator1 = AutoMinorLocator(2) ax1.xaxis.set_minor_locator(minor_locator) ax2.xaxis.set_minor_locator(minor_locator) ax2.yaxis.set_minor_locator(minor_locator1) print "NPRIM", ctsets[0]['nprim'], "NJOBS", len( ctsets[0]['ct']['files']), "MM", mm #gebruiken deze falloff_pos niet. we doen contrast en fow over de average van 50 batches wegens smoothe curve. daardoor geen sigma f.savefig(studyname + '-' + typ + str(ctsets[0]['nprim']) + '-FOW.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# # results table for ctset in ctsets: res = [ typ, ctset['nprim'], ctset['ct']['fopmu'], ctset['ct']['fopsigma'], g_fwhm, contrast, ctset['detyieldmu'], ctset['detyieldsigma'], ctset['detcount'] ] if ctset['nprim'] == 10**9: if 'iba' in typ: #res.append(pgprod_1mev_iba*ctset['nprim']) res[-1] = res[-1] / (pgprod_1mev_iba * ctset['nprim']) if 'ipnl' in typ: #res.append(pgprod_1mev_ipnl*ctset['nprim']) res[-1] = res[-1] / (pgprod_1mev_ipnl * ctset['nprim']) else: res[-1] = '' if precolli: res.extend( [ctset['precollidetyieldmu'], ctset['precollidetyieldsigma']]) resultstable.append(res)
def megaplot(ctsets,studyname,emisfops=None,labels=["$10^9$","$10^8$","$10^7$","$10^6$"],axlabel='Primaries [nr]'): if len(ctsets) == 4: f, ((ax1,ax2),(ax3,ax4)) = plot.subplots(nrows=2, ncols=2, sharex=False, sharey=False) auger.plot_all_ranges_CTONLY(ax1,ctsets[0]) auger.plot_all_ranges_CTONLY(ax2,ctsets[1]) auger.plot_all_ranges_CTONLY(ax3,ctsets[2]) auger.plot_all_ranges_CTONLY(ax4,ctsets[3]) if not 'Primaries' in axlabel: ax1.set_title(labels[0]) ax2.set_title(labels[1]) ax3.set_title(labels[2]) ax4.set_title(labels[3]) f.subplots_adjust(hspace=.5) ax1.set_xlabel('') ax2.set_xlabel('') ax2.set_ylabel('') ax4.set_ylabel('') f.savefig(studyname+'-'+typ+'-FOP.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# # print 'FOP shift distributions' # from mpl_toolkits.mplot3d import Axes3D # import matplotlib.pyplot as plt # fig = plt.figure() # ax1 = plt.axes(projection='3d') # ax1.view_init(30, -50) # for i,ctset in enumerate(ctsets): # auger.plotfodiffdist(ax1,ctset,i,emisfops,labels,axlabel) # if not emisfops == None: # fopshifts=[] # for fopset in emisfops: # fopshifts.append( fopset[-1]-fopset[0] ) # ax1.set_xlim3d(np.mean(fopshifts)-20,np.mean(fopshifts)+20) # if emisfops is not None and len(emisfops) == 1: # ax1.set_title(studyname+', $Shift_{em}$ = '+str(emisfops[0][-1]-emisfops[0][0]), y=1.08) # #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T # fig.savefig(studyname+'-'+typ+'-FOP-shift.pdf')#, bbox_inches='tight') # plt.close('all') f, (ax1,ax2,ax3) = plot.subplots(nrows=3, ncols=1, sharex=False, sharey=False) x=ctsets[0]['rpct']['x'] y=ctsets[0]['ct']['av'] auger.get_fow(x,y,plot='wut',ax=ax1,ax2=ax2,ax3=ax3,smooth=0.2,filename=ctsets[0]['ct']['path']) #since high statistics, no smoothing needed # ax1.set_title('FOP = '+str(falloff_pos), fontsize=8) f.savefig(studyname+'-'+typ+'-FOW.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt print 'FOP distributions' fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i,ctset in enumerate(ctsets): auger.plotfodist_CTONLY(ax1,ctset,i,emisfops,labels,axlabel) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname+', $CT_{FOP_{em}}$ = '+str(emisfops[0][0])[:5]+', $RPCT_{FOP_{em}}$ = '+str(emisfops[0][1])[:5], y=1.08) #plt.legend()#shadow = True,frameon = True,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'lower right') #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T plt.savefig(studyname+'-'+typ+'-FOP-dist.pdf')#, bbox_inches='tight') plt.close('all')
def megaplot(ctsets,studyname,emisfops=None,labels=["$10^9$","$10^8$","$10^7$","$10^6$"],axlabel='Primaries [nr]'): if emisfops is not None: for emisfop in emisfops: emisfop[0]+=15.863 emisfop[1]+=15.863 print 'FOP shift all overlaid' if len(ctsets) == 4: f, ((ax1,ax2),(ax3,ax4)) = plot.subplots(nrows=2, ncols=2, sharex=False, sharey=False) auger.plot_all_ranges(ax1,ctsets[0]) auger.plot_all_ranges(ax2,ctsets[1]) auger.plot_all_ranges(ax3,ctsets[2]) auger.plot_all_ranges(ax4,ctsets[3]) if not 'Primaries' in axlabel: ax1.set_title(labels[0]) ax2.set_title(labels[1]) ax3.set_title(labels[2]) ax4.set_title(labels[3]) f.subplots_adjust(hspace=.5) ax1.set_xlabel('') ax2.set_xlabel('') ax2.set_ylabel('') ax4.set_ylabel('') f.savefig(studyname+'-'+typ+'-FOP.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# print 'FOP shift distributions' from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i,ctset in enumerate(ctsets): auger.plotfodiffdist(ax1,ctset,i,emisfops,labels,axlabel) if not emisfops == None: fopshifts=[] for fopset in emisfops: fopshifts.append( fopset[-1]-fopset[0] ) ax1.set_xlim3d(np.mean(fopshifts)-20,np.mean(fopshifts)+20) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname+', $Shift_{em}$ = '+str(emisfops[0][-1]-emisfops[0][0]), y=1.08) #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T fig.savefig(studyname+'-'+typ+'-FOP-shift.pdf')#, bbox_inches='tight') plt.close('all') ############################################################################################# print 'FOP distributions' fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i,ctset in enumerate(ctsets): auger.plotfodist(ax1,ctset,i,emisfops,labels,axlabel) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname+', $CT_{FOP_{em}}$ = '+str(emisfops[0][0])[:5]+', $RPCT_{FOP_{em}}$ = '+str(emisfops[0][1])[:5], y=1.08) #plt.legend()#shadow = True,frameon = True,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'lower right') #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T plt.savefig(studyname+'-'+typ+'-FOP-dist.pdf')#, bbox_inches='tight') plt.close('all')
def megaplot(ctsets, studyname, emisfops=None, labels=["$10^9$", "$10^8$", "$10^7$", "$10^6$"], axlabel='Primaries [nr]'): if len(ctsets) == 4: f, ((ax1, ax2), (ax3, ax4)) = plot.subplots(nrows=2, ncols=2, sharex=False, sharey=False) auger.plot_all_ranges_CTONLY(ax1, ctsets[0]) auger.plot_all_ranges_CTONLY(ax2, ctsets[1]) auger.plot_all_ranges_CTONLY(ax3, ctsets[2]) #auger.plot_all_ranges_CTONLY(ax4,ctsets[3]) if not 'Primaries' in axlabel: ax1.set_title(labels[0]) ax2.set_title(labels[1]) ax3.set_title(labels[2]) #ax4.set_title(labels[3]) f.subplots_adjust(hspace=.5) ax1.set_xlabel('') ax2.set_xlabel('') ax2.set_ylabel('') #ax4.set_ylabel('') f.savefig(studyname + '-' + typ + '-FOP.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# # print 'FOP shift distributions' # from mpl_toolkits.mplot3d import Axes3D # import matplotlib.pyplot as plt # fig = plt.figure() # ax1 = plt.axes(projection='3d') # ax1.view_init(30, -50) # for i,ctset in enumerate(ctsets): # auger.plotfodiffdist(ax1,ctset,i,emisfops,labels,axlabel) # if not emisfops == None: # fopshifts=[] # for fopset in emisfops: # fopshifts.append( fopset[-1]-fopset[0] ) # ax1.set_xlim3d(np.mean(fopshifts)-20,np.mean(fopshifts)+20) # if emisfops is not None and len(emisfops) == 1: # ax1.set_title(studyname+', $Shift_{em}$ = '+str(emisfops[0][-1]-emisfops[0][0]), y=1.08) # #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T # fig.savefig(studyname+'-'+typ+'-FOP-shift.pdf')#, bbox_inches='tight') # plt.close('all') ############################################################################################# # print 'FOP FOW Contrast DE averages over 10e9 ctset' # removed 2nd deriv from plot f, (ax1, ax2) = plot.subplots(nrows=2, ncols=1, sharex=False, sharey=False) x = ctsets[0]['ct']['x'] # 0 should be one with nprim=1e9 y = ctsets[0]['ct']['av'] if 'iba' in ctsets[0]['name']: # ctset['name'] == typ mm = 4 / 0.8 if 'ipnl' in ctsets[0]['name']: mm = 8 falloff_pos, g_fwhm, contrast = auger.get_fop_fow_contrast( x, y, plot='wut', ax=ax1, ax2=ax2, smooth=0.2, filename=ctsets[0]['ct']['path'], contrast_divisor=ctsets[0]['nprim'] * len(ctsets[0]['ct']['files']) * mm, fitlines=False) # some cosmetics maxyrounded = int(math.ceil(max(y) / 100.0)) * 100 ticks = np.arange(0, maxyrounded, 100) if len(ticks) > 10: ticks = np.arange(0, maxyrounded + 100, 200) if len(ticks) > 10: ticks = np.arange(0, maxyrounded + 200, 400) ax1.set_yticks(ticks) minor_locator = AutoMinorLocator(2) minor_locator1 = AutoMinorLocator(2) ax1.xaxis.set_minor_locator(minor_locator) ax2.xaxis.set_minor_locator(minor_locator) ax2.yaxis.set_minor_locator(minor_locator1) print "NPRIM", ctsets[0]['nprim'], "NJOBS", len( ctsets[0]['ct']['files']), "MM", mm #gebruiken deze falloff_pos niet. we doen contrast en fow over de average van 50 batches wegens smoothe curve. daardoor geen sigma f.savefig(studyname + '-' + typ + '-FOW.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# # results table print 'Computing pgprod ratios...' pgprod_1mev = dump.count_ekine_in_phasespace( "/home/brent/phd/art2_lyso_box/stage2_box15_docker/output/pgprod-worldframe.root", 1.) pgprod_3mev = dump.count_ekine_in_phasespace( "/home/brent/phd/art2_lyso_box/stage2_box15_docker/output/pgprod-worldframe.root", 3.) print 'done.' for ctset in ctsets: res = [ typ, ctset['nprim'], ctset['ct']['fopmu'], ctset['ct']['fopsigma'], g_fwhm, contrast, ctset['detyieldmu'], ctset['detyieldsigma'], ctset['detcount'] ] if ctset['nprim'] == 10**9: if pgexit and '3' in typ: res[-1] = res[-1] / pgprod_3mev elif pgexit and '1' in typ: res[-1] = res[-1] / pgprod_1mev else: res[-1] = '' if precolli: res.extend( [ctset['precollidetyieldmu'], ctset['precollidetyieldsigma']]) resultstable.append(res) ############################################################################################# from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt print 'FOP distributions' fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i, ctset in enumerate(ctsets): auger.plotfodist_CTONLY(ax1, ctset, i, emisfops, labels, axlabel) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname + ', $CT_{FOP_{em}}$ = ' + str(emisfops[0][0])[:5] + ', $RPCT_{FOP_{em}}$ = ' + str(emisfops[0][1])[:5], y=1.08) #plt.legend()#shadow = True,frameon = True,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'lower right') #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T plt.savefig(studyname + '-' + typ + '-FOP-dist.pdf') #, bbox_inches='tight') plt.close('all')
def megaplot(ctsets,studyname,emisfops=None,labels=["$10^9$","$10^8$","$10^7$","$10^6$"],axlabel='Primaries [nr]'): #if emisfops is not None: #for emisfop in emisfops: #emisfop[0]+=15.863 #emisfop[1]+=15.863 print 'FOP shift all overlaid' #if len(ctsets) == 3: #f, (ax1,ax2,ax3) = plot.subplots(nrows=1, ncols=3, sharex=False, sharey=False) #auger.plot_all_ranges(ax1,ctsets[0]) #auger.plot_all_ranges(ax2,ctsets[1]) #auger.plot_all_ranges(ax3,ctsets[2]) #f.savefig(studyname+'-'+typ+'-FOP.pdf', bbox_inches='tight') #plot.close('all') #f.subplots_adjust(hspace=.5) #ax2.set_ylabel('') #ax3.set_ylabel('') if len(ctsets) > 2: f, ((ax1,ax2),(ax3,ax4)) = plot.subplots(nrows=2, ncols=2, sharex=False, sharey=False) ax1.set_xlabel('') ax2.set_xlabel('') ax2.set_ylabel('') ax4.set_ylabel('') elif len(ctsets) == 2: f, (ax1,ax2) = plot.subplots(nrows=1, ncols=2, sharex=False, sharey=False) ax2.set_xlabel('') f.subplots_adjust(hspace=0.7,wspace=0.5) auger.plot_all_ranges(ax1,ctsets[0]) auger.plot_all_ranges(ax2,ctsets[1]) if len(ctsets) > 2: try: auger.plot_all_ranges(ax3,ctsets[2]) except: ax3.axis('off') try: auger.plot_all_ranges(ax4,ctsets[3]) except: ax4.axis('off') #auger.plot_single_range(ax1,ctsets[0]) #auger.plot_single_range(ax2,ctsets[1]) #auger.plot_single_range(ax3,ctsets[2]) #auger.plot_single_range(ax4,ctsets[3]) if not 'Primaries' in axlabel: ax1.set_title(labels[0]) ax2.set_title(labels[1]) #ax3.set_title(labels[2]) #ax4.set_title(labels[3]) #if 'waterbox' in studyname: #import matplotlib #matplotlib.pyplot.ticklabel_format(style='sci', axis='x', scilimits=(0,0)) #f.subplots_adjust(wspace=.3) #x0 = [] #y1 = [] #y1std = [] #y2 = [] #y2std = [] #for ct in ctsets: #x0.append(1./sqrt(ct['nprim'])) #y1.append(ct['ct']['fopsigma']) #y2.append(ct['rpct']['fopsigma']) #y1std.append( ct['ct']['fopsigma']/sqrt(2*(len(ct['ct']['falloff'])-1)) ) #y2std.append( ct['rpct']['fopsigma']/sqrt(2*(len(ct['rpct']['falloff'])-1)) ) #plot.plot_errorbands(ax4,x0,y1,y1std,color='steelblue') #plot.plot_errorbands(ax4,x0,y2,y2std,color='indianred') ##ax4.set_xlim(x[0],x[-1]) ##ax4.set_ylim(y[0],y[-1]) #ax4.set_title('CNR check', fontsize=8) #ax4.set_xlabel('1/sqrt(N$_{prim}$)', fontsize=8) ##ax4.set_ylabel('sqrt(background)/signal', fontsize=8) #ax4.set_ylabel('$\sigma_{FOP} [mm]$', fontsize=8) #plot.texax(ax4) f.savefig(studyname+'-'+typ+'-FOP.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# print 'FOP shift distributions' from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) tmpprim=0 center=0 for ctset in ctsets: if ctset['nprim'] > tmpprim: tmpprim = ctset['nprim'] center= ctset['fodiffmu'] for i,ctset in enumerate(ctsets): auger.plotfodiffdist(ax1,ctset,i,emisfops,labels,axlabel,center) if not emisfops == None: fopshifts=[] for fopset in emisfops: fopshifts.append( fopset[-1]-fopset[0] ) ax1.set_xlim3d(np.mean(fopshifts)-20,np.mean(fopshifts)+20) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname+', $Shift_{em}$ = '+str(emisfops[0][-1]-emisfops[0][0]), y=1.08) pass #fig.suptitle('FOP shifts', fontsize=10) #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T fig.savefig(studyname+'-'+typ+'-FOP-shift.pdf')#, bbox_inches='tight') plt.close('all') ############################################################################################# print 'FOP distributions' fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) tmpprim=0 center=0 for ctset in ctsets: if ctset['nprim'] > tmpprim: tmpprim = ctset['nprim'] center= ( ctset['ct']['fopmu'] + ctset['rpct']['fopmu'] ) /2. for i,ctset in enumerate(ctsets): auger.plotfodist(ax1,ctset,i,emisfops,labels,axlabel,center) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname+', $CT_{FOP_{em}}$ = '+str(emisfops[0][0])[:5]+', $RPCT_{FOP_{em}}$ = '+str(emisfops[0][1])[:5], y=1.08) #plt.legend()#shadow = True,frameon = True,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'lower right') #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T #fig.suptitle('FOP distributions', fontsize=10) plt.savefig(studyname+'-'+typ+'-FOP-dist.pdf')#, bbox_inches='tight') plt.close('all')
def save(self, file=AUTOSAVE_PATH, quit_app=False): if file is None or file not in (AUTOSAVE_PATH, self.app.modules.rootfolder): file = filedialog.asksaveasfilename(defaultextension="") if not file: return files = self.app.modules.files("file") folders = self.app.modules.files("folder") is_rootfolder = file != AUTOSAVE_PATH and len(files + folders) > 0 if file != AUTOSAVE_PATH: self.app.title(os.path.basename(file)) if is_rootfolder: # need to clear prev files # check in modified self._copy_project_files(file) objects = {} modules = [] file_locals = self.app.modules.locals for j in self.app.modules.store: if not self.app.modules.has_tag(j, "local"): modules.append({ "alias": j, "name": self.app.modules[j].__name__}) # modules = [{ "alias": j, "name": self.app.modules[j].__name__} for j in self.app.modules.store] functions = {} methods = {} custom_fn = {} for name in self.app.objects: objects[name] = self.app.objects.store[name] itemdata = {} for i in self.app.node: item = self.app.node[i] itemdata[i] = { "name": item.name, "position": item.position(), "connection": item.connection, "coord": item.position(), "args": { j: item.args[j] for j in item.args if j != "<value>" }, "kwargs": { k: item.kwargs[k] for k in item.kwargs }, "opts": item.opts.store, } plot_config = plot.config() try: help_geometry = help.browser.geometry() except: help_geometry = help.geometry data = [{ "name": "app_title", "value": self.app.title() },{ "name": "zoom", "value": self.app.node.zoom },{ "name": "geometry", "value": self.app.geometry() if self.app.geometry()[:3] != "1x1" else "1280x720" }, { "name": "horizontal_panel_sash", "value": self.app.horizontal_panel.sashpos(0) },{ "name": "vertical_panel_sash", "value": self.app.vertical_panel.sashpos(0) }, { "name": "rootfolder", "value": self.app.modules.rootfolder },{ "name": "modules", "value": modules },{ "name": "file_locals", "value": file_locals },{ "name": "objects", "value": objects },{ "name": "itemdata", "value": itemdata },{ "name": "files", "value": files },{ "name": "folders", "value": self.app.modules.files("folder") },{ "name": "disabled_files", "value": self.app.modules.files("disabled", True) },{ "name": "plot_window_size", "value": plot_config["size"] if plot_config else None },{ "name": "plot_window_position", "value": plot_config["window_pos"] if plot_config else None },{ "name": "plot2d_options", "value": { i: plot.OPTIONS_2D[i] for i in ["show_grid", "show_range"] } },{ "name": "plot3d_options", "value": { i: plot.OPTIONS_3D[i] for i in ["show_grid"] } },{ "name": "plot_window_position", "value": os.environ["SDL_VIDEO_WINDOW_POS"] if "SDL_VIDEO_WINDOW_POS" in os.environ else None },{ "name": "help_geometry", "value": help_geometry },{ "name": "objects_order", "value": self.app.objects.order() },{ "name": "objects_expanded", "value": self.app.objects.expanded() },{ "name": "console_history", "value": self.app.console.prompt.history.cmds },{ "name": "side_select", "value": self.app.side_view.select() },{ "name": "module_order", "value": self.app.modules.order() },{ "name": "module_expanded", "value": self.app.modules.expanded() }] name, ext = name_ext(file) if is_rootfolder: filepath = os.path.join(file, os.path.basename(file) + ".math") else: filepath = os.path.join(os.path.dirname(file), name + ".math") with open(filepath, "wb") as output: cloudpickle.dump(data, output) if quit_app: plot.close() self.app.quit()
def megaplot(ctsets, studyname, emisfops=None, labels=["$10^9$", "$10^8$", "$10^7$", "$10^6$"], axlabel='Primaries [nr]'): f, (ax1, ax2) = plot.subplots(nrows=2, ncols=1, sharex=False, sharey=False) x = ctsets[0]['ct']['x'] y = ctsets[0]['ct']['av'] if 'iba' in ctsets[0]['name']: # ctset['name'] == typ mm = 4 / 0.8 if 'ipnl' in ctsets[0]['name']: mm = 8 falloff_pos, g_fwhm, contrast = auger.get_fop_fow_contrast( x, y, plot='wut', ax=ax1, ax2=ax2, smooth=0.2, filename=ctsets[0]['ct']['path'], contrast_divisor=ctsets[0]['nprim'] * len(ctsets[0]['ct']['files']) * mm, fitlines=False) # some cosmetics maxyrounded = int(math.ceil(max(y) / 100.0)) * 100 ticks = np.arange(0, maxyrounded, 100) if len(ticks) > 10: ticks = np.arange(0, maxyrounded + 100, 200) if len(ticks) > 10: ticks = np.arange(0, maxyrounded + 200, 400) if len(ticks) > 10: ticks = np.arange(0, maxyrounded + 400, 800) ax1.set_yticks(ticks) minor_locator = AutoMinorLocator(2) minor_locator1 = AutoMinorLocator(2) ax1.xaxis.set_minor_locator(minor_locator) ax2.xaxis.set_minor_locator(minor_locator) ax2.yaxis.set_minor_locator(minor_locator1) if PHYSDET_PROFILE_IBA != None and 'iba' in ctsets[0]['name']: ax1.scatter(x, PHYSDET_PROFILE_IBA, color='lightgrey', marker="x", clip_on=False) if PHYSDET_PROFILE_IPNL != None and 'ipnl' in ctsets[0]['name']: ax1.scatter(x, PHYSDET_PROFILE_IPNL, color='lightgrey', marker="x", clip_on=False) print "NPRIM", ctsets[0]['nprim'], "NJOBS", len( ctsets[0]['ct']['files']), "MM", mm #gebruiken deze falloff_pos niet. we doen contrast en fow over de average van 50 batches wegens smoothe curve. daardoor geen sigma f.savefig(studyname + '-' + typ + str(ctsets[0]['nprim']) + '-FOW.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# # results table for ctset in ctsets: res = [ typ, ctset['nprim'], ctset['ct']['fopmu'], ctset['ct']['fopsigma'], g_fwhm, contrast, ctset['detyieldmu'], ctset['detyieldsigma'], ctset['detcount'], ctset['detcount'] ] if ctset['nprim'] == 10**9: if 'iba' in typ: #res.append(pgprod_1mev_iba*ctset['nprim']) res[-1] = res[-1] / (pgprod_1mev_iba * ctset['nprim']) if 'ipnl' in typ: #res.append(pgprod_1mev_ipnl*ctset['nprim']) res[-1] = res[-1] / (pgprod_1mev_ipnl * ctset['nprim']) else: res[-1] = '' if precolli: res.extend( [ctset['precollidetyieldmu'], ctset['precollidetyieldsigma']]) resultstable.append(res) ############################################################################################# from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt print 'FOP distributions' fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i, ctset in enumerate(ctsets): auger.plotfodist_CTONLY(ax1, ctset, i, emisfops, labels, axlabel) # plt.legend()#shadow = True,frameon = True,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'lower right') # plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T plt.savefig(studyname + '-' + typ + '-FOP-dist.pdf') #, bbox_inches='tight') plt.close('all')
def megaplot(ctsets, studyname, emisfops=None, labels=["$10^9$", "$10^8$", "$10^7$", "$10^6$"], axlabel='Primaries [nr]'): if len(ctsets) == 4: f, ((ax1, ax2), (ax3, ax4)) = plot.subplots(nrows=2, ncols=2, sharex=False, sharey=False) auger.plot_all_ranges_CTONLY(ax1, ctsets[0]) auger.plot_all_ranges_CTONLY(ax2, ctsets[1]) auger.plot_all_ranges_CTONLY(ax3, ctsets[2]) auger.plot_all_ranges_CTONLY(ax4, ctsets[3]) if not 'Primaries' in axlabel: ax1.set_title(labels[0]) ax2.set_title(labels[1]) ax3.set_title(labels[2]) ax4.set_title(labels[3]) f.subplots_adjust(hspace=.5) ax1.set_xlabel('') ax2.set_xlabel('') ax2.set_ylabel('') ax4.set_ylabel('') f.savefig(studyname + '-' + typ + '-FOP.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# # print 'FOP shift distributions' # from mpl_toolkits.mplot3d import Axes3D # import matplotlib.pyplot as plt # fig = plt.figure() # ax1 = plt.axes(projection='3d') # ax1.view_init(30, -50) # for i,ctset in enumerate(ctsets): # auger.plotfodiffdist(ax1,ctset,i,emisfops,labels,axlabel) # if not emisfops == None: # fopshifts=[] # for fopset in emisfops: # fopshifts.append( fopset[-1]-fopset[0] ) # ax1.set_xlim3d(np.mean(fopshifts)-20,np.mean(fopshifts)+20) # if emisfops is not None and len(emisfops) == 1: # ax1.set_title(studyname+', $Shift_{em}$ = '+str(emisfops[0][-1]-emisfops[0][0]), y=1.08) # #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T # fig.savefig(studyname+'-'+typ+'-FOP-shift.pdf')#, bbox_inches='tight') # plt.close('all') f, (ax1, ax2, ax3) = plot.subplots(nrows=3, ncols=1, sharex=False, sharey=False) x = ctsets[0]['rpct']['x'] y = ctsets[0]['ct']['av'] auger.get_fow(x, y, plot='wut', ax=ax1, ax2=ax2, ax3=ax3, smooth=0.2, filename=ctsets[0]['ct'] ['path']) #since high statistics, no smoothing needed # ax1.set_title('FOP = '+str(falloff_pos), fontsize=8) f.savefig(studyname + '-' + typ + '-FOW.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt print 'FOP distributions' fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i, ctset in enumerate(ctsets): auger.plotfodist_CTONLY(ax1, ctset, i, emisfops, labels, axlabel) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname + ', $CT_{FOP_{em}}$ = ' + str(emisfops[0][0])[:5] + ', $RPCT_{FOP_{em}}$ = ' + str(emisfops[0][1])[:5], y=1.08) #plt.legend()#shadow = True,frameon = True,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'lower right') #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T plt.savefig(studyname + '-' + typ + '-FOP-dist.pdf') #, bbox_inches='tight') plt.close('all')
def megaplot(ctsets,studyname,emisfops=None,labels=["$10^9$","$10^8$","$10^7$","$10^6$"],axlabel='Primaries [nr]'): if len(ctsets) == 4: f, ((ax1,ax2),(ax3,ax4)) = plot.subplots(nrows=2, ncols=2, sharex=False, sharey=False) auger.plot_all_ranges_CTONLY(ax1,ctsets[0]) auger.plot_all_ranges_CTONLY(ax2,ctsets[1]) auger.plot_all_ranges_CTONLY(ax3,ctsets[2]) auger.plot_all_ranges_CTONLY(ax4,ctsets[3]) if not 'Primaries' in axlabel: ax1.set_title(labels[0]) ax2.set_title(labels[1]) ax3.set_title(labels[2]) ax4.set_title(labels[3]) f.subplots_adjust(hspace=.5) ax1.set_xlabel('') ax2.set_xlabel('') ax2.set_ylabel('') ax4.set_ylabel('') f.savefig(studyname+'-'+typ+'-FOP.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# # print 'FOP shift distributions' # from mpl_toolkits.mplot3d import Axes3D # import matplotlib.pyplot as plt # fig = plt.figure() # ax1 = plt.axes(projection='3d') # ax1.view_init(30, -50) # for i,ctset in enumerate(ctsets): # auger.plotfodiffdist(ax1,ctset,i,emisfops,labels,axlabel) # if not emisfops == None: # fopshifts=[] # for fopset in emisfops: # fopshifts.append( fopset[-1]-fopset[0] ) # ax1.set_xlim3d(np.mean(fopshifts)-20,np.mean(fopshifts)+20) # if emisfops is not None and len(emisfops) == 1: # ax1.set_title(studyname+', $Shift_{em}$ = '+str(emisfops[0][-1]-emisfops[0][0]), y=1.08) # #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T # fig.savefig(studyname+'-'+typ+'-FOP-shift.pdf')#, bbox_inches='tight') # plt.close('all') ############################################################################################# # print 'FOP FOW Contrast DE averages over 10e9 ctset' f, (ax1,ax2,ax3) = plot.subplots(nrows=3, ncols=1, sharex=False, sharey=False) x=ctsets[0]['ct']['x'] y=ctsets[0]['ct']['av'] if 'iba' in ctsets[0]['name']: # ctset['name'] == typ mm=4/0.8 if 'ipnl' in ctsets[0]['name']: mm=8 falloff_pos,g_fwhm,contrast = auger.get_fop_fow_contrast(x,y,plot='wut',ax=ax1,ax2=ax2,ax3=ax3,smooth=0.2,filename=ctsets[0]['ct']['path'],contrast_divisor=ctsets[0]['nprim']*len(ctsets[0]['ct']['files'])*mm) print "NPRIM", ctsets[0]['nprim'],"NJOBS",len(ctsets[0]['ct']['files']),"MM",mm #gebruiken deze falloff_pos niet. we doen contrast en fow over de average van 50 batches wegens smoothe curve. daardoor geen sigma res=[typ,ctsets[0]['ct']['fopmu'],ctsets[0]['ct']['fopsigma'],g_fwhm,contrast,ctsets[0]['detyieldmu'],ctsets[0]['detyieldsigma']] resultstable.append(res) f.savefig(studyname+'-'+typ+'-FOW.pdf', bbox_inches='tight') plot.close('all') ############################################################################################# from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt print 'FOP distributions' fig = plt.figure() ax1 = plt.axes(projection='3d') ax1.view_init(30, -50) for i,ctset in enumerate(ctsets): auger.plotfodist_CTONLY(ax1,ctset,i,emisfops,labels,axlabel) if emisfops is not None and len(emisfops) == 1: ax1.set_title(studyname+', $CT_{FOP_{em}}$ = '+str(emisfops[0][0])[:5]+', $RPCT_{FOP_{em}}$ = '+str(emisfops[0][1])[:5], y=1.08) #plt.legend()#shadow = True,frameon = True,fancybox = True,ncol = 1,fontsize = 'x-small',loc = 'lower right') #plt.tight_layout(rect = [-0.1, 0.0, 1.0, 1.1])#L,B,R,T plt.savefig(studyname+'-'+typ+'-FOP-dist.pdf')#, bbox_inches='tight') plt.close('all')