Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def define_plots(bl):
    plots = []
    for screen in bl.screens:
        saveName = ('./plots/' + subfolder + save_prefix + screen.name + '_y' +
                    str(int(screen.center[1])) + save_suffix + '.png')
        if 'focus' in screen.name:
            plot = XYCPlot(beam=screen.name,
                           xaxis=xrtplot.XYCAxis(label="x",
                                                 fwhmFormatStr='%.3f'),
                           yaxis=xrtplot.XYCAxis(label="z",
                                                 fwhmFormatStr='%.3f'),
                           caxis=xrtplot.XYCAxis(label="energy",
                                                 unit=r"eV",
                                                 offset=E0,
                                                 fwhmFormatStr='%.4f'),
                           title=screen.name + '_y' +
                           str(int(screen.center[1])),
                           saveName=str(saveName),
                           aspect='auto')
        else:
            plot = XYCPlot(beam=screen.name,
                           xaxis=xrtplot.XYCAxis(label="x",
                                                 fwhmFormatStr='%.3f'),
                           yaxis=xrtplot.XYCAxis(label="z",
                                                 fwhmFormatStr='%.3f'),
                           caxis=xrtplot.XYCAxis(label="energy",
                                                 unit=r"eV",
                                                 offset=E0,
                                                 fwhmFormatStr='%.4f'),
                           title=screen.name + '_y' +
                           str(int(screen.center[1])),
                           saveName=str(saveName))
        plots.append(plot)

        if do_plot == 'all':
            saveName = ('./plots/' + subfolder + save_prefix + screen.name +
                        '_y' + str(int(screen.center[1])) + '_divVsE' +
                        save_suffix + '.png')
            plot = XYCPlot(beam=screen.name,
                           xaxis=xrtplot.XYCAxis(label="energy",
                                                 unit="eV",
                                                 offset=E0),
                           yaxis=xrtplot.XYCAxis(label="z'",
                                                 unit="urad",
                                                 factor=1E6),
                           caxis=xrtplot.XYCAxis(
                               label="energy",
                               unit="eV",
                               offset=E0,
                               fwhmFormatStr='%.4f',
                           ),
                           aspect='auto',
                           title=screen.name + '_y' +
                           str(int(screen.center[1])),
                           saveName=saveName)
            plots.append(plot)
    return plots
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
Archivo: warp.py Proyecto: wholden/xrt
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
def main():
    beamLine = build_beamline()
    fwhmFormatStrE = '%.2f'
    plots = []

    plot = xrtp.XYCPlot('beamFSM1', caxis='category')
    plots.append(plot)

    for i, dy in enumerate(beamLine.fsm2dY):
        if i == len(beamLine.fsm2dY) // 2:
            limits = limZoom
            unit = 'fm'
        else:
            limits = lim
            unit = u'mm'
        xaxis = xrtp.XYCAxis(r'$x$', unit, limits=limits)
        yaxis = xrtp.XYCAxis(r'$z$', unit, limits=limits)
        plot = xrtp.XYCPlot('beamFSM2-{0:d}'.format(i + 1),
                            xaxis=xaxis,
                            yaxis=yaxis,
                            caxis='category')
        plots.append(plot)

    for plot in plots:
        plot.caxis.fwhmFormatStr = fwhmFormatStrE
        plot.xaxis.fwhmFormatStr = fwhmFormatStrE
        plot.yaxis.fwhmFormatStr = fwhmFormatStrE
        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)
Ejemplo n.º 11
0
def define_plots(beamLine):
    plots = []

    limitsFSM = -15, 15
    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
    plot1.textPanel = plot1.fig.text(0.86,
                                     0.8,
                                     '',
                                     transform=plot1.fig.transFigure,
                                     size=14,
                                     color='r',
                                     ha='center')
    plots.append(plot1)

    plot = xrtp.XYCPlot('beamLaueDCMlocal1', (1, ),
                        xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=limitsFSM),
                        yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=limitsFSM),
                        ePos=1,
                        title=beamLine.laueDCM1.name + '_E')
    plot.caxis.invertAxis = True
    plots.append(plot)

    plot = xrtp.XYCPlot('beamLaueDCMlocal2', (1, ),
                        xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=limitsFSM),
                        yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=limitsFSM),
                        ePos=1,
                        title=beamLine.laueDCM2.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', limits=limitsFSM),
                         ePos=1,
                         title=beamLine.fsm2.name + '_E')
    plot2.caxis.invertAxis = True
    plot2.textPanel = plot2.fig.text(0.86,
                                     0.8,
                                     '',
                                     transform=plot2.fig.transFigure,
                                     size=14,
                                     color='r',
                                     ha='center')
    plots.append(plot2)

    return plots
Ejemplo n.º 12
0
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
Ejemplo n.º 13
0
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
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
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():
    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
Ejemplo n.º 17
0
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
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
Ejemplo n.º 19
0
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
Ejemplo n.º 20
0
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
Ejemplo n.º 21
0
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
Ejemplo n.º 22
0
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
Ejemplo n.º 23
0
def define_plots(bl):
    plots = []
    for screen in bl.screens:
        # x-z plot:
        saveName = './plots/dist_' + str(int(
            D / 1000)) + '_' + screen.name + '.png'
        plot = XYCPlot(beam=screen.name,
                       xaxis=xrtplot.XYCAxis(label="x", fwhmFormatStr='%.3f'),
                       yaxis=xrtplot.XYCAxis(label="z", fwhmFormatStr='%.3f'),
                       caxis=xrtplot.XYCAxis(label="energy",
                                             unit=r"eV",
                                             offset=E0,
                                             fwhmFormatStr='%.4f'),
                       title=screen.name + '_y' + str(int(screen.center[1])),
                       saveName=str(saveName))
        plots.append(plot)
        # E-z' plot:
        saveName = './plots/dist_' + str(int(
            D / 1000)) + '_' + screen.name + '._div.png'
        plot = XYCPlot(beam=screen.name,
                       xaxis=xrtplot.XYCAxis(label="energy",
                                             unit="eV",
                                             offset=E0),
                       yaxis=xrtplot.XYCAxis(label="z'",
                                             unit="urad",
                                             factor=1E6),
                       caxis=xrtplot.XYCAxis(
                           label="energy",
                           unit="eV",
                           offset=E0,
                           fwhmFormatStr='%.4f',
                       ),
                       title=screen.name + '_y' + str(int(screen.center[1])),
                       saveName=saveName,
                       aspect='auto')
        plots.append(plot)
    return plots
