コード例 #1
0
def srw_end_bl_call():
    el2 = []
    opMask = setup_mask()
    el2.append(srwlib.SRWLOptD(1e-32))
    el2.append(opMask)   
    pp2 = []
    pp2.append([0, 0, 1.0, 1, 0, xRatio, 1/xRatio, xRatio, 1/yRatio])
    pp2.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])#mask
    pp2.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    op2 = deepcopy(srwlib.SRWLOptC(el2, pp2))      
    
    
    int_ws2=propogation(op2)      
    mesh_ws2 = deepcopy(wfr2.mesh)
    print('.....',mesh_ws2.xStart, mesh_ws2.ny , '......')
    
    up.uti_plot2d1d(
        int_ws2,
        [mesh_ws2.xStart, mesh_ws2.xFin, mesh_ws2.nx],
        [mesh_ws2.yStart, mesh_ws2.yFin, mesh_ws2.ny],
        0, 
        0, 
        ['Horizontal Position', 'Vertical Position', ' After Propagation'],
        ['m', 'm', 'ph/s/.1%bw/mm^2'],
        True)
    up.uti_plot_show()   
コード例 #2
0
#************************************* 7. Plotting
for i in range(len(intensitiesToPlot['intensity'])):
    srwl_uti_save_intens_ascii(
        intensitiesToPlot['intensity'][i],
        intensitiesToPlot['mesh'][i],
        '{}/intensity_{:.1f}m.dat'.format(example_folder,
                                          intensitiesToPlot['distance'][i]),
        0, ['Photon Energy', 'Horizontal Position', 'Vertical Position', ''],
        _arUnits=['eV', 'm', 'm', 'ph/s/.1%bw/mm^2'])
    uti_plot.uti_plot2d1d(intensitiesToPlot['intensity'][i],
                          intensitiesToPlot['mesh_x'][i],
                          intensitiesToPlot['mesh_y'][i],
                          x=0,
                          y=0,
                          labels=[
                              'Horizontal Position', 'Vertical Position',
                              'Intenisty at {} m'.format(
                                  intensitiesToPlot['distance'][i])
                          ],
                          units=['m', 'm', 'a.u.'])

with open('{}/compare.dat'.format(example_folder), 'w') as f:
    f.write('\n'.join(data_to_print))

try:
    from matplotlib import pyplot as plt
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(s, xRMS, '-r.', label="X envelope from SRW")
    ax.plot(s, Wthx, '--ro', label="X envelope from analytical estimate")
コード例 #3
0
# Plotting initial wavefront:
plotMeshInX = [1000 * wfrIn.mesh.xStart, 1000 * wfrIn.mesh.xFin, wfrIn.mesh.nx]
plotMeshInY = [1000 * wfrIn.mesh.yStart, 1000 * wfrIn.mesh.yFin, wfrIn.mesh.ny]
srwl_uti_save_intens_ascii(
    arIin,
    wfrIn.mesh,
    '{}/{}'.format(example_folder, strIntOutFileName),
    0,
    ['Photon Energy', 'Horizontal Position', 'Vertical Position', ''],
    #_arUnits=['eV', 'm', 'm', 'ph/s/.1%bw/mm^2'])
    _arUnits=['eV', 'm', 'm', 'arb. units'])
uti_plot.uti_plot2d1d(
    arIin,
    plotMeshInX,
    plotMeshInY,
    #labels=['Horizontal Position [mm]', 'Vertical Position [mm]', 'Intensity Before Propagation [a.u.]'])
    labels=[
        'Horizontal Position', 'Vertical Position',
        'Intensity Before Propagation'
    ],
    units=['mm', 'mm', 'arb. units'])

# Element definition:
apertureSize = 0.00075  # Aperture radius, m
defaultDriftLength = 1.0  # Drift length, m
OpElement = []
ppOpElement = []

