def main(): myBalder = build_beamline() align_beamline(myBalder) plots = define_plots(myBalder) xrtr.run_ray_tracing( plots, repeats=16, generator=plot_generator, beamLine=myBalder, globalNorm=True, processes='half')
def ray_trace(und_x, und_xp, und_y, und_yp, und_z, p1h_x, p1h_z, m1h_x, m1h_alpha, m1h_z, p2h_x, p2h_z, m2h_x, m2h_alpha, m2h_z, p3h_x, p3h_z, dg3_x, dg3_z, yag_sz, yag_res, ret_imgs=False): HOMS = build_beamline(und_x, und_xp, und_y, und_yp, und_z, p1h_x, p1h_z, m1h_x, m1h_alpha, m1h_z, p2h_x, p2h_z, m2h_x, m2h_alpha, m2h_z, p3h_x, p3h_z, dg3_x, dg3_z) E0 = list(HOMS.Source.energies)[0] align_beamline(HOMS, E0) plots = define_plots(yag_sz, yag_res, p1h_x, p2h_x, p3h_x, dg3_x) xrtrun.run_ray_tracing(plots=plots, backend=r"raycing", beamLine=HOMS) if ret_imgs: return [plot.total2D for plot in plots]
def main(): beamLine = build_beamline() plots, plotsFSM2 = define_plots(beamLine) xrtr.run_ray_tracing( plots, repeats=16, generator=plot_generator, generatorArgs=[plots, plotsFSM2, beamLine], updateEvery=1, beamLine=beamLine, processes='half')
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 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 main(): beamLine = build_beamline() if showIn3D: beamLine.glow(scale=[500, 10, 500], centerAt='warped') return plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, beamLine=beamLine)
def main(): beamLine = build_beamline() plots, plotsE, complexPlotsPCA = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, afterScript=afterScript, afterScriptArgs=[ plots, complexPlotsPCA, beamLine], beamLine=beamLine)
def main(): beamLine = build_beamline() plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=40, beamLine=beamLine, processes='half')
def get_efficiency(): beamLine = build_beamline() plots, plotsR = define_plots(beamLine) args = [plots, plotsR, beamLine] xrtr.run_ray_tracing(plots, repeats=2, beamLine=beamLine, processes=1, generator=plot_generator, generatorArgs=args, afterScript=afterScript)
def get_efficiency(): beamLine = build_beamline() xrtr.run_ray_tracing([], repeats=1, beamLine=beamLine, processes=1, generator=plot_generator, afterScript=afterScript)
def main(): beamLine = build_beamline() plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=1, updateEvery=1, beamLine=beamLine, processes=1)
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow() else: plots, plotsE = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=100, beamLine=beamLine, afterScript=afterScript, afterScriptArgs=[plots])
def main(): beamLine = build_beamline() plots, plotsE = define_plots(beamLine) xrtr.run_ray_tracing( plots, repeats=1, # afterScript=afterScript, afterScriptArgs=plots, beamLine=beamLine)
def main(): beamLine = build_beamline(azimuth=-2*pitch, nrays=10000) align_beamline(beamLine) plots, plotsMono, plotsFocus = define_plots(beamLine) args = [plots, plotsMono, plotsFocus, beamLine] xrtr.run_ray_tracing(plots, repeats=1, beamLine=beamLine, generator=plot_generator, generatorArgs=args, processes='half')
def main(): beamLine = build_beamline() plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=360, generator=plot_generator, beamLine=beamLine, processes='half')
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow(scale=[300, 3, 300], centerAt='VFM') return plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=40, beamLine=beamLine, processes='half')
def main(): beamLine = build_beamline() if showIn3D: beamLine.fsmExpX = np.linspace(-lim, lim, bins + 1) beamLine.fsmExpZ = np.linspace(-lim, lim, bins + 1) beamLine.glow() else: plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, beamLine=beamLine)
def main(): beamLine = build_beamline() if showIn3D: beamLine.fsmExpX = np.linspace(-lim, lim, bins+1) beamLine.fsmExpZ = np.linspace(-lim, lim, bins+1) beamLine.glow() else: plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, beamLine=beamLine)
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow(scale=[100, 10, 100], centerAt='FZP', colorAxis='xzprime') return plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=360, generator=plot_generator, beamLine=beamLine, processes='half')
def main(): beamLine = build_beamline() plots, plotsAnalyzer, plotsDetector, plotsE, plotAnE, plotDetE =\ define_plots(beamLine) args = [plots, plotsAnalyzer, plotsDetector, plotsE, plotAnE, plotDetE, beamLine] xrtr.run_ray_tracing( plots, generator=plot_generator, generatorArgs=args, beamLine=beamLine, processes='half')
def run_it(self): """ Runs the whole operation """ self.make_it() # xrtr.run_ray_tracing(self.plots,\ repeats=self.repeats,\ beamLine=self.beamLine,\ processes=_processes)
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow() else: plots, plotsE = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=20, beamLine=beamLine, generator=plot_generator, threads=4, globalNorm=1)
def main(): beamLine = build_beamline() E0 = (Emin + Emax) * 0.5 align_beamline(beamLine, E0) plots = define_plots() xrtrun.run_ray_tracing(plots=plots, repeats=10, backend=r"raycing", beamLine=beamLine)
def main(): beamLine = build_beamline() plots, plotsAnalyzer, plotsDetector, plotsE, plotAnE, plotDetE =\ define_plots(beamLine) args = [plots, plotsAnalyzer, plotsDetector, plotsE, plotAnE, plotDetE, beamLine] xrtr.run_ray_tracing( plots, generator=plot_generator, generatorArgs=args, beamLine=beamLine, updateEvery=4, threads=1, processes=4)
def main(): beamLine = build_beamline() E0 = list(beamLine.source.energies)[0] beamLine.alignE = E0 plots, plotPhaseSpaceBefore, plotPhaseSpaceAfter = define_plots(beamLine) xrtrun.run_ray_tracing( plots=plots, repeats=1, beamLine=beamLine, afterScript=afterScript, afterScriptArgs=[plotPhaseSpaceBefore, plotPhaseSpaceAfter, beamLine])
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow(centerAt='FZP') return plots, plotPos = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=60, beamLine=beamLine, processes='half', afterScript=afterScript, afterScriptArgs=[plotPos])
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow() else: plots, plotsE = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=1, # afterScript=afterScript, afterScriptArgs=plots, beamLine=beamLine)
def main(): myBalder = BalderBL.build_beamline( stripe=stripe, eMinRays=E0-dE, eMaxRays=E0+dE) if showIn3D: myBalder.glow(centerAt='VFM', startFrom=7, generator=plot_generator, generatorArgs=[[], myBalder]) return plots = define_plots() xrtr.run_ray_tracing(plots, repeats=16, generator=plot_generator, beamLine=myBalder, globalNorm=True, processes='half')
def main(): beamLine = build_beamline() E0 = (Emin+Emax)*0.5 align_beamline(beamLine, E0) plots = define_plots() xrtrun.run_ray_tracing( plots=plots, repeats=10, backend=r"raycing", beamLine=beamLine)
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow(scale=1e3, centerAt='CRL_Exit') return plots, plotsFSM2 = define_plots(beamLine) xrtr.run_ray_tracing( plots, repeats=16, generator=plot_generator, generatorArgs=[plots, plotsFSM2, beamLine], updateEvery=1, beamLine=beamLine, processes='half')
def main(): beamLine = build_beamline(azimuth=-2 * pitch) align_beamline(beamLine) plots, toSave = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, beamLine=beamLine, afterScript=afterScript, afterScriptArgs=[toSave], processes=1)
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow(scale=[30, 3, 30], centerAt='LaueDCM1', startFrom=1, generator=plot_generator, generatorArgs=[[], beamLine]) return plots = define_plots(beamLine) xrtr.run_ray_tracing( plots, repeats=36, generator=plot_generator, beamLine=beamLine, processes='half')
def main(): beamLine = build_beamline() plots, plotsFSM2 = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=16, generator=plot_generator, generatorArgs=[plots, plotsFSM2, beamLine], updateEvery=1, beamLine=beamLine, processes='half')
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow(scale=[30, 3, 30], centerAt='LaueSCM', startFrom=1, generator=plot_generator, generatorArgs=[[], beamLine]) return plots = define_plots(beamLine) xrtr.run_ray_tracing( plots, repeats=360, generator=plot_generator, beamLine=beamLine, processes='half')
def main(): beamLine = build_beamline(azimuth=-2*pitch) align_beamline(beamLine) if showIn3D: # beamLine.orient_along_global_Y() beamLine.glow(scale=[100, 10, 1000], centerAt='M2') return plots, toSave = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, beamLine=beamLine, afterScript=afterScript, afterScriptArgs=[toSave], processes=1)
def main(): myBalder = build_beamline(stripe=stripe, eMinRays=E0 - dE, eMaxRays=E0 + dE) plots = define_plots() xrtr.run_ray_tracing(plots, repeats=16, generator=plot_generator, beamLine=myBalder, globalNorm=True, processes='half')
def main(): myBalder = BalderBL.build_beamline() BalderBL.align_beamline(myBalder) if showIn3D: myBalder.glow(centerAt='Filter1_Entrance', startFrom=1, generator=plot_generator, generatorArgs=[[], myBalder]) return plots = define_plots(myBalder) xrtr.run_ray_tracing( plots, repeats=16, generator=plot_generator, beamLine=myBalder, globalNorm=True, processes='half')
def main(): beamLine = build_beamline(azimuth=-2*pitch) align_beamline(beamLine) if showIn3D: # beamLine.orient_along_global_Y() beamLine.glow(scale=[100, 10, 1000], centerAt='M2') return plots, complexPlotsIs, complexPlotsDs = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, beamLine=beamLine, afterScript=afterScript, afterScriptArgs=[complexPlotsIs, complexPlotsDs], processes=1)
def main(): beamLine = build_beamline(azimuth=-2 * pitch) align_beamline(beamLine) plots, complexPlotsIs, complexPlotsEs, complexPlotsPCAs =\ define_plots(beamLine) xrtr.run_ray_tracing( plots, repeats=repeats, beamLine=beamLine, afterScript=afterScript, afterScriptArgs=[complexPlotsIs, complexPlotsEs, complexPlotsPCAs], processes=1)
def main(): beamLine = build_beamline() if showIn3D: beamLine.glow(scale=[3e2, 3, 3e2], centerAt='QWP', startFrom=-4, generator=plot_generator, generatorArgs=[[], beamLine], colorAxis='circular_polarization_rate', colorAxisLimits=[-1, 1]) return plots = define_plots(beamLine) xrtr.run_ray_tracing( plots, repeats=24, generator=plot_generator, beamLine=beamLine, globalNorm=True, processes='half')
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 main(): beamLine = build_beamline() if showIn3D: beamLine.glow(scale=4, centerAt=analyzerName, generator=plot_generator, generatorArgs=[beamLine]) return plots, plotsAnalyzer, plotsDetector, plotsE, plotDetE = \ define_plots(beamLine) args = [beamLine, plots, plotsAnalyzer, plotsDetector, plotsE, plotDetE] xrtr.run_ray_tracing( plots, generator=plot_generator, generatorArgs=args, beamLine=beamLine, processes='half')
def main(): beamLine = build_beamline() if showIn3D: beamLine.fsmExpX = np.linspace(xlimits[0], xlimits[1], bins+1) beamLine.fsmExpZ = np.linspace(zlimits[0], xlimits[1], bins+1) beamLine.glow() else: plots, plotsE, complexPlotsPCA = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, afterScript=afterScript, afterScriptArgs=[ plots, complexPlotsPCA, beamLine], beamLine=beamLine)
def run_it(self): """ Prepares plots """ self.make_it() # We want to go through the whole beam # Provide shorter beam if You fancy otherwise _repeats = np.ceil(self.source_beam.x.size / self.beam_chunk_size) xrtr.run_ray_tracing(self.plots, repeats=_repeats,\ beamLine=self.beamLine,\ processes=_processes)
def main(): P02_2 = build_beamline() plots = define_plots() xrtrun.run_ray_tracing( plots=plots, generator=plot_generator, generatorArgs=[P02_2, plots], repeats=10, # pickleEvery=5, # analysis:ignore backend=r"raycing", beamLine=P02_2, afterScript=plotJet, afterScriptArgs=[plots])
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 main(pitch, fixedExit, hkl, stripe, eMinRays, eMaxRays, eTune, vfmR, prefix): myBalder = BalderBL.build_beamline(100000, hkl, stripe, eMinRays, eMaxRays) BalderBL.align_beamline( myBalder, pitch=pitch, energy=eTune, fixedExit=fixedExit, vfmR=vfmR) suffix = '' #= touch the beam with the EH slit: =========================================== # note that for using `touch_beam` the beams must exist, therefore you should # run the source shrinkage above or `run_process` below this line. # BalderBL.run_process(myBalder) # myBalder.slitEH.touch_beam(myBalder.beams['beamVFMglobal']) if showIn3D: myBalder.glow(centerAt='VFM') return plots = define_plots(myBalder, prefix, suffix) xrtr.run_ray_tracing(plots, repeats=1, beamLine=myBalder, processes=4)
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 main(): beamLine = build_beamline(azimuth=-2*pitch) align_beamline(beamLine) plots = define_plots(beamLine) xrtr.run_ray_tracing(plots, repeats=repeats, beamLine=beamLine)
def main(): beamLine, fName = build_beamline() plots = define_plots(beamLine, fName) xrtr.run_ray_tracing(plots, repeats=40, updateEvery=1, beamLine=beamLine, processes='half')