def define_plots(bl):
    plots = []
    for screen in bl.screens:
        saveName = ('./plots/' + screen.name + '_y' + str(int(screen.center[1]))
            + save_suffix + '.png')
        plot = XYCPlot(beam=screen.name,
            xaxis=xrtplot.XYCAxis(label="x"),
            yaxis=xrtplot.XYCAxis(label="z"),
            caxis=xrtplot.XYCAxis(label="energy",unit=r"eV", offset=E0),
            title=screen.name+ '_y' + str(int(screen.center[1])),
            saveName=str(saveName))
        plots.append(plot)
        
        saveName = ('./plots/' + screen.name + '_y' + str(int(screen.center[1]))
            + '_divVsE' + save_suffix + '.png')
        plot = XYCPlot(beam=screen.name,
            xaxis=xrtplot.XYCAxis(label="energy", unit="eV", offset=E0),
            yaxis=xrtplot.XYCAxis(label="z'", unit="rad"),
            caxis=xrtplot.XYCAxis(label="energy",unit="eV", offset=E0),
            aspect='auto',
            title=screen.name+ '_y' + str(int(screen.center[1])),
            saveName=saveName)
        plots.append(plot)
    return plots
Ejemplo n.º 25
0
def define_plots(beamLine):
    plots = []

    ePos = 1 if xbins < 4 else 2
    caxis = xrtp.XYCAxis('energy', 'eV', bins=cbins, ppb=cppb)
    plot = xrtp.XYCPlot('beamFSM0', (1, ),
                        xaxis=xrtp.XYCAxis(r'$x$', 'mm', bins=xbins, ppb=xppb),
                        yaxis=xrtp.XYCAxis(r'$z$', 'mm', bins=zbins, ppb=zppb),
                        caxis=caxis,
                        ePos=ePos,
                        title='00-FE')
    plot.xaxis.fwhmFormatStr = '%.3f'
    plot.yaxis.fwhmFormatStr = '%.3f'
    plots.append(plot)

    ePos = 1 if zbins < 4 else 2
    caxis = xrtp.XYCAxis('energy', 'eV', bins=cbins, ppb=cppb)
    plot = xrtp.XYCPlot('beamM1local', (1, ),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$',
                                           'mm',
                                           bins=zbins,
                                           ppb=zppb,
                                           limits=beamLine.m1.limPhysX),
                        yaxis=xrtp.XYCAxis(r'$y$',
                                           'mm',
                                           bins=xbins,
                                           ppb=xppb,
                                           limits=beamLine.m1.limPhysY),
                        caxis=caxis,
                        ePos=ePos,
                        title='01-M1local')
    plots.append(plot)

    ePos = 1 if xbins < 4 else 2
    caxis = xrtp.XYCAxis('energy', 'eV', bins=cbins, ppb=cppb)
    plot = xrtp.XYCPlot('beamM2local', (1, ),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$',
                                           'mm',
                                           bins=xbins,
                                           ppb=xppb,
                                           limits=beamLine.m2.limPhysX),
                        yaxis=xrtp.XYCAxis(r'$y$',
                                           'mm',
                                           bins=zbins,
                                           ppb=zppb,
                                           limits=beamLine.m2.limPhysY),
                        caxis=caxis,
                        ePos=ePos,
                        title='02-M2local')
    plots.append(plot)

    ePos = 1 if xbins < 4 else 2
    caxis = xrtp.XYCAxis('energy', 'eV', bins=cbins, ppb=cppb)
    plot = xrtp.XYCPlot('beamPGlocal', (1, ),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$',
                                           'mm',
                                           bins=xbins,
                                           ppb=xppb,
                                           limits=beamLine.pg.limPhysX),
                        yaxis=xrtp.XYCAxis(r'$y$',
                                           'mm',
                                           bins=zbins,
                                           ppb=zppb,
                                           limits=beamLine.pg.limPhysY),
                        caxis=caxis,
                        ePos=ePos,
                        title='02-PGlocal')
    plots.append(plot)

    ePos = 1 if zbins < 4 else 2
    caxis = xrtp.XYCAxis('energy', 'eV', bins=cbins, ppb=cppb)
    plot = xrtp.XYCPlot('beamM3local', (1, ),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$',
                                           'mm',
                                           bins=zbins,
                                           ppb=zppb,
                                           limits=beamLine.m3.limPhysX),
                        yaxis=xrtp.XYCAxis(r'$y$',
                                           'mm',
                                           bins=xbins,
                                           ppb=xppb,
                                           limits=beamLine.m3.limPhysY),
                        caxis=caxis,
                        ePos=ePos,
                        title='03-M3local')
    plots.append(plot)

    ePos = 1 if zbins < 4 else 2
    caxis = xrtp.XYCAxis('Ep phase',
                         '',
                         bins=cbins,
                         ppb=cppb,
                         data=raycing.get_Ep_phase,
                         limits=[-np.pi, np.pi])
    plot = xrtp.XYCPlot('beamM3local', (1, ),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$',
                                           'mm',
                                           bins=zbins,
                                           ppb=zppb,
                                           limits=beamLine.m3.limPhysX),
                        yaxis=xrtp.XYCAxis(r'$y$',
                                           'mm',
                                           bins=xbins,
                                           ppb=xppb,
                                           limits=beamLine.m3.limPhysY),
                        caxis=caxis,
                        ePos=ePos,
                        title='03s-M3local')
    plots.append(plot)

    limMaxX = ESdX * 0.6e3
    limMaxZ = ESdZ * 0.6e3
    ePos = 1 if xbins < 4 else 2
    caxis = xrtp.XYCAxis('energy', 'eV', bins=cbins, ppb=cppb)
    plot = xrtp.XYCPlot('beamExitSlit', (1, beamLine.exitSlit.lostNum),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=xbins,
                                           ppb=xppb),
                        yaxis=xrtp.XYCAxis(r'$z$', u'µm', bins=zbins,
                                           ppb=zppb),
                        caxis=caxis,
                        ePos=ePos,
                        title='04-ExitSlit')
    plot.xaxis.limits = -limMaxX, limMaxX
    plot.yaxis.limits = -limMaxZ, limMaxZ
    plots.append(plot)

    ePos = 1 if xbins < 4 else 2
    caxis = xrtp.XYCAxis('Es phase',
                         '',
                         bins=cbins,
                         ppb=cppb,
                         data=raycing.get_Es_phase,
                         limits=[-np.pi, np.pi])
    plot = xrtp.XYCPlot('beamExitSlit', (1, ),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=xbins,
                                           ppb=xppb),
                        yaxis=xrtp.XYCAxis(r'$z$', u'µm', bins=zbins,
                                           ppb=zppb),
                        caxis=caxis,
                        ePos=ePos,
                        title='04s-ExitSlit')
    plot.xaxis.limits = -limMaxX, limMaxX
    plot.yaxis.limits = -limMaxZ, limMaxZ
    plots.append(plot)

    ePos = 1 if zbins < 4 else 2
    caxis = xrtp.XYCAxis('energy', 'eV', bins=cbins, ppb=cppb)
    plot = xrtp.XYCPlot('beamM4local', (1, ),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$',
                                           'mm',
                                           bins=zbins,
                                           ppb=zppb,
                                           limits=beamLine.m4.limPhysX),
                        yaxis=xrtp.XYCAxis(r'$y$',
                                           'mm',
                                           bins=xbins,
                                           ppb=xppb,
                                           limits=beamLine.m4.limPhysY),
                        caxis=caxis,
                        ePos=ePos,
                        title='05-M4local')
    plots.append(plot)

    ePos = 1 if xbins < 4 else 2
    caxis = xrtp.XYCAxis('energy', 'eV', bins=cbins, ppb=cppb)
    plot = xrtp.XYCPlot('beamM5local', (1, ),
                        aspect='auto',
                        xaxis=xrtp.XYCAxis(r'$x$',
                                           'mm',
                                           bins=xbins,
                                           ppb=xppb,
                                           limits=beamLine.m5.limPhysX),
                        yaxis=xrtp.XYCAxis(r'$y$',
                                           'mm',
                                           bins=zbins,
                                           ppb=zppb,
                                           limits=beamLine.m5.limPhysY),
                        caxis=caxis,
                        ePos=ePos,
                        title='06-M5local')
    plots.append(plot)

    complexPlotsDs = []
    complexPlotsXs = []
    for ic, (fsmExpCenter, d) in enumerate(zip(beamLine.fsmExpCenters,
                                               dFocus)):
        ePos = 1 if xebins < 4 else 2
        caxis = xrtp.XYCAxis('energy', 'eV', bins=cebins, ppb=ceppb)
        plot = xrtp.XYCPlot('beamFSMExp{0:02d}'.format(ic), (1, ),
                            aspect='auto',
                            xaxis=xrtp.XYCAxis(r'$x$',
                                               u'µm',
                                               bins=xebins,
                                               ppb=xeppb,
                                               limits=[-expSize, expSize]),
                            yaxis=xrtp.XYCAxis(r'$z$',
                                               u'µm',
                                               bins=zebins,
                                               ppb=zeppb,
                                               limits=[-expSize, expSize]),
                            caxis=caxis,
                            fluxKind='Es',
                            ePos=ePos,
                            title='08e-ExpFocus{0:02d}'.format(ic))
        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)
        complexPlotsDs.append(plot)
        fsmExpPlot = plot

        ePos = 1 if xebins < 4 else 2
        caxis = xrtp.XYCAxis('energy', 'eV', bins=cebins, ppb=ceppb)
        if 'hor' in cut:
            xaxis = xrtp.XYCAxis(r'$x$',
                                 u'µm',
                                 bins=xebins,
                                 ppb=xeppb,
                                 limits=[-expSize, expSize])
            yaxis = xrtp.XYCAxis(r'$x$',
                                 u'µm',
                                 bins=xebins,
                                 ppb=xeppb,
                                 limits=[-expSize, expSize])
        elif 'ver' in cut:
            xaxis = xrtp.XYCAxis(r'$z$',
                                 u'µm',
                                 bins=zebins,
                                 ppb=zeppb,
                                 limits=[-expSize, expSize])
            yaxis = xrtp.XYCAxis(r'$z$',
                                 u'µm',
                                 bins=zebins,
                                 ppb=zeppb,
                                 limits=[-expSize, expSize])
        plot = xrtp.XYCPlot('beamFSMExp{0:02d}'.format(ic), (1, ),
                            aspect='auto',
                            xaxis=xaxis,
                            yaxis=yaxis,
                            caxis=caxis,
                            fluxKind='Esxx',
                            ePos=ePos,
                            title='08x-ExpFocus{0:02d}'.format(ic))
        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)
        complexPlotsXs.append(plot)

        ePos = 1 if xebins < 4 else 2
        caxis = xrtp.XYCAxis(
            'Es phase',
            '',
            bins=cebins,
            ppb=ceppb,
            data=raycing.get_Es_phase,
            #density='kde',
            limits=[-np.pi, np.pi])
        plot = xrtp.XYCPlot('beamFSMExp{0:02d}'.format(ic), (1, ),
                            aspect='auto',
                            xaxis=xrtp.XYCAxis(r'$x$',
                                               u'µm',
                                               bins=xebins,
                                               ppb=xeppb,
                                               limits=[-expSize, expSize]),
                            yaxis=xrtp.XYCAxis(r'$z$',
                                               u'µm',
                                               bins=zebins,
                                               ppb=zeppb,
                                               limits=[-expSize, expSize]),
                            caxis=caxis,
                            ePos=ePos,
                            title='08p-ExpFocusPhase{0:02d}'.format(ic))
        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')
        plot.caxis.fwhmFormatStr = None
        plots.append(plot)

        if what != 'rays':
            ePos = 1 if xebins < 4 else 2
            caxis = xrtp.XYCAxis(
                'Es phase',
                '',
                bins=cebins,
                ppb=ceppb,
                data=raycing.get_Es_phase,
                #density='kde',
                limits=[-np.pi, np.pi])
            plot = xrtp.XYCPlot(
                'beamFSMExpFront{0:02d}'.format(ic), (1, ),
                aspect='auto',
                xaxis=xrtp.XYCAxis(r'$x$',
                                   u'µm',
                                   bins=xebins,
                                   ppb=xeppb,
                                   limits=[-expSize, expSize]),
                yaxis=xrtp.XYCAxis(r'$z$',
                                   u'µm',
                                   bins=zebins,
                                   ppb=zeppb,
                                   limits=[-expSize, expSize]),
                caxis=caxis,
                ePos=ePos,
                title='08pf-ExpFocusPhaseFront{0:02d}'.format(ic))
            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')
            #            plot.caxis.fwhmFormatStr = '%.3f'
            plot.caxis.fwhmFormatStr = None
            plots.append(plot)

    ax = fsmExpPlot.xaxis
    edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins + 1)
    beamLine.fsmExpX = (edges[:-1] + edges[1:]) * 0.5 / ax.factor
    #    print('d beamLine.fsmExpX', beamLine.fsmExpX[1]-beamLine.fsmExpX[0])
    ax = fsmExpPlot.yaxis
    edges = np.linspace(ax.limits[0], ax.limits[1], ax.bins + 1)
    beamLine.fsmExpZ = (edges[:-1] + edges[1:]) * 0.5 / ax.factor
    #    print('d beamLine.fsmExpZ', beamLine.fsmExpZ[1]-beamLine.fsmExpZ[0])

    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'
        if plot.xaxis.bins < 4:
            plot.ax2dHist.xaxis.set_ticks([0])
            plot.xaxis.fwhmFormatStr = None
            plot.ax1dHistX.set_visible(False)
        if plot.yaxis.bins < 4:
            plot.ax2dHist.yaxis.set_ticks([0])
            plot.yaxis.fwhmFormatStr = None
            plot.ax1dHistY.set_visible(False)

    toSave = [
        complexPlotsDs, complexPlotsXs, beamLine.waveOnSampleA,
        beamLine.waveOnSampleB, beamLine.waveOnSampleC
    ]
    lents = len(toSave[0])
    for ts in toSave[1:]:
        if len(ts) != lents:
            raise ValueError("cannot save the output!")
    return plots, toSave