OpElement.append(SRWLOptA('c', 'a', apertureSize, apertureSize))
ppOpElement.append([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0])
arIinymax = []
for k, driftLength in enumerate([0.0, defaultDriftLength]):
コード例 #4
0
ファイル: SRWLIB_Example15.py プロジェクト: mrakitin/SRW
    RMSbx = sqrt(1.0 / (-1.0 / Wx).imag / 3.1415 * Lam) * 2.35
    Wthx.append(RMSbx)
    Wy = (WRy[m][0][0] * qy0 + WRy[m][0][1]) / (WRy[m][1][0] * qy0 + WRy[m][1][1])  # MatrixMultiply(WR,qxP)
    RMSby = sqrt(1.0 / (-1.0 / Wy).imag / 3.1415 * Lam) * 2.35
    Wthy.append(RMSby)

#************************************* 7. Plotting
for i in range(len(intensitiesToPlot['intensity'])):
    srwl_uti_save_intens_ascii(intensitiesToPlot['intensity'][i], intensitiesToPlot['mesh'][i],
                               '{}/intensity_{:.1f}m.dat'.format(example_folder, intensitiesToPlot['distance'][i]),
                               0, ['Photon Energy', 'Horizontal Position', 'Vertical Position', ''],
                               _arUnits=['eV', 'm', 'm', 'ph/s/.1%bw/mm^2'])
    uti_plot.uti_plot2d1d(intensitiesToPlot['intensity'][i],
                          intensitiesToPlot['mesh_x'][i],
                          intensitiesToPlot['mesh_y'][i],
                          x=0, y=0,
                          labels=['Horizontal Position', 'Vertical Position',
                                  'Intenisty at {} m'.format(intensitiesToPlot['distance'][i])],
                          units=['m', 'm', 'a.u.'])

with open('{}/compare.dat'.format(example_folder), 'w') as f:
    f.write('\n'.join(data_to_print))

try:
    from matplotlib import pyplot as plt
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(s, xRMS, '-r.', label="X envelope from SRW")
    ax.plot(s, Wthx, '--ro', label="X envelope from analytical estimate")
    ax.plot(s, yRMS, '-b.', label="Y envelope from SRW")
    ax.plot(s, Wthy, '--bo', label="Y envelope from analytical estimate")
コード例 #5
0
ファイル: SRWLIB_Example16.py プロジェクト: mrakitin/SRW
arIin = array('f', [0] * wfrIn.mesh.nx * wfrIn.mesh.ny)
srwl.CalcIntFromElecField(arIin, wfrIn, 0, 0, 3, wfr.mesh.eStart, 0, 0)

arIinY = array('f', [0] * wfrIn.mesh.ny)
srwl.CalcIntFromElecField(arIinY, wfrIn, 0, 0, 2, wfrIn.mesh.eStart, 0, 0)  # extracts intensity

# Plotting initial wavefront:
plotMeshInX = [1000 * wfrIn.mesh.xStart, 1000 * wfrIn.mesh.xFin, wfrIn.mesh.nx]
plotMeshInY = [1000 * wfrIn.mesh.yStart, 1000 * wfrIn.mesh.yFin, wfrIn.mesh.ny]
srwl_uti_save_intens_ascii(arIin, wfrIn.mesh,
                           '{}/{}'.format(example_folder, strIntOutFileName),
                           0, ['Photon Energy', 'Horizontal Position', 'Vertical Position', ''],
                           #_arUnits=['eV', 'm', 'm', 'ph/s/.1%bw/mm^2'])
                           _arUnits=['eV', 'm', 'm', 'arb. units'])
uti_plot.uti_plot2d1d(arIin, plotMeshInX, plotMeshInY,
                      #labels=['Horizontal Position [mm]', 'Vertical Position [mm]', 'Intensity Before Propagation [a.u.]'])
                      labels=['Horizontal Position', 'Vertical Position', 'Intensity Before Propagation'],
                      units=['mm', 'mm', 'arb. units'])

# Element definition:
apertureSize = 0.00075  # Aperture radius, m
defaultDriftLength = 1.0  # Drift length, m
OpElement = []
ppOpElement = []

OpElement.append(SRWLOptA('c', 'a', apertureSize, apertureSize))
ppOpElement.append([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0])
arIinymax = []
for k, driftLength in enumerate([0.0, defaultDriftLength]):
    ppOpElement.append([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0])
    if driftLength:
        OpElement.append(SRWLOptD(driftLength))  # Drift space