def define_plots(beamLine): plots = [] plot = xrtp.XYCPlot( 'beamFSM0', aspect='auto', xaxis=xrtp.XYCAxis(xName, unit, bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(zName, unit, bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('energy', 'eV', bins=eBins, ppb=eppb), title='1-BeamSource') plot.baseName = plot.title + suffix plots.append(plot) plot = xrtp.XYCPlot( 'beamFSM1', aspect='auto', xaxis=xrtp.XYCAxis(xName, unit, bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(zName, unit, bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('energy', 'eV', bins=eBins, ppb=eppb), title='2-Screen Rays') plot.baseName = plot.title + suffix plots.append(plot) plot = xrtp.XYCPlot( 'waveOnScreen', aspect='auto', xaxis=xrtp.XYCAxis(xName, unit, bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(zName, unit, bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('energy', 'eV', bins=eBins, ppb=eppb), title='3-Screen Wave') plot.baseName = plot.title + suffix plots.append(plot) return plots
def define_plots(bl): plots = [] plot = xrtplot.XYCPlot(beam='s0', xaxis=xrtplot.XYCAxis(label="x", fwhmFormatStr='%.3f', limits=[-1, 1]), yaxis=xrtplot.XYCAxis(label="z", fwhmFormatStr='%.3f', limits=[-1.5, 1]), caxis=xrtplot.XYCAxis(label="energy", unit=r"eV", offset=E0, fwhmFormatStr='%.4f')) plots.append(plot) plot = xrtplot.XYCPlot(beam='det', xaxis=xrtplot.XYCAxis(label="x", fwhmFormatStr='%.3f', limits=[-1, 1]), yaxis=xrtplot.XYCAxis(label="z", fwhmFormatStr='%.3f', limits=[-1.5, 1]), caxis=xrtplot.XYCAxis(label="energy", unit=r"eV", offset=E0, fwhmFormatStr='%.4f')) plots.append(plot) return plots
def define_plots(beamLine): fwhmFormatStrE = None plots = [] plot1 = xrtp.XYCPlot( 'beamFSM1', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), title='FSM1_E') plot1.caxis.fwhmFormatStr = None plot1.caxis.limits = [70, 130] plots.append(plot1) plot2 = xrtp.XYCPlot( 'beamFSM2', (1,), aspect='auto', xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits='symmetric'), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), caxis=xrtp.XYCAxis('energy', 'eV', bins=64, ppb=4, limits=[70, 130]), title='FSM2_Es') plot2.caxis.fwhmFormatStr = fwhmFormatStrE # plot2.fluxFormatStr = '%.2e' plot2.saveName = gratingKind + 'E.png' plots.append(plot2) plot3 = xrtp.XYCPlot( 'beamFSM2', (1,), aspect='auto', xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits='symmetric'), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), caxis=xrtp.XYCAxis('diffraction order', '', bins=32, ppb=8), title='FSM2_Es') plot3.caxis.fwhmFormatStr = None plot3.caxis.limits = [-2.1, 2.1] # plot2.fluxFormatStr = '%.2e' plot3.saveName = gratingKind + 'Order.png' plots.append(plot3) return plots
def main(): beamLine = build_beamline() fwhmFormatStrE = '%.2f' plots = [] plot = xrtp.XYCPlot('beamFSM1', caxis='category') plots.append(plot) for i, dy in enumerate(beamLine.fsm2dY): plot = xrtp.XYCPlot('beamFSM2-{0:d}'.format(i+1), caxis='category') plots.append(plot) for plot in plots: plot.caxis.fwhmFormatStr = fwhmFormatStrE plot.xaxis.fwhmFormatStr = fwhmFormatStrE plot.yaxis.fwhmFormatStr = fwhmFormatStrE plot.xaxis.limits = lim plot.yaxis.limits = lim plot.fluxFormatStr = '%.2e' if globalRoll == 0: globalRollTxt = '0' elif globalRoll == np.pi/2: globalRollTxt = u'0.5π' elif globalRoll == np.pi/4: globalRollTxt = u'0.25π' elif globalRoll == np.pi: globalRollTxt = u'π' else: globalRollTxt = '{0}'.format(globalRoll) plot.saveName = \ ['{0}-roll={1}-{2}.png'.format(case, globalRollTxt, plot.title)] xrtr.run_ray_tracing(plots, repeats=1, beamLine=beamLine)
def define_plots(beamLine): plots = [] plot1 = xrtp.XYCPlot( 'beamFSM1', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=limitsFSM), yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=limitsFSM), ePos=1, title=beamLine.fsm1.name+'_E') plot1.caxis.invertAxis = True plots.append(plot1) plot = xrtp.XYCPlot( 'beamLaueSCMlocal', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=limitsFSM), yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=limitsFSM), ePos=1, title=beamLine.laueSCM.name+'_E') plot.caxis.invertAxis = True plots.append(plot) plot2 = xrtp.XYCPlot( 'beamFSM2', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=limitsFSM), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), ePos=1, title=beamLine.fsm2.name+'_E') plot2.caxis.invertAxis = True plot2.textPanel = plot2.fig.text( 0.88, 0.8, '', transform=plot2.fig.transFigure, size=14, color='r', ha='center') plots.append(plot2) return plots
def define_plots(beamLine): plots = [] # plot = xrtp.XYCPlot('beamFilter1local1', (1,), # xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$y$', 'mm'), # caxis=xrtp.XYCAxis('energy', 'keV'), # title='Footprint1_I') # plot.fluxFormatStr = '%.2e' # plots.append(plot) plot = xrtp.XYCPlot( 'beamVCMlocal', (1, ), aspect='auto', xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-7, 7]), yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-700, 700]), caxis=xrtp.XYCAxis('energy', 'keV'), fluxKind='power', title='FootprintP', # oe=beamLine.vcm, contourLevels=[ 0.9, ], contourColors=[ 'r', ], contourFmt=r'%.3f W/mm$^2$') plot.fluxFormatStr = '%.0f' plot.xaxis.fwhmFormatStr = '%.1f' plot.yaxis.fwhmFormatStr = '%.0f' plot.textPanel = plot.fig.text(0.85, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plots.append(plot) plot = xrtp.XYCPlot('beamFSMVCM', (1, ), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), caxis=xrtp.XYCAxis('energy', 'keV'), title='FSM') plot.xaxis.limits = [-7, 7] plot.yaxis.limits = [-2, 12] plot.fluxFormatStr = '%.2p' plot.textPanel = plot.fig.text(0.85, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plots.append(plot) for plot in plots: plot.caxis.limits = [0, beamLine.sources[0].eMax * 1e-3] plot.caxis.fwhmFormatStr = None return plots
def define_plots(beamLine): plots = [] xlimits = [-1, 1] plotSource = xrtp.XYCPlot('beamFSMsource', (1, ), xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=xlimits), yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=xlimits), ePos=0, title='0-source') plots.append(plotSource) plotLocal = xrtp.XYCPlot('oeLocal', (1, ), aspect='auto', xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=xlimits), yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=beamLine.oe.limPhysY), caxis=xrtp.XYCAxis(r"theta", 'mrad'), ePos=1, title='1-oeLocal') plots.append(plotLocal) xlimits = [-500, 500] for iR, R in enumerate(Rs): plotRefl = xrtp.XYCPlot('beamFSMrefl{0:02d}'.format(iR), (1, ), aspect='auto', xaxis=xrtp.XYCAxis(r'$x$', u'µm', limits=xlimits), yaxis=xrtp.XYCAxis(r'$z$', u'µm', limits=xlimits), ePos=0, title='2-refl') Rstr = '{0:.1f}km'.format(R * 1e-6) if R < 1e19 else 'inf' plotRefl.saveName = '{0}-{1}-R={2}.png'.format(prefix, iR, Rstr) Rstr = '{0:.1f} km'.format(R * 1e-6) if R < 1e19 else '$\infty$' plotRefl.textPanel = plotRefl.ax2dHist.text( 0.01, 0.01, 'R = {0}'.format(Rstr), transform=plotRefl.ax2dHist.transAxes, size=12, color='w', ha='left', va='bottom') plots.append(plotRefl) ax = plotRefl.xaxis edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins + 1) beamLine.fsmExpX = (edges[:-1] + edges[1:]) * 0.5 / ax.factor # print(beamLine.fsmExpX) ax = plotRefl.yaxis edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins + 1) beamLine.fsmExpZ = (edges[:-1] + edges[1:]) * 0.5 / ax.factor # print(beamLine.fsmExpZ) for plot in plots: plot.fluxFormatStr = '%.1p' return plots
def define_plots(beamLine): plots = [] beamLine.fsmXZmeshes = [] for ip, p in enumerate(ps): lim = beamLine.source.w(p, E0) * maxFactor * 1e3 plot = xrtp.XYCPlot( 'beamFSMg{0}'.format(ip), (1,), xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=bins, ppb=ppb), yaxis=xrtp.XYCAxis(r'$z$', u'µm', bins=bins, ppb=ppb), caxis=xrtp.XYCAxis('Es phase', '', data=raycing.get_Es_phase, bins=bins, ppb=ppb)) plot.xaxis.limits = [-lim, lim] plot.yaxis.limits = [-lim, lim] plot.title = '{0}{1:02d}-beamFSMg-at{2:03.1f}m'.format( prefix, ip, p*1e-3) tpf = '{0:2.1f} m' if p < 1000 else '{0:2.0f} m' plot.textPanel = plot.ax2dHist.text( 0.02, 0.98, tpf.format(p*1e-3), size=14, color='w', transform=plot.ax2dHist.transAxes, ha='left', va='top') plot.saveName = plot.title + '.png' plots.append(plot) if p > 100 and wantKirchhoff: plot = xrtp.XYCPlot( 'beamFSMk{0}'.format(ip), (1,), xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=bins, ppb=ppb), yaxis=xrtp.XYCAxis(r'$z$', u'µm', bins=bins, ppb=ppb), caxis=xrtp.XYCAxis('Es phase', '', data=raycing.get_Es_phase, bins=bins, ppb=ppb)) plot.xaxis.limits = [-lim, lim] plot.yaxis.limits = [-lim, lim] plot.textPanel = plot.ax2dHist.text( 0.02, 0.98, tpf.format(p*1e-3), size=14, color='w', transform=plot.ax2dHist.transAxes, ha='left', va='top') plot.title = '{0}{1:02d}-beamFSMk-at{2:03.1f}m'.format( prefix, ip, p*1e-3) plot.saveName = plot.title + '.png' plots.append(plot) ax = plot.xaxis edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins+1) xCenters = (edges[:-1] + edges[1:]) * 0.5 / ax.factor ax = plot.yaxis edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins+1) zCenters = (edges[:-1] + edges[1:]) * 0.5 / ax.factor beamLine.fsmXZmeshes.append([xCenters, zCenters]) for plot in plots: plot.caxis.limits = [-np.pi, np.pi] plot.caxis.fwhmFormatStr = None plot.ax1dHistE.set_yticks([l*np.pi for l in (-1, -0.5, 0, 0.5, 1)]) plot.ax1dHistE.set_yticklabels( (r'$-\pi$', r'-$\frac{\pi}{2}$', 0, r'$\frac{\pi}{2}$', r'$\pi$')) return plots
def define_plots(beamLine): plots = [] plot = xrtplot.XYCPlot(beam=r"beamSource", aspect='auto', xaxis=xrtplot.XYCAxis(r"x'", 'mrad'), yaxis=xrtplot.XYCAxis(r"z'", 'mrad', data=get_dtheta)) plot.saveName = ["0-source.png"] plots.append(plot) plot = xrtplot.XYCPlot(beam=r"beamXtalLocal", aspect='auto', xaxis=xrtplot.XYCAxis(r"x'", 'mrad'), yaxis=xrtplot.XYCAxis(r"z'", 'mrad', data=get_dtheta)) plot.saveName = ["1-localXtal.png"] plots.append(plot) plot = xrtplot.XYCPlot(beam=r"beamXtalLocal", aspect='auto', xaxis=xrtplot.XYCAxis(r"y", 'mm'), yaxis=xrtplot.XYCAxis(r"z", 'µm', limits=[-400, 10])) plot.saveName = ["1-localXtalDepth.png"] plots.append(plot) for iscr, screenPos in enumerate(screenPoss): plot = xrtplot.XYCPlot(beam='beamScreen' + '{0:d}'.format(iscr), aspect='auto', xaxis=xrtplot.XYCAxis(r"x", limits=[-100, 100], bins=xBins), yaxis=xrtplot.XYCAxis(r"z", limits=[-3.6, 3.6], bins=zBins)) plot.textPanel = plot.fig.text(0.88, 0.9, 'p:q = 1:{0:.0f}'.format( (screenPos - p) / p), transform=plot.fig.transFigure, size=14, color='r', ha='center') plot.saveName = ["2-screen{0:d}.png".format(iscr + 1)] plots.append(plot) for plot in plots: plot.caxis.offset = Ec plot.xaxis.fwhmFormatStr = '%.2f' plot.yaxis.fwhmFormatStr = '%.2f' return plots
def define_plots(beamLine): plots = [] xaxis = xrtp.XYCAxis(r'$x$', 'mm', limits=xlimits, bins=bins, ppb=ppb) yaxis = xrtp.XYCAxis(r'$z$', 'mm', limits=zlimits, bins=bins, ppb=ppb) caxis = xrtp.XYCAxis('Es phase', '', data=raycing.get_Es_phase, limits=[-np.pi, np.pi], bins=bins, ppb=ppb) plot = xrtp.XYCPlot('beamFSM1', (1, ), xaxis=xaxis, yaxis=yaxis, caxis=caxis, fluxKind='s', aspect='auto', title='horizontal polarization flux') plot.saveName = prefix + '1horFlux' + suffix + '.png' plots.append(plot) ax = plot.xaxis edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins + 1) beamLine.fsmExpX = (edges[:-1] + edges[1:]) * 0.5 / ax.factor ax = plot.yaxis edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins + 1) beamLine.fsmExpZ = (edges[:-1] + edges[1:]) * 0.5 / ax.factor xaxis = xrtp.XYCAxis(r'$x$', 'mm', limits=xlimits, bins=bins, ppb=ppb) yaxis = xrtp.XYCAxis(r'$z$', 'mm', limits=zlimits, bins=bins, ppb=ppb) caxis = xrtp.XYCAxis('Ep phase', '', data=raycing.get_Ep_phase, limits=[-np.pi, np.pi], bins=bins, ppb=ppb) plot = xrtp.XYCPlot('beamFSM1', (1, ), xaxis=xaxis, yaxis=yaxis, caxis=caxis, fluxKind='p', aspect='auto', title='vertical polarization flux') plot.saveName = prefix + '3verFlux' + suffix + '.png' plots.append(plot) for plot in plots: plot.xaxis.fwhmFormatStr = '%.3f' plot.yaxis.fwhmFormatStr = '%.3f' plot.caxis.fwhmFormatStr = None plot.fluxFormatStr = '%.2p' plot.ax1dHistE.set_yticks([l * np.pi for l in (-1, -0.5, 0, 0.5, 1)]) plot.ax1dHistE.set_yticklabels( (r'$-\pi$', r'-$\frac{\pi}{2}$', 0, r'$\frac{\pi}{2}$', r'$\pi$')) return plots
def demo(): """The main body of demo.""" plots = [] #create a plot... plot = plotter.XYCPlot(title='normal energy distribution') #notice the energy offset and how it is displayed plot.caxis.offset = 5000 # plot1.persistentName='01.pickle' #for saving and restoring plot.xaxis.limits = [-2.5, 2.5] plot.yaxis.limits = [-2.5, 2.5] filename = 'offset5000' plot.saveName = [filename + '.pdf', filename + '.png'] #an example of creating a label: #the first 2 values are x and y in figure coordinates plot.textPanel = plot.fig.text(0.76, 0.8, '', transform=plot.fig.transFigure, size=12, color='r') plot.caxis.fwhmFormatStr = '%.1f' plots.append(plot) #... and another plot. The 2nd plot is negative and of inverted colors (i.e. #the energy color map is inverted back to that of plot1 after making the graph #negative) plot = plotter.XYCPlot(invertColorMap=True, negative=True, title='normal energy distribution,\ negative+{inverted colors}') plot.xaxis.limits = [-1, 1] plot.yaxis.limits = [-1, 1] #an example of creating a label: plot.textPanel = plot.fig.text(0.76, 0.8, '', transform=plot.fig.transFigure, size=12, color='b') plot.xaxis.fwhmFormatStr = '%.1f' plots.append(plot) #a dummy text: for plot in plots: plot.textPanel.set_text('test label1 = {0}\ntest label2 = {1}'.format( 0.1, r'$e^{i\pi}$')) runner.run_ray_tracing(plots, repeats=40, updateEvery=2, backend='dummy', processes='all')
def define_plots(beamLine): plots = [] plot = xrtp.XYCPlot( 'beamFilter1local1', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$y$', 'mm'), caxis=xrtp.XYCAxis('energy', 'keV'), title='Footprint1_I') plot.fluxFormatStr = '%.2p' plots.append(plot) plot = xrtp.XYCPlot( 'beamFilter1local1', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$y$', 'mm'), caxis=xrtp.XYCAxis('energy', 'keV'), fluxKind='power', title='Footprint1_P', contourLevels=[0.85, 0.95], contourColors=['b', 'r'], contourFmt=r'%.1f W/mm$^2$') plot.fluxFormatStr = '%.0f' plots.append(plot) plot = xrtp.XYCPlot( 'beamFilter1local2', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$y$', 'mm'), caxis=xrtp.XYCAxis('energy', 'keV'), title='Footprint2_I') plot.fluxFormatStr = '%.2p' plot.textPanel = plot.fig.text( 0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plots.append(plot) plot = xrtp.XYCPlot( 'beamFilter1local2A', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$y$', 'mm'), caxis=xrtp.XYCAxis('energy', 'keV'), fluxKind='power', title='Footprint2_PA', contourLevels=[0.85, 0.95], contourColors=['b', 'r'], contourFmt=r'%.1f W/mm$^2$') plot.fluxFormatStr = '%.0f' plot.textPanel = plot.fig.text( 0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plots.append(plot) for plot in plots: plot.xaxis.limits = [-7, 7] plot.yaxis.limits = [-7, 7] plot.caxis.limits = [0, beamLine.sources[0].eMax*1e-3] plot.caxis.fwhmFormatStr = None return plots
def define_plots(beamLine): plots = [] plotsR = [] xmax = 1100 * beamLine.bg.rho_1 plot = xrtp.XYCPlot( 'oeLocal', aspect='auto', xaxis=xrtp.XYCAxis(r'$y$', u'µm', limits=[-xmax, xmax]), yaxis=xrtp.XYCAxis(r'$z$', 'nm', limits=[-1e3*np.tan(blaze)*xmax, 0]), caxis=xrtp.XYCAxis('energy', 'meV', bins=eBins, ppb=eppb)) plots.append(plot) plot = xrtp.XYCPlot( 'saw', aspect='auto', xaxis=xrtp.XYCAxis(r'$y$', u'µm', limits=[-xmax, xmax]), yaxis=xrtp.XYCAxis(r'$z$', 'nm', limits=[-1e3*np.tan(blaze)*xmax, 0]), caxis=xrtp.XYCAxis('energy', 'meV', bins=eBins, ppb=eppb)) plots.append(plot) # for order in range(minOrder, maxOrder+1): for order in [1]: plot = xrtp.XYCPlot( 'beamFSMrays', aspect='auto', xaxis=xrtp.XYCAxis(r'$\phi$', u'µrad', bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(r'$\theta$', u'µrad', bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('energy', 'meV', bins=eBins, ppb=eppb)) plot.title = 'beamFSMrays{0}'.format(order) plot.baseName = plot.title plot.order = order plots.append(plot) plotsR.append(plot) plot = xrtp.XYCPlot( 'waveFSM', aspect='auto', xaxis=xrtp.XYCAxis(r'$\phi$', u'µrad', bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(r'$\theta$', u'µrad', bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('energy', 'meV', bins=eBins, ppb=eppb)) plot.title = 'beamFSMwave{0}'.format(order) plot.baseName = plot.title plot.order = order plots.append(plot) plotsR.append(plot) for plot in plots: # plot.xaxis.limits = [-xmax, xmax] plot.xaxis.fwhmFormatStr = None plot.fluxFormatStr = '%.2p' if hasattr(plot, 'baseName'): plot.saveName = [plot.baseName + '.png'] # plot.persistentName = plot.baseName + '.pickle' return plots, plotsR
def define_plots(beamLine): fwhmFormatStrE = '%.2f' plots = [] # plot = xrtp.XYCPlot( # 'beamFSM1', (1,), xaxis=xrtp.XYCAxis(r'$x$', r'$\mu$m'), # yaxis=xrtp.XYCAxis(r'$z$', r'$\mu$m'), title='FSM1_E') # plot.caxis.fwhmFormatStr = None # plot.saveName = [plot.title + '.png', ] # plots.append(plot) # plot = xrtp.XYCPlot( 'beamFZPlocal', (1, -1), xaxis=xrtp.XYCAxis(r'$x$', r'$\mu$m', bins=512, ppb=1, limits=[-12, 12]), yaxis=xrtp.XYCAxis(r'$y$', r'$\mu$m', bins=512, ppb=1, limits=[-12, 12]), caxis='category', title='localZ') plot.caxis.fwhmFormatStr = None plot.textPanel = plot.ax1dHistX.text( 0.5, 0.02, '', size=14, color='w', transform=plot.ax1dHistX.transAxes, ha='center', va='bottom') plots.append(plot) plot = xrtp.XYCPlot( 'beamFZPlocal', (1, -1), xaxis=xrtp.XYCAxis(r'$x$', r'$\mu$m', bins=512, ppb=1), yaxis=xrtp.XYCAxis(r'$y$', r'$\mu$m', bins=512, ppb=1), caxis='category', title='localFull') plot.caxis.fwhmFormatStr = None plot.textPanel = plot.ax1dHistX.text( 0.5, 0.02, '', size=14, color='w', transform=plot.ax1dHistX.transAxes, ha='center', va='bottom') plots.append(plot) plot = xrtp.XYCPlot( 'beamFSM2', (1,), xaxis=xrtp.XYCAxis(r'$x$', r'nm', bins=256, ppb=1, limits=[-500, 500]), yaxis=xrtp.XYCAxis(r'$z$', r'nm', bins=256, ppb=1, limits=[-500, 500]), caxis='category', title='FSM2_Es') plot.caxis.fwhmFormatStr = fwhmFormatStrE plot.fluxFormatStr = '%.2e' plot.textPanel = plot.ax1dHistX.text( 0.5, 0.02, '', size=14, color='w', transform=plot.ax1dHistX.transAxes, ha='center', va='bottom') plots.append(plot) return plots
def define_plots(): plots = [] plot = xrtp.XYCPlot('beamFSMSample', (1, ), aspect='auto', xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), caxis=xrtp.XYCAxis('energy', 'eV'), title='Sample', ePos=0) plot.xaxis.limits = [-10, 10] plot.yaxis.limits = [42.79 - 10, 42.79 + 10] # plot.xaxis.fwhmFormatStr = '%.0f' # plot.yaxis.fwhmFormatStr = '%.2f' plot.fluxFormatStr = '%.1p' plot.textPanel = plot.ax2dHist.text(0.5, 0.9, '', transform=plot.ax2dHist.transAxes, size=14, color='r', ha='center') plots.append(plot) for plot in plots: plot.caxis.limits = [E0 - dE, E0 + dE] plot.caxis.offset = E0 return plots
def define_plots(beamLine): plots = [] plotsE = [] xaxis = xrtp.XYCAxis(r'$x$', 'mm', limits=xlimitsZoom, bins=bins, ppb=ppb) yaxis = xrtp.XYCAxis(r'$z$', 'mm', limits=zlimitsZoom, bins=bins, ppb=ppb) caxis = xrtp.XYCAxis('energy', eUnit, fwhmFormatStr=None, bins=bins, ppb=ppb) plot = xrtp.XYCPlot('beamFSM1zoom', (1, ), xaxis=xaxis, yaxis=yaxis, caxis=caxis, fluxKind='s', aspect='auto', title='horizontal polarization flux zoom') plot.caxis.fwhmFormatStr = None plot.saveName = prefix + '2horizFluxZoom' + suffix + '.png' plots.append(plot) plotsE.append(plot) for plot in plotsE: f = plot.caxis.factor plot.caxis.limits = eMinRays * f, eMaxRays * f for plot in plots: plot.xaxis.fwhmFormatStr = '%.2f' plot.yaxis.fwhmFormatStr = '%.2f' plot.fluxFormatStr = '%.2p' return plots, plotsE
def define_plots(beamLine): plots = [] plotsE = [] xaxis = xrtp.XYCAxis(r'$x$', 'mm', limits=xlimits, bins=512, ppb=1) yaxis = xrtp.XYCAxis(r'$z$', 'mm', limits=zlimits, bins=256, ppb=1) caxis = xrtp.XYCAxis('energy', 'eV', limits=elimits, offset=E0, bins=256, ppb=1) plot = xrtp.XYCPlot('beamFSM1', (1, ), xaxis=xaxis, yaxis=yaxis, caxis=caxis, aspect='auto', title='total flux', ePos=1) plot.baseName = prefix + '1TotalFlux - nearAxis - s' plot.saveName = plot.baseName + '.png' plots.append(plot) plotsE.append(plot) for plot in plots: plot.fluxFormatStr = '%.2p' return plots, plotsE
def define_plots(): plots = [] if mirror == 'vcm': plot = xrtp.XYCPlot('beamFSMDCM', (1, ), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), caxis=xrtp.XYCAxis('energy', 'eV'), title='DCM') plot.xaxis.limits = [-7., 7.] plot.yaxis.limits = [38.1 - 7., 38.1 + 7.] plot.fluxFormatStr = '%.2p' plot.textPanel = plot.fig.text(0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plots.append(plot) plot = xrtp.XYCPlot('beamFSMSample', (1, ), aspect='auto', xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=xrtp.defaultBins / 2), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), caxis=xrtp.XYCAxis('energy', 'eV'), title='Sample') plot.xaxis.limits = [-300, 300] plot.yaxis.limits = [42.8 - 0.6, 42.8 + 0.6] plot.ax2dHist.xaxis.set_major_locator(FixedLocator([-200, 0, 200])) plot.xaxis.fwhmFormatStr = '%.0f' plot.yaxis.fwhmFormatStr = '%.2f' plot.fluxFormatStr = '%.2p' plot.textPanel = plot.fig.text(0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plots.append(plot) for plot in plots: plot.caxis.limits = [E0 - dE, E0 + dE] plot.caxis.offset = E0 return plots
def define_plots(beamLine): plots = [] plot = xrtp.XYCPlot('beamFSMDCM', (1, ), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), caxis=xrtp.XYCAxis('energy', 'keV', fwhmFormatStr='%.2f'), title='DCM') plot.xaxis.limits = [-7., 7.] plot.yaxis.limits = [20.3 - 7., 20.3 + 7.] plot.fluxFormatStr = '%.1p' plot.textPanel = plot.fig.text(0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plot.baseName = 'afterDMM' plots.append(plot) plot = xrtp.XYCPlot('beamDCMlocal1', (1, ), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$y$', 'mm'), caxis=xrtp.XYCAxis('energy', 'keV', fwhmFormatStr='%.2f'), title='Xtal1 local') plot.xaxis.limits = [-86., 86.] plot.yaxis.limits = [-86., 86.] plot.fluxFormatStr = '%.1p' plot.textPanel = plot.fig.text(0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plot.baseName = '1stML' plots.append(plot) for plot in plots: plot.caxis.limits = [(E0 - dE) * 1e-3, (E0 + dE) * 1e-3] plot.caxis.offset = E0 * 1e-3 return plots
def define_plots(beamLine): plots = [] plot = xrtp.XYCPlot( 'beamFSM0', aspect='auto', xaxis=xrtp.XYCAxis(xName, unit, bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(zName, unit, bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('energy', 'eV', bins=eBins, ppb=eppb), title='1 - Source') plots.append(plot) plot = xrtp.XYCPlot( 'beamFSM1', aspect='auto', xaxis=xrtp.XYCAxis(xName, unit, bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(zName, unit, bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('energy', 'eV', bins=eBins, ppb=eppb), title='2 - DS Propagation Rays') plots.append(plot) plot = xrtp.XYCPlot( 'beamFSM1wave', aspect='auto', xaxis=xrtp.XYCAxis(xName, unit, bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(zName, unit, bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('energy', 'eV', bins=eBins, ppb=eppb), #fluxKind='wave', title='3 - DS Propagation Wave') plots.append(plot) plot = xrtp.XYCPlot( 'beamFSM1wave', aspect='auto', xaxis=xrtp.XYCAxis(xName, unit, bins=xBins, ppb=xppb), yaxis=xrtp.XYCAxis(zName, unit, bins=zBins, ppb=zppb), caxis=xrtp.XYCAxis('Es phase', '', data=raycing.get_Es_phase, limits=[-np.pi, np.pi], bins=eBins, ppb=eppb), fluxKind='s', title='4 - DS Propagation Es phase') plots.append(plot) for plot in plots: plot.textPanel = plot.fig.text( 0.82, 0.6, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') return plots
def define_plots(): plots = [] Plot01 = xrtplot.XYCPlot(beam=r"FSM_SourcebeamLocal01", xaxis=xrtplot.XYCAxis(label=r"x", bins=256, ppb=1, fwhmFormatStr=r"%.2f"), yaxis=xrtplot.XYCAxis(label=r"z", bins=256, ppb=1, fwhmFormatStr=r"%.2f"), caxis=xrtplot.XYCAxis(label=r"energy", unit=r"eV", bins=256, ppb=1, fwhmFormatStr=r"%.2f"), title=r"01 - Undulator Beam at 29m", fluxFormatStr=r"%g", saveName=r"01 - Undulator Beam at 29m.png") plots.append(Plot01) Plot03 = xrtplot.XYCPlot(beam=r"FSM_DetectorbeamLocal01", xaxis=xrtplot.XYCAxis(label=r"x", limits=detLimits, bins=512, ppb=1, fwhmFormatStr=r"%.2f"), yaxis=xrtplot.XYCAxis(label=r"z", limits=detLimits, bins=512, ppb=1, fwhmFormatStr=r"%.2f"), caxis=xrtplot.XYCAxis(label=r"energy", unit=r"eV", bins=512, ppb=1, fwhmFormatStr=r"%.2f"), title=r"03 - Detector", fluxFormatStr=r"%g") plots.append(Plot03) return plots
def main(): plot2 = xrtp.XYCPlot('star.04') plot2.caxis.offset = 6000 plot2.xaxis.limits = [-4, 4] plot2.yaxis.limits = [-4, 4] plot2.yaxis.factor *= -1 textPanel2 = plot2.fig.text(0.88, 0.8, '', transform=plot2.fig.transFigure, size=12, color='r', ha='center') #========================================================================== threads = 4 #========================================================================== start01 = shadow.files_in_tmp_subdirs('start.01', threads) start04 = shadow.files_in_tmp_subdirs('start.04', threads) shadow.modify_input(start01, ('THICK(1)', str(60 * 1e-4))) stripe = 'Rh' shadow.modify_input(start01, ('FILE_REFL', stripe + '_refl.dat')) shadow.modify_input(start04, ('FILE_REFL', stripe + '_refl.dat')) def plot_generator(): shadow.modify_input(start01, ('F_REFLEC', '1')) for angle in np.linspace(4.1e-3, 5.3e-3, 7): rmirr = 744680 * 4.7e-3 / angle shadow.modify_input(start01, ('RMIRR', str(rmirr))) r_maj = 476597 * 4.7e-3 / angle shadow.modify_input(start04, ('R_MAJ', str(r_maj))) tIncidence = 90 - angle * 180 / np.pi shadow.modify_input(start01, ('T_INCIDENCE', str(tIncidence)), ('T_REFLECTION', str(tIncidence))) shadow.modify_input(start04, ('T_INCIDENCE', str(tIncidence)), ('T_REFLECTION', str(tIncidence))) filename04 = '04' + stripe + '_pitch_%.1f' % (angle * 1e3) plot2.title = filename04 plot2.saveName = \ [filename04 + '.pdf', filename04 + '.png', filename04 + '.svg'] # plot2.persistentName = filename04 + '.pickle' textPanel2.set_text(stripe + ' coating,\nangle\n%.1f mrad' % (angle * 1e3)) yield 0 xrtr.run_ray_tracing(plot2, repeats=640, updateEvery=2, threads=threads, energyRange=[5998, 6002], generator=plot_generator, globalNorm=True, backend='shadow')
def define_plots(): plots = [] P1H = xrtplot.XYCPlot(beam=r"P1Hbeam", xaxis=xrtplot.XYCAxis(label=r"x", density=r"kde"), yaxis=xrtplot.XYCAxis(label=r"z", limits=[-4, 4]), caxis=xrtplot.XYCAxis(label=r"energy", unit=r"eV"), ePos=0, title=r"P1H") plots.append(P1H) P2H = xrtplot.XYCPlot(beam=r"P2Hbeam", xaxis=xrtplot.XYCAxis(label=r"x"), yaxis=xrtplot.XYCAxis(label=r"z", limits=[-4, 4]), caxis=xrtplot.XYCAxis(label=r"energy", unit=r"eV"), ePos=0, title=r"P2H", contourFmt=r"%.3f") plots.append(P2H) P3H = xrtplot.XYCPlot(beam=r"P3HBeam", xaxis=xrtplot.XYCAxis(label=r"x"), yaxis=xrtplot.XYCAxis(label=r"z", limits=[-4, 4]), caxis=xrtplot.XYCAxis(label=r"energy", unit=r"eV"), ePos=0, title=r"P3H") plots.append(P3H) DG3 = xrtplot.XYCPlot(beam=r"DG3Beam", xaxis=xrtplot.XYCAxis(label=r"x"), yaxis=xrtplot.XYCAxis(label=r"z", limits=[-4, 4]), caxis=xrtplot.XYCAxis(label=r"energy", unit=r"eV"), ePos=0, title=r"DG3") plots.append(DG3) return plots
def main(): plot1 = xrtp.XYCPlot('star.04') plot1.caxis.offset = 6000 plot1.xaxis.limits = [-1, 1] plot1.yaxis.limits = [-1, 1] plot1.yaxis.factor *= -1 textPanel1 = plot1.fig.text(0.86, 0.8, '', transform=plot1.fig.transFigure, size=12, color='r', ha='center') #========================================================================== threads = 4 #========================================================================== start01 = shadow.files_in_tmp_subdirs('start.01', threads) start04 = shadow.files_in_tmp_subdirs('start.04', threads) rmirr0 = 744680. shadow.modify_input(start01, ('RMIRR', str(rmirr0))) angle = 4.7e-3 tIncidence = 90 - angle * 180 / np.pi shadow.modify_input(start01, ('T_INCIDENCE', str(tIncidence)), ('T_REFLECTION', str(tIncidence))) shadow.modify_input(start04, ('T_INCIDENCE', str(tIncidence)), ('T_REFLECTION', str(tIncidence))) rmaj0 = 476597.0 def plot_generator(): for rmaj in np.logspace(-1, 1, 7, base=1.5) * rmaj0: shadow.modify_input(start04, ('R_MAJ', str(rmaj))) filename = 'VFM_R%07i' % rmaj plot1.title = filename plot1.saveName = [filename + '.pdf', filename + '.png'] textToSet = 'focusing mirror\nmeridional radius\n$R =$ %.1f km'\ % (rmaj * 1e-5) textPanel1.set_text(textToSet) yield xrtr.run_ray_tracing(plot1, repeats=640, updateEvery=2, threads=threads, energyRange=[5998, 6002], generator=plot_generator, globalNorm=True, backend='shadow')
def main(): plot1 = xrtp.XYCPlot('star.03') plot1.xaxis.limits = [-15, 15] plot1.yaxis.limits = [-15, 15] plot1.yaxis.factor *= -1 textPanel = plot1.fig.text(0.88, 0.8, '', transform=plot1.fig.transFigure, size=14, color='r', ha='center') #========================================================================== threads = 4 #========================================================================== start01 = shadow.files_in_tmp_subdirs('start.01', threads) start02 = shadow.files_in_tmp_subdirs('start.02', threads) start03 = shadow.files_in_tmp_subdirs('start.03', threads) shadow.modify_input(start01, ('THICK(1)', str(60 * 1e-4))) shadow.modify_input(start01, ('FILE_REFL', 'Rh_refl.dat')) shadow.modify_input(start02, ('F_CENTRAL', '0')) shadow.modify_input(start03, ('F_CENTRAL', '0')) def plot_generator(): for crystal in ['Si111', 'Si311']: theta0 = 19.234 theta1 = 19.246 if crystal == 'Si311': theta0 = np.arcsin(np.sin(theta0*np.pi/180) * np.sqrt(11.0/3)) * 180 / np.pi theta1 = np.arcsin(np.sin(theta1*np.pi/180) * np.sqrt(11.0/3)) * 180 / np.pi shadow.modify_input(start02, ('FILE_REFL', crystal + '.rc')) shadow.modify_input(start03, ('FILE_REFL', crystal + '.rc')) for theta in np.linspace(theta0, theta1, 7): shadow.modify_input(start02, ('T_INCIDENCE', str(90 - theta)), ('T_REFLECTION', str(90 - theta))) shadow.modify_input(start03, ('T_INCIDENCE', str(90 - theta)), ('T_REFLECTION', str(90 - theta))) filename = crystal + '_%5i' % (theta * 1e4) plot1.title = filename plot1.saveName = [filename + '.pdf', filename + '.png'] # plot1.persistentName = filename + '.pickle' textPanel.set_text( crystal + '\nBragg angle\n$\\theta =$ %.3f$^o$' % theta) yield 0 xrtr.run_ray_tracing( plot1, repeats=640, updateEvery=2, energyRange=[5998, 6003], generator=plot_generator, threads=threads, globalNorm=True, backend='shadow')
def define_plots(): plots = [] plot = xrtp.XYCPlot( 'beamFSMDCM', (1,), xaxis=xrtp.XYCAxis(r'$x$', 'mm'), yaxis=xrtp.XYCAxis(r'$z$', 'mm'), caxis=xrtp.XYCAxis('energy', 'eV'), title='DCM') plot.xaxis.limits = [-7., 7.] plot.yaxis.limits = [38.1-7., 38.1+7.] plot.fluxFormatStr = '%.1p' plot.textPanel = plot.fig.text(0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r', ha='center') plots.append(plot) for plot in plots: plot.caxis.limits = [E0 - dE, E0 + dE] plot.caxis.offset = E0 return plots
def define_plots(beamLine): plots = [] for ic, (fsmExpCenter, d) in enumerate(zip(beamLine.fsmExpCenters, dFocus)): plot = xrtp.XYCPlot('beamFSMExp{0:02d}'.format(ic), (1, ), aspect='auto', xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=64, ppb=4), yaxis=xrtp.XYCAxis(r'$z$', u'µm', bins=64, ppb=4), fluxKind='s', title='08i-ExpFocus-Is{0:02d}'.format(ic)) plot.xaxis.limits = [imageExtent[0], imageExtent[1]] plot.yaxis.limits = [imageExtent[2], imageExtent[3]] plot.textPanel = plot.fig.text(0.88, 0.8, u'f{0:+.0f} mm'.format(d), transform=plot.fig.transFigure, size=12, color='r', ha='center') plots.append(plot) ax = plot.xaxis edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins + 1) beamLine.fsmExpX = (edges[:-1] + edges[1:]) * 0.5 / ax.factor ax = plot.yaxis edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins + 1) beamLine.fsmExpZ = (edges[:-1] + edges[1:]) * 0.5 / ax.factor for plot in plots: plot.saveName = [ prefix + plot.title + '.png', ] if plot.caxis.label.startswith('energy'): plot.caxis.limits = E0 - dE * vFactor, E0 + dE * vFactor plot.caxis.offset = E0 if plot.fluxKind.startswith('power'): plot.fluxFormatStr = '%.0f' else: plot.fluxFormatStr = '%.1p' return plots
def define_plots(): plots = [] plot02 = xrtplot.XYCPlot(beam=r"FSMFootprint", xaxis=xrtplot.XYCAxis(fwhmFormatStr='%.2f', label=r"x", bins=512, ppb=1), yaxis=xrtplot.XYCAxis(fwhmFormatStr='%.2f', label=r"z", bins=512, ppb=1), caxis=xrtplot.XYCAxis(fwhmFormatStr="%.2f", label=r"energy", bins=512, ppb=1, unit=r"eV", limits=[9995, 10005]), aspect=r"auto", title=r"FSM Footprint", fluxFormatStr=r"%g") plots.append(plot02) return plots
def main(): plot1 = xrtp.XYCPlot('star.01') plot1.caxis.fwhmFormatStr = None plot1.xaxis.limits = [-15, 15] plot1.yaxis.limits = [-15, 15] textPanel = plot1.fig.text(0.88, 0.8, '', transform=plot1.fig.transFigure, size=14, color='r', ha='center') #========================================================================== processes = 4 #========================================================================== start01 = shadow.files_in_tmp_subdirs('start.01', processes) def plot_generator(): for i, thick in enumerate([0, 60, 400, 1000, 1500]): # for i, thick in enumerate([0, ]): shadow.modify_input(start01, ('THICK(1)', str(thick * 1e-4))) filename = 'filt%04imum' % thick plot1.title = filename plot1.saveName = [filename + '.pdf', filename + '.png'] textPanel.set_text('filter\nthickness\n%s $\mu$m' % thick) yield 0 xrtr.run_ray_tracing([ plot1, ], repeats=160, updateEvery=2, backend='shadow', energyRange=[2400, 22400], generator=plot_generator, processes=processes, globalNorm=True)
def define_plots(beamLine): plots = [] plotsE = [] xaxis = xrtp.XYCAxis(r'$x$', 'mm', limits=xlimits, bins=360, ppb=1) yaxis = xrtp.XYCAxis(r'$z$', 'mm', limits=zlimits, bins=360, ppb=1) caxis = xrtp.XYCAxis('energy', 'keV', bins=360, ppb=1) plot = xrtp.XYCPlot('beamFSM1', (1, ), xaxis=xaxis, yaxis=yaxis, caxis=caxis, aspect='auto', title='total flux', ePos=1) plot.baseName = prefix + '1TotalFlux' plot.saveName = plot.baseName + '.png' plots.append(plot) plotsE.append(plot) for plot in plotsE: plot.caxis.limits = eMin * 1e-3, eMax * 1e-3 for plot in plots: plot.fluxFormatStr = '%.2p' return plots, plotsE