Ejemplo n.º 26
0
def define_plots(beamLine):
    dE = beamLine.sources[0].energies[-1] - beamLine.sources[0].energies[0]
    midE = \
        (beamLine.sources[0].energies[-1] + beamLine.sources[0].energies[0])/2
    if dE < midE / 20.:
        fwhmFormatStrE = '%.2f'
        offsetE = E0
    else:
        fwhmFormatStrE = None
        offsetE = 0
    plots = []

#    plot = xrtp.XYCPlot('beamFSM1', (1,),
#      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-20, 20]),
#      yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-20, 20]),
#      ePos=1, title=beamLine.fsm1.name+'_E')
#    plot.caxis.fwhmFormatStr = fwhmFormatStrE
#    plot.caxis.limits = eLimits
#    plot.caxis.offset = offsetE
#    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('beamVFMlocal', (1,2), aspect='auto',
#      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-20, 20]),
#      yaxis=xrtp.XYCAxis(r'$y$', 'mm'),
#      title='VFM_footprint')
#    plots.append(plot)

#    plot = xrtp.XYCPlot('beamQWPlocal', (1,2),
#      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-10, 10]),
#      yaxis=xrtp.XYCAxis(r'$y$', 'mm'),
#      title='QWP_footprint')
#    plots.append(plot)

    plot = xrtp.XYCPlot(
        'beamFSM2', (1,),
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-0.15, 0.15]),
        yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.15, 0.15]),
        ePos=1, title=beamLine.fsm2.name+'_E')
    plot.caxis.fwhmFormatStr = fwhmFormatStrE
    plot.caxis.limits = eLimits
    plot.caxis.offset = offsetE
    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('beamFSM2', (1,),
#      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-0.15, 0.15]),
#      yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.15, 0.15]),
#      caxis=xrtp.XYCAxis('degree of polarization', '',
#      data=raycing.get_polarization_degree, limits=[0, 1]),
#      ePos=1, title=beamLine.fsm2.name+'_DegreeOfPol')
#    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(
        'beamFSM2', (1,),
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-0.15, 0.15]),
        yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.15, 0.15]),
        caxis=xrtp.XYCAxis('circular polarization rate', '',
                           data=raycing.get_circular_polarization_rate,
                           limits=[-1, 1]),
        ePos=1, title=beamLine.fsm2.name+'_CircPolRate')
    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(
        'beamFSM2', (1,),
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-0.15, 0.15]),
        yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.15, 0.15]),
        caxis=xrtp.XYCAxis('ratio of ellipse axes', '',
                           data=raycing.get_ratio_ellipse_axes,
                           limits=[-1, 1]),
        ePos=1, title=beamLine.fsm2.name+'_PolAxesRatio')
    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('beamFSM2', (1,),
#      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-0.15, 0.15]),
#      yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.15, 0.15]),
#      caxis=xrtp.XYCAxis('angle of polarization ellipse', 'rad',
#      data=raycing.get_polarization_psi, limits=[-math.pi/2, math.pi/2]),
#      ePos=1, title=beamLine.fsm2.name+'_PolPsi')
#    plot.ax1dHistE.set_yticks(
#        (-math.pi/2, -math.pi/4, 0, math.pi/4, math.pi/2))
#    plot.ax1dHistE.set_yticklabels((r'-$\frac{\pi}{2}$', r'-$\frac{\pi}{4}$',
#      '0', r'$\frac{\pi}{4}$', r'$\frac{\pi}{2}$'))
#    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(
        'beamFSM2', (1,),
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-0.15, 0.15]),
        yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.15, 0.15]),
        caxis=xrtp.XYCAxis('phase shift', '',
                           data=raycing.get_phase_shift,
                           limits=[-1, 1]),  # limits are in units of pi!
        ePos=1, title=beamLine.fsm2.name+'_PhaseShift')
    formatter = mpl.ticker.FormatStrFormatter('%g' + r'$ \pi$')
    plot.ax1dHistE.yaxis.set_major_formatter(formatter)
    plot.textPanel = plot.fig.text(
        0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r',
        ha='center')
    plots.append(plot)
    return plots
