def _gaussian_beam_intensity(GsnBm, _mesh, **kwargs):
    wfr = srwlib.SRWLWfr()
    wfr.allocate(_mesh.ne, _mesh.nx, _mesh.ny) #Numbers of points vs Photon Energy, Horizontal and Vertical Positions
    wfr.mesh = srwlib.deepcopy(_mesh)
    wfr.partBeam.partStatMom1.x = GsnBm.x #Some information about the source in the Wavefront structure
    wfr.partBeam.partStatMom1.y = GsnBm.y
    wfr.partBeam.partStatMom1.z = GsnBm.z
    wfr.partBeam.partStatMom1.xp = GsnBm.xp
    wfr.partBeam.partStatMom1.yp = GsnBm.yp
    arPrecPar = [kwargs['_samp_fact']]

    srwlpy.CalcElecFieldGaussian(wfr, GsnBm, arPrecPar)

    depType = -1
    if((_mesh.ne >= 1) and (_mesh.nx == 1) and (_mesh.ny == 1)): depType = 0
    elif((_mesh.ne == 1) and (_mesh.nx > 1) and (_mesh.ny == 1)): depType = 1
    elif((_mesh.ne == 1) and (_mesh.nx == 1) and (_mesh.ny > 1)): depType = 2
    elif((_mesh.ne == 1) and (_mesh.nx > 1) and (_mesh.ny > 1)): depType = 3
    elif((_mesh.ne > 1) and (_mesh.nx > 1) and (_mesh.ny == 1)): depType = 4
    elif((_mesh.ne > 1) and (_mesh.nx == 1) and (_mesh.ny > 1)): depType = 5
    elif((_mesh.ne > 1) and (_mesh.nx > 1) and (_mesh.ny > 1)): depType = 6
    if(depType < 0): Exception('Incorrect numbers of points in the mesh structure')

    sNumTypeInt = 'f'
    if(kwargs['_int_type'] == 4): sNumTypeInt = 'd'
    arI = srwlib.array(sNumTypeInt, [0]*wfr.mesh.ne*wfr.mesh.nx*wfr.mesh.ny)
    srwlpy.CalcIntFromElecField(arI, wfr, kwargs['_pol'], kwargs['_int_type'], depType, wfr.mesh.eStart, wfr.mesh.xStart, wfr.mesh.yStart) #extracts intensity
    _fname = kwargs['_fname']
    if(len(_fname) > 0): srwlib.srwl_uti_save_intens_ascii(arI, wfr.mesh, _fname, 0, ['Photon Energy', 'Horizontal Position', 'Vertical Position', ''], _arUnits=['eV', 'm', 'm', 'ph/s/.1%bw/mm^2'])
    return wfr, arI
示例#2
0
def _mirror_plot(model_data):
    mirror = model_data['models']['mirrorReport']
    element = srwlib.srwl_opt_setup_surf_height_1d(
        srwlib.srwl_uti_read_data_cols(mirror['heightProfileFile'], "\t", 0, 1),
        _dim=mirror['orientation'],
        _ang=float(mirror['grazingAngle']) / 1e3,
        _amp_coef=float(mirror['heightAmplification']))
        #_size_x=float(mirror['horizontalTransverseSize']) / 1e3,
        #_size_y=float(mirror['verticalTransverseSize']) / 1e3)
    transmission_data = element.get_data(3, 3)
    srwlib.srwl_uti_save_intens_ascii(
        transmission_data, element.mesh, 'res_mirror.dat', 0,
        ['', 'Horizontal Position', 'Vertical Position', 'Optical Path Difference'], _arUnits=['', 'm', 'm', ''])
    return 'res_mirror.dat'
示例#3
0
文件: srw.py 项目: mrakitin/sirepo
def _mirror_plot(model_data):
    mirror = model_data['models']['mirrorReport']
    dat_file = mirror['heightProfileFile']
    dimension = find_height_profile_dimension(dat_file)
    func_name = 'srwl_opt_setup_surf_height_{}d'.format(dimension)
    add_args = [0, 1] if dimension == 1 else []
    element = getattr(srwlib, func_name)(
        srwlib.srwl_uti_read_data_cols(mirror['heightProfileFile'], "\t", *add_args),
        _dim=mirror['orientation'],
        _ang=float(mirror['grazingAngle']) / 1e3,
        _amp_coef=float(mirror['heightAmplification']))
    transmission_data = element.get_data(3, 3)
    srwlib.srwl_uti_save_intens_ascii(
        transmission_data, element.mesh, 'res_mirror.dat', 0,
        ['', 'Horizontal Position', 'Vertical Position', 'Optical Path Difference'], _arUnits=['', 'm', 'm', ''])
    return 'res_mirror.dat'
示例#4
0
def _mirror_plot(model_data):
    mirror = model_data['models']['mirrorReport']
    element = srwlib.srwl_opt_setup_surf_height_1d(
        srwlib.srwl_uti_read_data_cols(mirror['heightProfileFile'], "\t", 0,
                                       1),
        _dim=mirror['orientation'],
        _ang=float(mirror['grazingAngle']) / 1e3,
        _amp_coef=float(mirror['heightAmplification']))
    #_size_x=float(mirror['horizontalTransverseSize']) / 1e3,
    #_size_y=float(mirror['verticalTransverseSize']) / 1e3)
    transmission_data = element.get_data(3, 3)
    srwlib.srwl_uti_save_intens_ascii(
        transmission_data,
        element.mesh,
        'res_mirror.dat',
        0, [
            '', 'Horizontal Position', 'Vertical Position',
            'Optical Path Difference'
        ],
        _arUnits=['', 'm', 'm', ''])
    return 'res_mirror.dat'
示例#5
0
def _mirror_plot(model_data):
    mirror = model_data['models']['mirrorReport']
    dat_file = mirror['heightProfileFile']
    dimension = find_height_profile_dimension(dat_file)
    func_name = 'srwl_opt_setup_surf_height_{}d'.format(dimension)
    add_args = [0, 1] if dimension == 1 else []
    element = getattr(srwlib, func_name)(
        srwlib.srwl_uti_read_data_cols(mirror['heightProfileFile'], "\t",
                                       *add_args),
        _dim=mirror['orientation'],
        _ang=float(mirror['grazingAngle']) / 1e3,
        _amp_coef=float(mirror['heightAmplification']))
    transmission_data = element.get_data(3, 3)
    srwlib.srwl_uti_save_intens_ascii(
        transmission_data,
        element.mesh,
        'res_mirror.dat',
        0, [
            '', 'Horizontal Position', 'Vertical Position',
            'Optical Path Difference'
        ],
        _arUnits=['', 'm', 'm', ''])
    return 'res_mirror.dat'