Ejemplo n.º 27
0
def define_plots(screen_names,
                 mode=['X', 'E', 'Zp', 'EZp', 'D'],
                 step=None,
                 step2=None):

    plots = []
    if step is not None and step2 is not None:
        save_ext = f'_{step:.3f}_{step2:.3f}.png'
    elif step is not None:
        save_ext = f'_{step:.3f}.png'
    else:
        save_ext = '.png'

    for od in screen_names:
        if 'X' in mode:
            plots.append(
                xrtplot.XYCPlot(od,
                                aspect='auto',
                                yaxis=xrtplot.XYCAxis("z", "mm", bins=fig_bin),
                                xaxis=xrtplot.XYCAxis("x", "mm", bins=fig_bin),
                                saveName=f'{fig_dir}{title}_X_{od}{save_ext}'))
        if 'E' in mode:
            plots.append(
                xrtplot.XYCPlot(od,
                                aspect='auto',
                                yaxis=xrtplot.XYCAxis("z", "mm", bins=fig_bin),
                                xaxis=xrtplot.XYCAxis("energy",
                                                      "eV",
                                                      bins=fig_bin),
                                saveName=f'{fig_dir}{title}_E_{od}{save_ext}'))

        if 'Zp' in mode:
            plots.append(
                xrtplot.XYCPlot(
                    od,
                    aspect='auto',
                    yaxis=xrtplot.XYCAxis("z", "mm", bins=fig_bin),
                    xaxis=xrtplot.XYCAxis("z'", "µrad", bins=fig_bin),
                    saveName=f'{fig_dir}{title}_Zp_{od}{save_ext}'))

        if 'EZp' in mode:
            plots.append(
                xrtplot.XYCPlot(
                    od,
                    aspect='auto',
                    yaxis=xrtplot.XYCAxis("energy", "eV", bins=fig_bin),
                    xaxis=xrtplot.XYCAxis("z'", "µrad", bins=fig_bin),
                    saveName=f'{fig_dir}{title}_EZp_{od}{save_ext}'))

        if 'D' in mode:
            plots.append(
                xrtplot.XYCPlot(
                    od,
                    aspect='auto',
                    yaxis=xrtplot.XYCAxis(
                        "z",
                        "mm",
                        ppb=1,
                        bins=det_pix,
                        #                                               limits=[-det_dim, det_dim]),
                        limits=[-5.15, 6]),
                    xaxis=xrtplot.XYCAxis(
                        "x",
                        "mm",
                        ppb=1,
                        bins=det_pix,
                        #                                               limits=[-det_dim, det_dim]),
                        limits=[-7, 7]),
                    saveName=f'{fig_dir}{title}_D_{od}{save_ext}'))

    for plot in plots:

        sn = plot.saveName[:-4].split('/')[-1]
        od = sn.split('_')[2]
        pm = sn.split('_')[1]

        if od == 'S0':
            if pm == 'E':
                plot.xaxis.limits = [E0 - 0.01, E0 + 0.01]
                plot.xaxis.offset = E0
        if od == 'S2':
            if pm == 'EZp':
                plot.yaxis.limits = [E0 - dE, E0 + dE]
                plot.xaxis.limits = [-800, 800]
            else:
                plot.yaxis.limits = [-60, 60]
            if pm == 'X':
                plot.xaxis.limits = [-60, 60]
            if pm == 'E':
                plot.xaxis.limits = [E0 - dE, E0 + dE]
            if pm == 'Zp':
                plot.xaxis.limits = [-800, 800]

        if od == 'S3':
            if pm == 'EZp':
                plot.yaxis.limits = [E0 - 2 * dE, E0 + 2 * dE]
                plot.xaxis.limits = [-1200, 1200]
            else:
                plot.yaxis.limits = [-3.5, 3.5]
            if pm == 'X':
                plot.xaxis.limits = [-7, 7]
            if pm == 'E':
                plot.xaxis.limits = [E0 - 0.1, E0 + 0.1]
            if pm == 'Zp':
                plot.xaxis.limits = [-1200, 1200]

        if od == 'S4':
            if pm == 'EZp':
                plot.yaxis.limits = [E0 - 2 * dE, E0 + 2 * dE]
                #plot.xaxis.limits = [-20000, 20000]
            if pm == 'X':
                pass
#               plot.xaxis.limits = [-3.5, 3.5]
            if pm == 'E':
                plot.xaxis.limits = [E0 - 2 * dE, E0 + 2 * dE]
                plot.xaxis.offset = E0
#            if pm == 'Zp':
#                plot.xaxis.limits = [-20000, 20000]

        if od in ['S0', 'S1']:
            plot.caxis.limits = [E0 - dE, E0 + dE]
        if od in ['S2']:
            plot.caxis.limits = [E0 - 2 * dE, E0 + 2 * dE]
        if od in ['S3', 'S4']:
            ftr = 1
            #plot.caxis.limits = [(E0-dE)*ftr,(E0+dE)*ftr]
            plot.caxis.limits = [E0 - dE, E0 + dE]
            plot.caxis.factor = ftr
            plot.caxis.unit = r"eV"
            plot.caxis.fwhmFormatStr = '%1.4f'
            plot.caxis.label = r"energy"
        plot.caxis.offset = E0
        plot.xaxis.fwhmFormatStr = '%1.6f'
        plot.yaxis.fwhmFormatStr = '%1.6f'
#        plot.caxis.fwhmFormatStr = '%1.6f'

#    Plot02 = xrtplot.XYCPlot(
#        beam=r"screen01beamLocal01",
#        xaxis=xrtplot.XYCAxis(
#            label=r"x",
#            fwhmFormatStr=r"%.3f"),
#        yaxis=xrtplot.XYCAxis(
#            label=r"z",
#            fwhmFormatStr=r"%.3f"),
#        caxis=xrtplot.XYCAxis(
#            label=r"energy",
#            unit=r"eV",
#            fwhmFormatStr=r"%.3f"),
#        title=r"Screen between the two crystal")

    return plots
Ejemplo n.º 28
0
def define_plots(beamLine):
    plots = []

    xrtp.yTextPosNraysR = 0.82
    xrtp.yTextPosNrays1 = 0.52

    plot0 = xrtp.XYCPlot('beamFSM1', (1, ),
                         xaxis=xrtp.XYCAxis(r'$x$',
                                            'mm',
                                            limits=[-1.2, 1.2],
                                            fwhmFormatStr=None),
                         yaxis=xrtp.XYCAxis(r'$z$',
                                            'mm',
                                            limits=[-1.2, 1.2],
                                            fwhmFormatStr=None),
                         ePos=0,
                         title=beamLine.fsm1.name)
    plots.append(plot0)

    #    plot1 = xrtp.XYCPlot(
    #        'beamLensLocal1_{0:02d}'.format(0), (1,),
    #        xaxis=xrtp.XYCAxis(
    #            r'$x$', 'mm', limits=[-1.2, 1.2], fwhmFormatStr=None),
    #        yaxis=xrtp.XYCAxis(
    #            r'$y$', 'mm', limits=[-1.2, 1.2], fwhmFormatStr=None),
    #        ePos=0, title='LensFootprint1_00')
    #    plots.append(plot1)

    fwhmFormatStrF = '%.2f'
    plotsFSM2 = []
    for i, dq in enumerate(beamLine.fsm2.dqs):
        plot2 = xrtp.XYCPlot('beamFSM2_{0:02d}'.format(i), (1, ),
                             xaxis=xrtp.XYCAxis(r'$x$',
                                                u'µm',
                                                limits=xyLimits,
                                                bins=250,
                                                ppb=1),
                             yaxis=xrtp.XYCAxis(r'$z$',
                                                u'µm',
                                                limits=xyLimits,
                                                bins=250,
                                                ppb=1),
                             ePos=0,
                             title=beamLine.fsm2.name + '-{0:02d}'.format(i))
        plot2.xaxis.fwhmFormatStr = fwhmFormatStrF
        plot2.yaxis.fwhmFormatStr = fwhmFormatStrF
        plot2.textPanel = plot2.fig.text(0.2,
                                         0.75,
                                         '',
                                         transform=plot2.fig.transFigure,
                                         size=14,
                                         color='r',
                                         ha='left')
        plot2.textPanelTemplate = '{0}: d$q=${1:+.0f} mm'.format('{0}', dq)
        plots.append(plot2)
        plotsFSM2.append(plot2)


#        plot3 = xrtp.XYCPlot('beamFSM2_{0:02d}'.format(i), (1,),
#          xaxis=xrtp.XYCAxis(r'$x$', u'µm', limits=xyLimits),
#          yaxis=xrtp.XYCAxis(r'$z$', u'µm', limits=xyLimits),
#          caxis=xrtp.XYCAxis('degree of polarization', '',
#          data=raycing.get_polarization_degree, limits=[0, 1]),
#          ePos=1, title=beamLine.fsm2.name+'PolDegree'+'-{0:02d}'.format(i))
#        plot3.textPanel = plot3.fig.text(
#            0.2, 0.75, '', transform=plot3.fig.transFigure,
#            size=14, color='r', ha='left')
#        plots.append(plot3)
#
#        plot4 = xrtp.XYCPlot('beamFSM2_{0:02d}'.format(i), (1,),
#          xaxis=xrtp.XYCAxis(r'$x$', u'µm', limits=xyLimits),
#          yaxis=xrtp.XYCAxis(r'$z$', u'µm', limits=xyLimits),
#          caxis=xrtp.XYCAxis('circular polarization rate', '',
#          data=raycing.get_circular_polarization_rate, limits=[-1, 1]),
#          ePos=1, title=beamLine.fsm2.name+'CircPolRate'+'-{0:02d}'.format(i))
#        plot4.textPanel = plot4.fig.text(
#            0.2, 0.75, '', transform=plot4.fig.transFigure,
#            size=14, color='r', ha='left')
#        plots.append(plot4)
#
#        plot5 = xrtp.XYCPlot('beamFSM2_{0:02d}'.format(i), (1,),
#          xaxis=xrtp.XYCAxis(r'$x$', u'µm', limits=xyLimits),
#          yaxis=xrtp.XYCAxis(r'$z$', u'µm', limits=xyLimits),
#          caxis=xrtp.XYCAxis('ratio of ellipse axes', '',
#          data=raycing.get_ratio_ellipse_axes, limits=[-1, 1]),
#          ePos=1,
#          title=beamLine.fsm2.name+'PolAxesRatio'+'-{0:02d}'.format(i))
#        plot5.textPanel = plot5.fig.text(
#            0.2, 0.75, '', transform=plot5.fig.transFigure,
#            size=14, color='r', ha='left')
#        plots.append(plot5)
#
#        plot6 = xrtp.XYCPlot('beamFSM2_{0:02d}'.format(i), (1,),
#          xaxis=xrtp.XYCAxis(r'$x$', u'µm', limits=xyLimits),
#          yaxis=xrtp.XYCAxis(r'$z$', u'µm', limits=xyLimits),
#          caxis=xrtp.XYCAxis('angle of polarization ellipse', '',
#          data=raycing.get_polarization_psi, limits=[-90, 90]),
#          ePos=1, title=beamLine.fsm2.name+'PolPsi'+'-{0:02d}'.format(i))
#        plot6.ax1dHistE.set_yticks([-90,-45,0,45,90])
#        plot6.textPanel = plot6.fig.text(
#            0.2, 0.75, '', transform=plot6.fig.transFigure,
#            size=14, color='r', ha='left')
#        plots.append(plot6)
    return plots, plotsFSM2
Ejemplo n.º 29
0
def define_plots(beamLine):
    plots = []

    ePos = 1 if xbins < 4 else 2
    plot = xrtp.XYCPlot(
        'beamFSM0', (1,),
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', bins=xbins, ppb=xppb),
        yaxis=xrtp.XYCAxis(r'$z$', 'mm', bins=zbins, ppb=zppb),
        ePos=ePos, title='00-FE')
    plot.xaxis.fwhmFormatStr = '%.3f'
    plot.yaxis.fwhmFormatStr = '%.3f'
    plots.append(plot)

    ePos = 1 if zbins < 4 else 2
    plot = xrtp.XYCPlot(
        'beamM1local', (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', bins=zbins, ppb=zppb,
                           limits=beamLine.m1.limPhysX),
        yaxis=xrtp.XYCAxis(r'$y$', 'mm', bins=xbins, ppb=xppb,
                           limits=beamLine.m1.limPhysY),
        ePos=ePos, title='01-M1local')
    plots.append(plot)

    ePos = 1 if xbins < 4 else 2
    plot = xrtp.XYCPlot(
        'beamM2local', (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', bins=xbins, ppb=xppb,
                           limits=beamLine.m2.limPhysX),
        yaxis=xrtp.XYCAxis(r'$y$', 'mm', bins=zbins, ppb=zppb,
                           limits=beamLine.m2.limPhysY),
        ePos=ePos, title='02-M2local')
    plots.append(plot)

    ePos = 1 if xbins < 4 else 2
    plot = xrtp.XYCPlot(
        'beamPGlocal', (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', bins=xbins, ppb=xppb,
                           limits=beamLine.pg.limPhysX),
        yaxis=xrtp.XYCAxis(r'$y$', 'mm', bins=zbins, ppb=zppb,
                           limits=beamLine.pg.limPhysY),
        ePos=ePos, title='02-PGlocal')
    plots.append(plot)

    ePos = 1 if zbins < 4 else 2
    plot = xrtp.XYCPlot(
        'beamM3local', (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', bins=zbins, ppb=zppb,
                           limits=beamLine.m3.limPhysX),
        yaxis=xrtp.XYCAxis(r'$y$', 'mm', bins=xbins, ppb=xppb,
                           limits=beamLine.m3.limPhysY),
        ePos=ePos, title='03-M3local')
    plots.append(plot)

    caxis = xrtp.XYCAxis('Ep phase', '',
                         data=raycing.get_Ep_phase, limits=[-np.pi, np.pi])
    ePos = 1 if zbins < 4 else 2
    plot = xrtp.XYCPlot(
        'beamM3local', (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(r'$x$', 'mm', bins=zbins, ppb=zppb,
                           limits=beamLine.m3.limPhysX),
        yaxis=xrtp.XYCAxis(r'$y$', 'mm', bins=xbins, ppb=xppb,
                           limits=beamLine.m3.limPhysY),
        caxis=caxis, ePos=ePos, title='03s-M3local')
    plots.append(plot)

    limMaxX = ESdX*0.6e3
    limMaxZ = ESdZ*0.6e3
    ePos = 1 if xbins < 4 else 2
    plot = xrtp.XYCPlot(
        'beamExitSlit', (1, beamLine.exitSlit.lostNum), aspect='auto',
        xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=xbins, ppb=xppb),
        yaxis=xrtp.XYCAxis(r'$z$', u'µm', bins=zbins, ppb=zppb),
        ePos=ePos, title='04-ExitSlit')
    plot.xaxis.limits = -limMaxX, limMaxX
    plot.yaxis.limits = -limMaxZ, limMaxZ
    plots.append(plot)

    caxis = xrtp.XYCAxis('Es phase', '',
                         data=raycing.get_Es_phase, limits=[-np.pi, np.pi])
    ePos = 1 if xbins < 4 else 2
    plot = xrtp.XYCPlot(
        'beamExitSlit', (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(r'$x$', u'µm', bins=xbins, ppb=xppb),
        yaxis=xrtp.XYCAxis(r'$z$', u'µm', bins=zbins, ppb=zppb),
        caxis=caxis, ePos=ePos, title='04s-ExitSlit')
    plot.xaxis.limits = -limMaxX, limMaxX
    plot.yaxis.limits = -limMaxZ, limMaxZ
    plots.append(plot)

    if what == 'rays':
        plot = xrtp.XYCPlot(
            'beamFSMFZP', (1,), aspect='auto',
            xaxis=xrtp.XYCAxis(
                r'$x$', u'µm', bins=256, ppb=1, limits=[-ZPdiam/2, ZPdiam/2]),
            yaxis=xrtp.XYCAxis(
                r'$z$', u'µm', bins=256, ppb=1, limits=[-ZPdiam/2, ZPdiam/2]),
            title='05l-FZP')
        plots.append(plot)

    plot = xrtp.XYCPlot(
        'beamFZPlocal', (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(
            r'$x$', u'µm', bins=256, ppb=1, limits=[-ZPdiam/2, ZPdiam/2]),
        yaxis=xrtp.XYCAxis(
            r'$y$', u'µm', bins=256, ppb=1, limits=[-ZPdiam/2, ZPdiam/2]),
        title='05-FZP')
    plots.append(plot)

    caxis = xrtp.XYCAxis('Es phase', '',
                         data=raycing.get_Es_phase, limits=[-np.pi, np.pi])
    plot = xrtp.XYCPlot(
        'beamFZPlocal', (1,), aspect='auto',
        xaxis=xrtp.XYCAxis(
            r'$x$', u'µm', bins=256, ppb=1, limits=[-ZPdiam/2, ZPdiam/2]),
        yaxis=xrtp.XYCAxis(
            r'$y$', u'µm', bins=256, ppb=1, limits=[-ZPdiam/2, ZPdiam/2]),
        caxis=caxis, title='05s-FZP')
    plots.append(plot)

    complexPlotsIs = []
    complexPlotsPCAs = []
    for ic, (fsmExpCenter, d) in enumerate(
            zip(beamLine.fsmExpCenters, dFocus)):
        ePos = 1 if xbins < 4 else 2
        plot = xrtp.XYCPlot(
            'beamFSMExp{0:02d}'.format(ic), (1,), aspect='auto',
            xaxis=xrtp.XYCAxis(r'$x$', r'nm', bins=xbins, ppb=xppb,
                               limits=[-160, 160]),
            yaxis=xrtp.XYCAxis(r'$z$', r'nm', bins=zbins, ppb=zppb,
                               limits=[-160, 160]),
            fluxKind='s', ePos=ePos, title='06-ExpFocus{0:02d}'.format(ic))
        plot.textPanel = plot.fig.text(
            0.88, 0.8, u'f{0:+.1f} µm'.format(d*1e3),
            transform=plot.fig.transFigure, size=12, color='r', ha='center')
        plots.append(plot)
        complexPlotsIs.append(plot)

        ePos = 1 if xbins < 4 else 2
        plot = xrtp.XYCPlot(
            'beamFSMExp{0:02d}'.format(ic), (1,), aspect='auto',
            xaxis=xrtp.XYCAxis(r'$x$', r'nm', bins=xbins, ppb=xppb,
                               limits=[-160, 160]),
            yaxis=xrtp.XYCAxis(r'$z$', r'nm', bins=zbins, ppb=zppb,
                               limits=[-160, 160]),
            fluxKind='EsPCA', ePos=ePos,
            title='06e-ExpFocus{0:02d}'.format(ic))
        plot.textPanel = plot.fig.text(
            0.88, 0.8, u'f{0:+.1f} µm'.format(d*1e3),
            transform=plot.fig.transFigure, size=12, color='r', ha='center')
        plots.append(plot)
        complexPlotsPCAs.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'
        if plot.xaxis.bins < 4:
            plot.ax2dHist.xaxis.set_ticks([0])
            plot.xaxis.fwhmFormatStr = None
            plot.ax1dHistX.set_visible(False)
        if plot.yaxis.bins < 4:
            plot.ax2dHist.yaxis.set_ticks([0])
            plot.yaxis.fwhmFormatStr = None
            plot.ax1dHistY.set_visible(False)
    return plots, complexPlotsIs, complexPlotsPCAs
Ejemplo n.º 30
0
def define_plots(beamLine):
    fwhmFormatStrE = '%.2f'
    plots = []
    plotsAnalyzer = []
    plotsDetector = []
    plotsE = []

    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,2,3,-1),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', 1.0, limits=[-52, 52], bins=400,
    #                         ppb=1),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', 1.0, limits=[-52, 52], bins=400,
    #                         ppb=1),
    #      caxis='category', title='xtal_footprint', oe=beamLine.analyzer)
    #    plotsAnalyzer.append(plot)

    plotAnE = xrtp.XYCPlot('beamAnalyzerLocal', (1, ),
                           xaxis=xrtp.XYCAxis(r'$x$',
                                              'mm',
                                              limits=[-52, 52],
                                              bins=400,
                                              ppb=1),
                           yaxis=xrtp.XYCAxis(r'$y$',
                                              'mm',
                                              limits=[-52, 52],
                                              bins=400,
                                              ppb=1),
                           caxis=xrtp.XYCAxis('energy',
                                              'eV',
                                              fwhmFormatStr='%.2f',
                                              bins=200,
                                              ppb=2),
                           title='xtal_E',
                           oe=beamLine.analyzer)
    plotAnE.caxis.fwhmFormatStr = fwhmFormatStrE
    plotAnE.caxis.invertAxis = True
    plotAnE.textPanel = plotAnE.fig.text(0.88,
                                         0.85,
                                         '',
                                         transform=plotAnE.fig.transFigure,
                                         size=14,
                                         color='r',
                                         ha='center')
    plotsAnalyzer.append(plotAnE)
    plotsE.append(plotAnE)

    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-52, 52], bins=400, ppb=1),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-52, 52], bins=400, ppb=1),
    #      caxis=xrtp.XYCAxis('degree of polarization', '', bins=200, ppb=2,
    #      data=raycing.get_polarization_degree, limits=[0, 1]),
    #      title='xtal_DegOfPol', oe=beamLine.analyzer)
    #    plotsAnalyzer.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-52, 52], bins=400, ppb=1),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-52, 52], bins=400, ppb=1),
    #      caxis=xrtp.XYCAxis('circular polarization rate', '', bins=200, ppb=2,
    #      data=raycing.get_circular_polarization_rate, limits=[-1, 1]),
    #      title='xtal_CircPol', oe=beamLine.analyzer)
    #    plot.textPanel = plot.fig.text(0.88, 0.85, '',
    #      transform=plot.fig.transFigure, size=14, color='r', ha='center')
    #    plotsAnalyzer.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-52, 52], bins=400, ppb=1),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-52, 52], bins=400, ppb=1),
    #      caxis=xrtp.XYCAxis('ratio of ellipse axes', '', bins=200, ppb=2,
    #      data=raycing.get_ratio_ellipse_axes, limits=[-1, 1]),
    #      title='xtal_PolAxes', oe=beamLine.analyzer)
    #    plot.textPanel = plot.fig.text(0.88, 0.85, '',
    #      transform=plot.fig.transFigure, size=14, color='r', ha='center')
    #    plotsAnalyzer.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-52, 52], bins=400, ppb=1),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-52, 52], bins=400, ppb=1),
    #      caxis=xrtp.XYCAxis('phase shift', '', bins=200, ppb=2,
    #      data=raycing.get_phase_shift, limits=[-1, 1]),#in units of pi!
    #      title='xtal_Phase', oe=beamLine.analyzer)
    #    plot.textPanel = plot.fig.text(0.88, 0.85, '',
    #      transform=plot.fig.transFigure, size=14, color='r', ha='center')
    #    formatter = mpl.ticker.FormatStrFormatter('%g' + r'$ \pi$')
    #    plot.ax1dHistE.yaxis.set_major_formatter(formatter)
    #    plotsAnalyzer.append(plot)
    #
    #
    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,-1),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-1.6, 1.6]),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-1.6, 1.6]),
    #      caxis='category', title='xtal_zoom', oe=beamLine.analyzer,
    #      raycingParam=1000)
    #    plotsAnalyzer.append(plot)
    #
    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1, ),
                        xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-1.6, 1.6]),
                        yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-1.6, 1.6]),
                        caxis=xrtp.XYCAxis('energy',
                                           'eV',
                                           fwhmFormatStr='%.2f'),
                        title='xtal_E_zoom',
                        oe=beamLine.analyzer,
                        raycingParam=1000)
    plot.caxis.fwhmFormatStr = fwhmFormatStrE
    plot.caxis.invertAxis = True
    plot.textPanel = plot.fig.text(0.88,
                                   0.8,
                                   '',
                                   transform=plot.fig.transFigure,
                                   size=14,
                                   color='r',
                                   ha='center')
    plotsAnalyzer.append(plot)
    plotsE.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-1.6, 1.6]),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-1.6, 1.6]),
    #      caxis=xrtp.XYCAxis('degree of polarization', '',
    #      data=raycing.get_polarization_degree, limits=[0, 1]),
    #      title='xtal_DegOfPol_zoom', oe=beamLine.analyzer, raycingParam=1000)
    #    plot.textPanel = plot.fig.text(
    #        0.88, 0.8, '', transform=plot.fig.transFigure,
    #        size=14, color='r', ha='center')
    #    plotsAnalyzer.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-1.6, 1.6]),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-1.6, 1.6]),
    #      caxis=xrtp.XYCAxis('circular polarization rate', '',
    #      data=raycing.get_circular_polarization_rate, limits=[-1, 1]),
    #      title='xtal_CircPol_zoom', oe=beamLine.analyzer, raycingParam=1000)
    #    plot.textPanel = plot.fig.text(
    #        0.88, 0.8, '', transform=plot.fig.transFigure,
    #        size=14, color='r', ha='center')
    #    plotsAnalyzer.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-1.6, 1.6]),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-1.6, 1.6]),
    #      caxis=xrtp.XYCAxis('ratio of ellipse axes', '',
    #      data=raycing.get_ratio_ellipse_axes, limits=[-1, 1]),
    #      title='xtal_PolAxes_zoom', oe=beamLine.analyzer, raycingParam=1000)
    #    plot.textPanel = plot.fig.text(
    #        0.88, 0.8, '', transform=plot.fig.transFigure,
    #        size=14, color='r', ha='center')
    #    plotsAnalyzer.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamAnalyzerLocal', (1,),
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-1.6, 1.6]),
    #      yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-1.6, 1.6]),
    #      caxis=xrtp.XYCAxis('phase shift', '',
    #      data=raycing.get_phase_shift, limits=[-1, 1]),#in units of pi!
    #      title='xtal_Phase_zoom', oe=beamLine.analyzer, raycingParam=1000)
    #    plot.textPanel = plot.fig.text(
    #    0.88, 0.8, '', transform=plot.fig.transFigure,
    #        size=14, color='r', ha='center')
    #    formatter = mpl.ticker.FormatStrFormatter('%g' + r'$ \pi$')
    #    plot.ax1dHistE.yaxis.set_major_formatter(formatter)
    #    plotsAnalyzer.append(plot)

    plotDetE = xrtp.XYCPlot('beamDetector', (1, ),
                            aspect='auto',
                            xaxis=xrtp.XYCAxis(r'$x$',
                                               'mm',
                                               limits=[-xAxisLim, xAxisLim],
                                               fwhmFormatStr='%.3f'),
                            yaxis=xrtp.XYCAxis(r'$z$',
                                               'mm',
                                               limits=[-0.25, 0.25],
                                               fwhmFormatStr='%.3f'),
                            title='det_E')
    plotDetE.caxis.fwhmFormatStr = fwhmFormatStrE
    plotDetE.caxis.invertAxis = True
    plotDetE.textPanel = plotDetE.fig.text(0.88,
                                           0.8,
                                           '',
                                           transform=plotDetE.fig.transFigure,
                                           size=14,
                                           color='r',
                                           ha='center')
    plotsDetector.append(plotDetE)
    plotsE.append(plotDetE)

    #    plot = xrtp.XYCPlot('beamDetector', (1,), aspect='auto',
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-xAxisLim, xAxisLim],
    #                         fwhmFormatStr='%.3f'),
    #      yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.25, 0.25],
    #                         fwhmFormatStr='%.3f'),
    #      caxis=xrtp.XYCAxis('degree of polarization', '',
    #                         data=raycing.get_polarization_degree,
    #                         limits=[0, 1]), title='det_DegOfPol')
    #    plot.textPanel = plot.fig.text(
    #        0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r',
    #        ha='center')
    #    plotsDetector.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamDetector', (1,), aspect='auto',
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-xAxisLim, xAxisLim],
    #                         fwhmFormatStr='%.3f'),
    #      yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.25, 0.25],
    #                         fwhmFormatStr='%.3f'),
    #      caxis=xrtp.XYCAxis('circular polarization rate', '',
    #                         data=raycing.get_circular_polarization_rate,
    #                         limits=[-1, 1]),
    #      title='det_CircPol')
    #    plot.textPanel = plot.fig.text(
    #        0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r',
    #        ha='center')
    #    plotsDetector.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamDetector', (1,), aspect='auto',
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-xAxisLim, xAxisLim],
    #                         fwhmFormatStr='%.3f'),
    #      yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.25, 0.25],
    #                         fwhmFormatStr='%.3f'),
    #      caxis=xrtp.XYCAxis('ratio of ellipse axes', '',
    #                         data=raycing.get_ratio_ellipse_axes,
    #                         limits=[-1, 1]),
    #      title='det_PolAxes')
    #    plot.textPanel = plot.fig.text(
    #        0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r',
    #        ha='center')
    #    plotsDetector.append(plot)
    #
    #    plot = xrtp.XYCPlot('beamDetector', (1,), aspect='auto',
    #      xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-xAxisLim, xAxisLim],
    #                         fwhmFormatStr='%.3f'),
    #      yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[-0.25, 0.25],
    #                         fwhmFormatStr='%.3f'),
    #      caxis=xrtp.XYCAxis('phase shift', '',
    #                         data=raycing.get_phase_shift,
    #                         limits=[-1, 1]),#in units of pi!
    #      title='det_Phase')
    #    plot.textPanel = plot.fig.text(
    #        0.88, 0.8, '', transform=plot.fig.transFigure, size=14, color='r',
    #        ha='center')
    #    formatter = mpl.ticker.FormatStrFormatter('%g' + r'$ \pi$')
    #    plot.ax1dHistE.yaxis.set_major_formatter(formatter)
    #    plotsDetector.append(plot)

    for plot in plotsAnalyzer:
        plots.append(plot)
    for plot in plotsDetector:
        plots.append(plot)
    return plots, plotsAnalyzer, plotsDetector, plotsE, plotAnE, plotDetE