Exemple #1
0
def set_optics(v=None):
    el = []
    pp = []
    names = ['Aperture', 'Aperture_Watchpoint', 'Watchpoint']
    for el_name in names:
        if el_name == 'Aperture':
            # Aperture: aperture 33.1798m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Aperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Aperture_Dx,
                    _Dy=v.op_Aperture_Dy,
                    _x=v.op_Aperture_x,
                    _y=v.op_Aperture_y,
                ))
            pp.append(v.op_Aperture_pp)
        elif el_name == 'Aperture_Watchpoint':
            # Aperture_Watchpoint: drift 33.1798m
            el.append(srwlib.SRWLOptD(_L=v.op_Aperture_Watchpoint_L, ))
            pp.append(v.op_Aperture_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 45.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Exemple #2
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()   
Exemple #3
0
def set_optics(v=None):
    el = []
    el.append(srwlib.SRWLOptD(1e-16))

    el.append(srwlib.SRWLOptD(6.866))

    ifnMirror1 = "mirror_1d.dat"
    if ifnMirror1:
        hProfDataMirror1 = srwlib.srwl_uti_read_data_cols(ifnMirror1, "\t", 0, 1)
        el.append(srwlib.srwl_opt_setup_surf_height_1d(hProfDataMirror1, _dim="x", _ang=0.0436332, _amp_coef=1.0, _size_x=0.001, _size_y=0.001))
    el.append(srwlib.SRWLOptD(20.634))
    el.append(srwlib.SRWLOptG(_mirSub=srwlib.SRWLOptMirPl(_size_tang=0.2, _size_sag=0.015, _nvx=0.0, _nvy=0.99991607766, _nvz=-0.0129552165771, _tvx=0.0, _tvy=0.0129552165771), _m=1.0, _grDen=1800.0, _grDen1=0.08997, _grDen2=3.004e-06, _grDen3=9.73e-11, _grDen4=0.0))
    el.append(srwlib.SRWLOptA("r", "a", 0.015, 0.00259104331543, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(34.63))
    el.append(srwlib.SRWLOptA("r", "a", 0.01832012956, 0.02, 0.0, 0.0))
    el.append(srwlib.SRWLOptMirEl(_p=89.63, _q=8.006, _ang_graz=0.0436332, _size_tang=0.42, _size_sag=0.02, _nvx=0.999048222947, _nvy=0.0, _nvz=-0.0436193560953, _tvx=-0.0436193560953, _tvy=0.0))
    el.append(srwlib.SRWLOptD(8.006))
    el.append(srwlib.SRWLOptA("r", "a", 0.0015, 0.0015, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(6.01))
    el.append(srwlib.SRWLOptA("r", "a", 0.0130858068286, 0.003, 0.0, 0.0))
    el.append(srwlib.SRWLOptMirEl(_p=6.01, _q=0.911, _ang_graz=0.0872665, _size_tang=0.3, _size_sag=0.05, _nvx=0.996194694832, _nvy=0.0, _nvz=-0.0871557800056, _tvx=-0.0871557800056, _tvy=0.0))
    el.append(srwlib.SRWLOptD(0.5))
    el.append(srwlib.SRWLOptMirEl(_p=6.51, _q=0.411, _ang_graz=0.0872665, _size_tang=0.3, _size_sag=0.05, _nvx=0.0, _nvy=0.996194694832, _nvz=-0.0871557800056, _tvx=0.0, _tvy=-0.0871557800056))
    el.append(srwlib.SRWLOptD(0.411))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    if ifnMirror1:
        pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.2, 3.5, 1.2, 3.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 3.0, 1.0, 3.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 0.4, 1.0, 0.4, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 2.0, 1.0, 2.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 1, 0.07, 1.5, 0.07, 6.0])

    return srwlib.SRWLOptC(el, pp)
Exemple #4
0
def set_optics(v=None):
    el = []    
    el.append(srwlib.SRWLOptD(0.6))
    
    pp = []
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])#drift    
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])#final

    return srwlib.SRWLOptC(el, pp)
Exemple #5
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'CRL', 'CRL_Watchpoint', 'Watchpoint', 'Fiber', 'Fiber_Watchpoint2',
        'Watchpoint2'
    ]
    for el_name in names:
        if el_name == 'CRL':
            # CRL: crl 36.0m
            el.append(
                srwlib.srwl_opt_setup_CRL(
                    _foc_plane=v.op_CRL_foc_plane,
                    _delta=v.op_CRL_delta,
                    _atten_len=v.op_CRL_atten_len,
                    _shape=v.op_CRL_shape,
                    _apert_h=v.op_CRL_apert_h,
                    _apert_v=v.op_CRL_apert_v,
                    _r_min=v.op_CRL_r_min,
                    _n=v.op_CRL_n,
                    _wall_thick=v.op_CRL_wall_thick,
                    _xc=v.op_CRL_x,
                    _yc=v.op_CRL_y,
                ))
            pp.append(v.op_CRL_pp)
        elif el_name == 'CRL_Watchpoint':
            # CRL_Watchpoint: drift 36.0m
            el.append(srwlib.SRWLOptD(_L=v.op_CRL_Watchpoint_L, ))
            pp.append(v.op_CRL_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 70.1915m
            pass
        elif el_name == 'Fiber':
            # Fiber: fiber 70.1915m
            el.append(
                srwlib.srwl_opt_setup_cyl_fiber(
                    _foc_plane=v.op_Fiber_foc_plane,
                    _delta_ext=v.op_Fiber_delta_ext,
                    _delta_core=v.op_Fiber_delta_core,
                    _atten_len_ext=v.op_Fiber_atten_len_ext,
                    _atten_len_core=v.op_Fiber_atten_len_core,
                    _diam_ext=v.op_Fiber_externalDiameter,
                    _diam_core=v.op_Fiber_diam_core,
                    _xc=v.op_Fiber_xc,
                    _yc=v.op_Fiber_yc,
                ))
            pp.append(v.op_Fiber_pp)
        elif el_name == 'Fiber_Watchpoint2':
            # Fiber_Watchpoint2: drift 70.1915m
            el.append(srwlib.SRWLOptD(_L=v.op_Fiber_Watchpoint2_L, ))
            pp.append(v.op_Fiber_Watchpoint2_pp)
        elif el_name == 'Watchpoint2':
            # Watchpoint2: watch 70.85m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Exemple #6
0
def set_optics(v=None):
    el = []
    pp = []
    names = ['M1', 'M1_M2', 'M2', 'M2_Watchpoint', 'Watchpoint']
    for el_name in names:
        if el_name == 'M1':
            # M1: ellipsoidMirror 28.5m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_M1_p,
                    _q=v.op_M1_q,
                    _ang_graz=v.op_M1_ang,
                    _size_tang=v.op_M1_size_tang,
                    _size_sag=v.op_M1_size_sag,
                    _nvx=v.op_M1_nvx,
                    _nvy=v.op_M1_nvy,
                    _nvz=v.op_M1_nvz,
                    _tvx=v.op_M1_tvx,
                    _tvy=v.op_M1_tvy,
                    _x=v.op_M1_x,
                    _y=v.op_M1_y,
                ))
            pp.append(v.op_M1_pp)

        elif el_name == 'M1_M2':
            # M1_M2: drift 28.5m
            el.append(srwlib.SRWLOptD(_L=v.op_M1_M2_L, ))
            pp.append(v.op_M1_M2_pp)
        elif el_name == 'M2':
            # M2: ellipsoidMirror 29.5m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_M2_p,
                    _q=v.op_M2_q,
                    _ang_graz=v.op_M2_ang,
                    _size_tang=v.op_M2_size_tang,
                    _size_sag=v.op_M2_size_sag,
                    _nvx=v.op_M2_nvx,
                    _nvy=v.op_M2_nvy,
                    _nvz=v.op_M2_nvz,
                    _tvx=v.op_M2_tvx,
                    _tvy=v.op_M2_tvy,
                    _x=v.op_M2_x,
                    _y=v.op_M2_y,
                ))
            pp.append(v.op_M2_pp)

        elif el_name == 'M2_Watchpoint':
            # M2_Watchpoint: drift 29.5m
            el.append(srwlib.SRWLOptD(_L=v.op_M2_Watchpoint_L, ))
            pp.append(v.op_M2_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 37.5m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Exemple #7
0
 def setup(self):
     super(BC11Section, self).setup()
     aperature = srwlib.SRWLOptA('c', 'a', self.detector_edge_length, 0, 0,
                                 0)
     aperature_params = [0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0]
     lens = srwlib.SRWLOptL(self.focal_length, self.focal_length)
     lens_params = [0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0]
     drift = srwlib.SRWLOptD(self.focal_length)
     drift_params = [0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0]
     self.__optics = srwlib.SRWLOptC(
         [aperature, lens, drift],
         [aperature_params, lens_params, drift_params])
Exemple #8
0
def set_optics(v=None):
    el = []
    el.append(srwlib.SRWLOptA("r", "a", 0.0002, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(6.9))
    ifnMirror1 = "mirror_1d.dat"
    if ifnMirror1:
        hProfDataMirror1 = srwlib.srwl_uti_read_data_cols(ifnMirror1, "\t", 0, 1)
        el.append(srwlib.srwl_opt_setup_surf_height_1d(hProfDataMirror1, _dim="x", _ang=0.0031415926, _amp_coef=1.0, _size_x=0.00094, _size_y=0.001))
    el.append(srwlib.SRWLOptD(2.5))
    el.append(srwlib.SRWLOptA("r", "a", 0.0002, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(4.4))
    el.append(srwlib.SRWLOptA("r", "a", 5e-05, 0.001, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(1.1))
    el.append(srwlib.srwl_opt_setup_CRL(2, 4.20756805e-06, 0.00731294, 1, 0.001, 0.0024, 0.0015, 1, 8e-05, 0, 0))
    el.append(srwlib.srwl_opt_setup_CRL(2, 4.20756805e-06, 0.00731294, 1, 0.001, 0.0014, 0.0005, 6, 8e-05, 0, 0))
    el.append(srwlib.SRWLOptD(9.1))
    el.append(srwlib.SRWLOptA("r", "a", 0.0014, 0.0002, 0.0, 0.0))
    el.append(srwlib.SRWLOptL(3.24479, 1e+23, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(3.5))
    el.append(srwlib.SRWLOptA("r", "a", 1e-05, 1e-05, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(0.7))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 2.5, 5.0, 1.5, 2.5])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    if ifnMirror1:
        pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 0.3, 2.0, 0.5, 1.0])

    return srwlib.SRWLOptC(el, pp)
def set_optics(v=None):
    el = []
    el.append(srwlib.SRWLOptD(0.6))
    opMask = setup_mask()
    el.append(opMask)
    pp = []
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mask

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #final

    return srwlib.SRWLOptC(el, pp)
Exemple #10
0
def set_optics(v=None):
    el = []
    # CRL: crl 36.0m
    el.append(
        srwlib.srwl_opt_setup_CRL(2, 4.716943e-06, 0.006257, 1, 0.001, 0.001,
                                  0.0005, 3, 8e-05, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(34.1915))
    # Watchpoint: watch 70.1915m

    # Fiber: fiber 70.1915m
    el.append(
        srwlib.srwl_opt_setup_cyl_fiber(_foc_plane=2,
                                        _delta_ext=6.228746e-06,
                                        _delta_core=4.129923e-05,
                                        _atten_len_ext=0.002412,
                                        _atten_len_core=3.63751e-06,
                                        _diam_ext=0.0001,
                                        _diam_core=1e-05,
                                        _xc=0.0,
                                        _yc=0.0))
    el.append(srwlib.SRWLOptD(0.6585))
    # Watchpoint: watch 70.85m

    pp = []
    # CRL
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # Watchpoint
    # Fiber
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # Watchpoint
    # final post-propagation
    pp.append([
        0, 0, 1.0, 0, 0, 0.7, 2.0, 0.2, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, 0.0
    ])
    return srwlib.SRWLOptC(el, pp)
Exemple #11
0
def set_optics(v=None):
    el = []
    el.append(
        srwl_uti_smp.srwl_opt_setup_transm_from_file(file_path=v.op_sample1,
                                                     resolution=2.480469e-09,
                                                     thickness=1e-05,
                                                     delta=3.738856e-05,
                                                     atten_len=3.38902e-06,
                                                     is_save_images=False,
                                                     prefix='op_sample1'))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 1.0, 100.0, 1.0, 100.0])

    pp.append([0, 0, 1.0, 0, 0, 0.005, 20.0, 0.005, 20.0])
    return srwlib.SRWLOptC(el, pp)
Exemple #12
0
def set_optics(v=None):
    el = []
    #el.append(srwlib.SRWLOptD(5000))
    opMask = setup_mask()
    el.append(opMask)

    el.append(srwlib.SRWLOptD(0.200000000012))

    pp = []
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mask

    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
    return srwlib.SRWLOptC(el, pp)
Exemple #13
0
def set_optics(v=None):
    el = []
    el.append(srwlib.SRWLOptA("r", "a", 0.001, 0.001, 0.0, 0.0))

    el.append(srwlib.SRWLOptD(0.02))

    el.append(srwlib.SRWLOptD(3.48))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 0.3, 5.0, 0.3, 5.0])

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])

    pp.append([0, 0, 1.0, 3, 0, 4.0, 1.0, 4.0, 1.0])

    pp.append([0, 0, 1.0, 0, 0, 0.075, 1.0, 0.075, 1.0])
    return srwlib.SRWLOptC(el, pp)
Exemple #14
0
def set_optics(v=None):
    el = []
    pp = []
    names = ['Sample', 'Watchpoint']
    for el_name in names:
        if el_name == 'Sample':
            # Sample: sample 20.0m
            el.append(
                srwl_uti_smp.srwl_opt_setup_transm_from_file(
                    file_path=v.op_Sample_file_path,
                    resolution=v.op_Sample_resolution,
                    thickness=v.op_Sample_thick,
                    delta=v.op_Sample_delta,
                    atten_len=v.op_Sample_atten_len,
                    xc=v.op_Sample_horizontalCenterCoordinate,
                    yc=v.op_Sample_verticalCenterCoordinate,
                    area=None if not v.op_Sample_cropArea else (
                        v.op_Sample_areaXStart,
                        v.op_Sample_areaXEnd,
                        v.op_Sample_areaYStart,
                        v.op_Sample_areaYEnd,
                    ),
                    extTr=v.op_Sample_extTransm,
                    rotate_angle=v.op_Sample_rotateAngle,
                    rotate_reshape=bool(int(v.op_Sample_rotateReshape)),
                    cutoff_background_noise=v.op_Sample_cutoffBackgroundNoise,
                    background_color=v.op_Sample_backgroundColor,
                    tile=None if not v.op_Sample_tileImage else (
                        v.op_Sample_tileRows,
                        v.op_Sample_tileColumns,
                    ),
                    shift_x=v.op_Sample_shiftX,
                    shift_y=v.op_Sample_shiftY,
                    invert=bool(int(v.op_Sample_invert)),
                    is_save_images=True,
                    prefix='Sample_sample',
                    output_image_format=v.op_Sample_outputImageFormat,
                ))
            pp.append(v.op_Sample_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 20.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Exemple #15
0
def set_optics(v=None):
    el = []
    el.append(
        srwlib.SRWLOptMirEl(_p=50.0,
                            _q=0.4,
                            _ang_graz=0.003,
                            _size_tang=0.2,
                            _size_sag=0.01,
                            _nvx=0.0,
                            _nvy=0.999995500003,
                            _nvz=-0.0029999955,
                            _tvx=0.0,
                            _tvy=-0.0029999955))
    el.append(srwlib.SRWLOptD(0.2))
    el.append(
        srwlib.SRWLOptMirEl(_p=50.0,
                            _q=0.2,
                            _ang_graz=0.003,
                            _size_tang=0.2,
                            _size_sag=0.01,
                            _nvx=0.999995500003,
                            _nvy=0.0,
                            _nvz=-0.0029999955,
                            _tvx=-0.0029999955,
                            _tvy=0.0))
    el.append(srwlib.SRWLOptD(0.4))
    opMask = setup_mask()
    el.append(opMask)
    el.append(srwlib.SRWLOptD(0.2))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mirror
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mirror
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #mask
    pp.append([0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0])  #drift

    pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])  #final

    return srwlib.SRWLOptC(el, pp)
Exemple #16
0
def set_optics(v=None):
    el = []
    # Sample: sample 20.0m
    el.append(
        srwl_uti_smp.srwl_opt_setup_transm_from_file(
            file_path=v.op_sample1,
            resolution=2.480469e-09,
            thickness=1e-05,
            delta=3.738856e-05,
            atten_len=3.38902e-06,
            xc=0.0,
            yc=0.0,
            area=(0, 1280, 0, 834),
            rotate_angle=0.0,
            rotate_reshape=False,
            cutoff_background_noise=0.5,
            background_color=0,
            tile=None,
            shift_x=0,
            shift_y=0,
            invert=False,
            is_save_images=True,
            prefix='op_sample1',
            output_image_format='tif',
        ))
    # Watchpoint: watch 20.0m

    pp = []
    # Sample
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 100.0, 1.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, 0.0
    ])
    # Watchpoint
    # final post-propagation
    pp.append([
        0, 0, 1.0, 0, 0, 0.005, 20.0, 0.005, 20.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, 0.0, 0.0
    ])
    return srwlib.SRWLOptC(el, pp)
Exemple #17
0
        def _createABCDbeamline(A, B, C, D):
            """
            #Use decomposition of ABCD matrix into kick-drift-kick Pei-Huang 2017 (https://arxiv.org/abs/1709.06222)
            #Construct corresponding SRW beamline container object
            #A,B,C,D are 2x2 matrix components.
            """

            f1 = B / (1 - A)
            L = B
            f2 = B / (1 - D)

            optLens1 = srwlib.SRWLOptL(f1, f1)
            optDrift = srwlib.SRWLOptD(L)
            optLens2 = srwlib.SRWLOptL(f2, f2)

            propagParLens1 = [0, 0, 1., 0, 0, 1, 1, 1, 1, 0, 0, 0]
            propagParDrift = [0, 0, 1., 0, 0, 1, 1, 1, 1, 0, 0, 0]
            propagParLens2 = [0, 0, 1., 0, 0, 1, 1, 1, 1, 0, 0, 0]

            return srwlib.SRWLOptC(
                [optLens1, optDrift, optLens2],
                [propagParLens1, propagParDrift, propagParLens2])
Exemple #18
0
def set_optics(v=None):
    el = []
    el.append(
        srwl_uti_smp.srwl_opt_setup_transm_from_file(
            file_path=v.op_sample1,
            resolution=3.96825e-09,  # nm/pixel
            # resolution=0.3*4.950495e-9,  # nm/pixel
            thickness=1e-05,
            delta=3.738856e-05,
            atten_len=3.38902e-06,
            # area=(510, 800, 395, 600),
            area=(688, 688 + 378, 273, 273 + 390),  # (688, 1066, 273, 663)
            # area=None,
            # area=(0, 1280, 0, 834),
            rotate_angle=-30,
            # rotate_angle=0,
            # rotate_reshape=False,  # denser objects
            rotate_reshape=True,  # sparser objects
            cutoff_background_noise=0.5,
            # background_color=100,
            background_color=0,
            invert=False,
            # invert=True,
            tile=(2, 3),
            # tile=(2, 1),
            # tile=None,
            shift_x=-50,
            shift_y=-50,
            is_save_images=True,
            prefix='op_sample1',
            output_image_format=None,
        ))

    pp = []
    pp.append([0, 0, 1.0, 0, 0, 1.0, 150.0, 1.0, 150.0])

    pp.append([0, 0, 1.0, 0, 0, 0.01, 20.0, 0.01, 20.0])
    return srwlib.SRWLOptC(el, pp)
Exemple #19
0
def set_optics(v=None):
    el = []
    # Aperture: aperture 33.1798m
    el.append(srwlib.SRWLOptA("r", "a", 0.00025, 0.00025, 0.0, 0.0))
    el.append(srwlib.SRWLOptD(11.8202))
    # Watchpoint: watch 45.0m

    pp = []
    # Aperture
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    pp.append([
        0, 0, 1.0, 1, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    # Watchpoint
    # final post-propagation
    pp.append([
        0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0
    ])
    return srwlib.SRWLOptC(el, pp)
Exemple #20
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'MOAT_1', 'MOAT_1_MOAT_2', 'MOAT_2', 'MOAT_2_HFM', 'HFM', 'HFM_VFM',
        'VFM', 'VFM_VDM', 'VDM', 'VDM_SSA', 'SSA', 'SSA_ES1', 'ES1', 'ES1_CRL',
        'CRL', 'CRL_ES2', 'ES2'
    ]
    for el_name in names:
        if el_name == 'MOAT_1':
            # MOAT_1: crystal 31.94m
            crystal = srwlib.SRWLOptCryst(
                _d_sp=v.op_MOAT_1_d_sp,
                _psi0r=v.op_MOAT_1_psi0r,
                _psi0i=v.op_MOAT_1_psi0i,
                _psi_hr=v.op_MOAT_1_psiHr,
                _psi_hi=v.op_MOAT_1_psiHi,
                _psi_hbr=v.op_MOAT_1_psiHBr,
                _psi_hbi=v.op_MOAT_1_psiHBi,
                _tc=v.op_MOAT_1_tc,
                _ang_as=v.op_MOAT_1_ang_as,
            )
            crystal.set_orient(
                _nvx=v.op_MOAT_1_nvx,
                _nvy=v.op_MOAT_1_nvy,
                _nvz=v.op_MOAT_1_nvz,
                _tvx=v.op_MOAT_1_tvx,
                _tvy=v.op_MOAT_1_tvy,
            )
            el.append(crystal)
            pp.append(v.op_MOAT_1_pp)
            mirror_file = v.op_MOAT_1_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by MOAT_1 beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_MOAT_1_dim,
                    _ang=abs(v.op_MOAT_1_ang),
                    _amp_coef=v.op_MOAT_1_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'MOAT_1_MOAT_2':
            # MOAT_1_MOAT_2: drift 31.94m
            el.append(srwlib.SRWLOptD(_L=v.op_MOAT_1_MOAT_2_L, ))
            pp.append(v.op_MOAT_1_MOAT_2_pp)
        elif el_name == 'MOAT_2':
            # MOAT_2: crystal 31.99m
            crystal = srwlib.SRWLOptCryst(
                _d_sp=v.op_MOAT_2_d_sp,
                _psi0r=v.op_MOAT_2_psi0r,
                _psi0i=v.op_MOAT_2_psi0i,
                _psi_hr=v.op_MOAT_2_psiHr,
                _psi_hi=v.op_MOAT_2_psiHi,
                _psi_hbr=v.op_MOAT_2_psiHBr,
                _psi_hbi=v.op_MOAT_2_psiHBi,
                _tc=v.op_MOAT_2_tc,
                _ang_as=v.op_MOAT_2_ang_as,
            )
            crystal.set_orient(
                _nvx=v.op_MOAT_2_nvx,
                _nvy=v.op_MOAT_2_nvy,
                _nvz=v.op_MOAT_2_nvz,
                _tvx=v.op_MOAT_2_tvx,
                _tvy=v.op_MOAT_2_tvy,
            )
            el.append(crystal)
            pp.append(v.op_MOAT_2_pp)

        elif el_name == 'MOAT_2_HFM':
            # MOAT_2_HFM: drift 31.99m
            el.append(srwlib.SRWLOptD(_L=v.op_MOAT_2_HFM_L, ))
            pp.append(v.op_MOAT_2_HFM_pp)
        elif el_name == 'HFM':
            # HFM: sphericalMirror 34.88244m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_HFM_r,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)
            mirror_file = v.op_HFM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by HFM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_HFM_dim,
                    _ang=abs(v.op_HFM_ang),
                    _amp_coef=v.op_HFM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'HFM_VFM':
            # HFM_VFM: drift 34.88244m
            el.append(srwlib.SRWLOptD(_L=v.op_HFM_VFM_L, ))
            pp.append(v.op_HFM_VFM_pp)
        elif el_name == 'VFM':
            # VFM: sphericalMirror 38.30244m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_VFM_r,
                    _size_tang=v.op_VFM_size_tang,
                    _size_sag=v.op_VFM_size_sag,
                    _nvx=v.op_VFM_nvx,
                    _nvy=v.op_VFM_nvy,
                    _nvz=v.op_VFM_nvz,
                    _tvx=v.op_VFM_tvx,
                    _tvy=v.op_VFM_tvy,
                    _x=v.op_VFM_x,
                    _y=v.op_VFM_y,
                ))
            pp.append(v.op_VFM_pp)
            mirror_file = v.op_VFM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by VFM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_VFM_dim,
                    _ang=abs(v.op_VFM_ang),
                    _amp_coef=v.op_VFM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'VFM_VDM':
            # VFM_VDM: drift 38.30244m
            el.append(srwlib.SRWLOptD(_L=v.op_VFM_VDM_L, ))
            pp.append(v.op_VFM_VDM_pp)
        elif el_name == 'VDM':
            # VDM: sphericalMirror 39.0m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_VDM_r,
                    _size_tang=v.op_VDM_size_tang,
                    _size_sag=v.op_VDM_size_sag,
                    _nvx=v.op_VDM_nvx,
                    _nvy=v.op_VDM_nvy,
                    _nvz=v.op_VDM_nvz,
                    _tvx=v.op_VDM_tvx,
                    _tvy=v.op_VDM_tvy,
                    _x=v.op_VDM_x,
                    _y=v.op_VDM_y,
                ))
            pp.append(v.op_VDM_pp)
            mirror_file = v.op_VDM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by VDM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_VDM_dim,
                    _ang=abs(v.op_VDM_ang),
                    _amp_coef=v.op_VDM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'VDM_SSA':
            # VDM_SSA: drift 39.0m
            el.append(srwlib.SRWLOptD(_L=v.op_VDM_SSA_L, ))
            pp.append(v.op_VDM_SSA_pp)
        elif el_name == 'SSA':
            # SSA: aperture 47.00244m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_SSA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_SSA_Dx,
                    _Dy=v.op_SSA_Dy,
                    _x=v.op_SSA_x,
                    _y=v.op_SSA_y,
                ))
            pp.append(v.op_SSA_pp)
        elif el_name == 'SSA_ES1':
            # SSA_ES1: drift 47.00244m
            el.append(srwlib.SRWLOptD(_L=v.op_SSA_ES1_L, ))
            pp.append(v.op_SSA_ES1_pp)
        elif el_name == 'ES1':
            # ES1: watch 50.9m
            pass
        elif el_name == 'ES1_CRL':
            # ES1_CRL: drift 50.9m
            el.append(srwlib.SRWLOptD(_L=v.op_ES1_CRL_L, ))
            pp.append(v.op_ES1_CRL_pp)
        elif el_name == 'CRL':
            # CRL: crl 57.335m
            el.append(
                srwlib.srwl_opt_setup_CRL(
                    _foc_plane=v.op_CRL_foc_plane,
                    _delta=v.op_CRL_delta,
                    _atten_len=v.op_CRL_atten_len,
                    _shape=v.op_CRL_shape,
                    _apert_h=v.op_CRL_apert_h,
                    _apert_v=v.op_CRL_apert_v,
                    _r_min=v.op_CRL_r_min,
                    _n=v.op_CRL_n,
                    _wall_thick=v.op_CRL_wall_thick,
                    _xc=v.op_CRL_x,
                    _yc=v.op_CRL_y,
                ))
            pp.append(v.op_CRL_pp)
        elif el_name == 'CRL_ES2':
            # CRL_ES2: drift 57.335m
            el.append(srwlib.SRWLOptD(_L=v.op_CRL_ES2_L, ))
            pp.append(v.op_CRL_ES2_pp)
        elif el_name == 'ES2':
            # ES2: watch 59.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Exemple #21
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'ApM1', 'M1', 'M1_Watchpoint', 'Watchpoint', 'ApKB', 'VFM', 'VFM_HFM',
        'HFM', 'HFM_Sample', 'Sample'
    ]
    for el_name in names:
        if el_name == 'ApM1':
            # ApM1: aperture 270.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_ApM1_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_ApM1_Dx,
                    _Dy=v.op_ApM1_Dy,
                    _x=v.op_ApM1_x,
                    _y=v.op_ApM1_y,
                ))
            pp.append(v.op_ApM1_pp)
        elif el_name == 'M1':
            # M1: mirror 270.0m
            mirror_file = v.op_M1_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by M1 beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_M1_dim,
                    _ang=abs(v.op_M1_ang),
                    _amp_coef=v.op_M1_amp_coef,
                    _size_x=v.op_M1_size_x,
                    _size_y=v.op_M1_size_y,
                ))
            pp.append(v.op_M1_pp)
        elif el_name == 'M1_Watchpoint':
            # M1_Watchpoint: drift 270.0m
            el.append(srwlib.SRWLOptD(_L=v.op_M1_Watchpoint_L, ))
            pp.append(v.op_M1_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 928.3m
            pass
        elif el_name == 'ApKB':
            # ApKB: aperture 928.3m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_ApKB_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_ApKB_Dx,
                    _Dy=v.op_ApKB_Dy,
                    _x=v.op_ApKB_x,
                    _y=v.op_ApKB_y,
                ))
            pp.append(v.op_ApKB_pp)
        elif el_name == 'VFM':
            # VFM: ellipsoidMirror 928.3m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_VFM_p,
                    _q=v.op_VFM_q,
                    _ang_graz=v.op_VFM_ang,
                    _size_tang=v.op_VFM_size_tang,
                    _size_sag=v.op_VFM_size_sag,
                    _nvx=v.op_VFM_nvx,
                    _nvy=v.op_VFM_nvy,
                    _nvz=v.op_VFM_nvz,
                    _tvx=v.op_VFM_tvx,
                    _tvy=v.op_VFM_tvy,
                    _x=v.op_VFM_x,
                    _y=v.op_VFM_y,
                ))
            pp.append(v.op_VFM_pp)
            mirror_file = v.op_VFM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by VFM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_VFM_dim,
                    _ang=abs(v.op_VFM_ang),
                    _amp_coef=v.op_VFM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'VFM_HFM':
            # VFM_HFM: drift 928.3m
            el.append(srwlib.SRWLOptD(_L=v.op_VFM_HFM_L, ))
            pp.append(v.op_VFM_HFM_pp)
        elif el_name == 'HFM':
            # HFM: ellipsoidMirror 928.9m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_HFM_p,
                    _q=v.op_HFM_q,
                    _ang_graz=v.op_HFM_ang,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)
            mirror_file = v.op_HFM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by HFM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_HFM_dim,
                    _ang=abs(v.op_HFM_ang),
                    _amp_coef=v.op_HFM_amp_coef,
                ))
            pp.append([0, 0, 1.0, 0, 0, 1.0, 1.0, 1.0, 1.0])
        elif el_name == 'HFM_Sample':
            # HFM_Sample: drift 928.9m
            el.append(srwlib.SRWLOptD(_L=v.op_HFM_Sample_L, ))
            pp.append(v.op_HFM_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 930.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Exemple #22
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'Fixed_Mask', 'Fixed_Mask_M1A', 'M1A', 'M1A_Watchpoint', 'Watchpoint',
        'M2A_VDM', 'M2A_VDM_Grating', 'Grating', 'Grating_Aperture',
        'Aperture', 'Watchpoint2', 'M3A_HFM', 'M3A_HFM_Watchpoint3',
        'Watchpoint3', 'Pinhole', 'Watchpoint4', 'Watchpoint4_Sample', 'Sample'
    ]
    for el_name in names:
        if el_name == 'Fixed_Mask':
            # Fixed_Mask: aperture 26.2m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Fixed_Mask_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Fixed_Mask_Dx,
                    _Dy=v.op_Fixed_Mask_Dy,
                    _x=v.op_Fixed_Mask_x,
                    _y=v.op_Fixed_Mask_y,
                ))
            pp.append(v.op_Fixed_Mask_pp)
        elif el_name == 'Fixed_Mask_M1A':
            # Fixed_Mask_M1A: drift 26.2m
            el.append(srwlib.SRWLOptD(_L=v.op_Fixed_Mask_M1A_L, ))
            pp.append(v.op_Fixed_Mask_M1A_pp)
        elif el_name == 'M1A':
            # M1A: mirror 27.2m
            mirror_file = v.op_M1A_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by M1A beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_M1A_dim,
                    _ang=abs(v.op_M1A_ang),
                    _amp_coef=v.op_M1A_amp_coef,
                    _size_x=v.op_M1A_size_x,
                    _size_y=v.op_M1A_size_y,
                ))
            pp.append(v.op_M1A_pp)
        elif el_name == 'M1A_Watchpoint':
            # M1A_Watchpoint: drift 27.2m
            el.append(srwlib.SRWLOptD(_L=v.op_M1A_Watchpoint_L, ))
            pp.append(v.op_M1A_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 40.4m
            pass
        elif el_name == 'M2A_VDM':
            # M2A_VDM: mirror 40.4m
            mirror_file = v.op_M2A_VDM_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by M2A_VDM beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_M2A_VDM_dim,
                    _ang=abs(v.op_M2A_VDM_ang),
                    _amp_coef=v.op_M2A_VDM_amp_coef,
                    _size_x=v.op_M2A_VDM_size_x,
                    _size_y=v.op_M2A_VDM_size_y,
                ))
            pp.append(v.op_M2A_VDM_pp)
        elif el_name == 'M2A_VDM_Grating':
            # M2A_VDM_Grating: drift 40.4m
            el.append(srwlib.SRWLOptD(_L=v.op_M2A_VDM_Grating_L, ))
            pp.append(v.op_M2A_VDM_Grating_pp)
        elif el_name == 'Grating':
            # Grating: grating 40.46m
            mirror = srwlib.SRWLOptMirPl(
                _size_tang=v.op_Grating_size_tang,
                _size_sag=v.op_Grating_size_sag,
                _nvx=v.op_Grating_nvx,
                _nvy=v.op_Grating_nvy,
                _nvz=v.op_Grating_nvz,
                _tvx=v.op_Grating_tvx,
                _tvy=v.op_Grating_tvy,
                _x=v.op_Grating_x,
                _y=v.op_Grating_y,
            )
            el.append(
                srwlib.SRWLOptG(
                    _mirSub=mirror,
                    _m=v.op_Grating_m,
                    _grDen=v.op_Grating_grDen,
                    _grDen1=v.op_Grating_grDen1,
                    _grDen2=v.op_Grating_grDen2,
                    _grDen3=v.op_Grating_grDen3,
                    _grDen4=v.op_Grating_grDen4,
                ))
            pp.append(v.op_Grating_pp)
        elif el_name == 'Grating_Aperture':
            # Grating_Aperture: drift 40.46m
            el.append(srwlib.SRWLOptD(_L=v.op_Grating_Aperture_L, ))
            pp.append(v.op_Grating_Aperture_pp)
        elif el_name == 'Aperture':
            # Aperture: aperture 42.46m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Aperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Aperture_Dx,
                    _Dy=v.op_Aperture_Dy,
                    _x=v.op_Aperture_x,
                    _y=v.op_Aperture_y,
                ))
            pp.append(v.op_Aperture_pp)
        elif el_name == 'Watchpoint2':
            # Watchpoint2: watch 42.46m
            pass
        elif el_name == 'M3A_HFM':
            # M3A_HFM: sphericalMirror 42.46m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_M3A_HFM_r,
                    _size_tang=v.op_M3A_HFM_size_tang,
                    _size_sag=v.op_M3A_HFM_size_sag,
                    _nvx=v.op_M3A_HFM_nvx,
                    _nvy=v.op_M3A_HFM_nvy,
                    _nvz=v.op_M3A_HFM_nvz,
                    _tvx=v.op_M3A_HFM_tvx,
                    _tvy=v.op_M3A_HFM_tvy,
                    _x=v.op_M3A_HFM_x,
                    _y=v.op_M3A_HFM_y,
                ))
            pp.append(v.op_M3A_HFM_pp)

        elif el_name == 'M3A_HFM_Watchpoint3':
            # M3A_HFM_Watchpoint3: drift 42.46m
            el.append(srwlib.SRWLOptD(_L=v.op_M3A_HFM_Watchpoint3_L, ))
            pp.append(v.op_M3A_HFM_Watchpoint3_pp)
        elif el_name == 'Watchpoint3':
            # Watchpoint3: watch 54.36m
            pass
        elif el_name == 'Pinhole':
            # Pinhole: aperture 54.36m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Pinhole_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Pinhole_Dx,
                    _Dy=v.op_Pinhole_Dy,
                    _x=v.op_Pinhole_x,
                    _y=v.op_Pinhole_y,
                ))
            pp.append(v.op_Pinhole_pp)
        elif el_name == 'Watchpoint4':
            # Watchpoint4: watch 54.36m
            pass
        elif el_name == 'Watchpoint4_Sample':
            # Watchpoint4_Sample: drift 54.36m
            el.append(srwlib.SRWLOptD(_L=v.op_Watchpoint4_Sample_L, ))
            pp.append(v.op_Watchpoint4_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 55.5m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
def propagator2d_srw(p_x,p_y,amplitude,propagation_distance=1.0,wavelength=1e-10):
    #
    # convolving with the Fresnel kernel via SRW package
    #
    import srwlib
    from NumpyToSRW import numpyArrayToSRWArray, SRWWavefrontFromElectricField, SRWEFieldAsNumpy

    # srw_amplituder = numpyArrayToSRWArray(amplitude)
    # print(type(srw_amplituder))



    srw_wfr = SRWWavefrontFromElectricField(p_x[0], p_x[-1], amplitude,
                                  p_y[0], p_y[-1], np.zeros_like(amplitude),
                                  12396.0/(wavelength*1e10), 1.0, 1.0, 1e-3, 1.0, 1e-3)

    print(type(srw_wfr))


    #
    # propagation
    #
    optDrift = srwlib.SRWLOptD(propagation_distance) #Drift space

    #                 0  1  2   3  4  5   6   7   8   9 10 11
    # propagParDrift = [1, 1, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]
    propagParDrift = [0, 0, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]
    #Wavefront Propagation Parameters:
    #[0]: Auto-Resize (1) or not (0) Before propagation
    #[1]: Auto-Resize (1) or not (0) After propagation
    #[2]: Relative Precision for propagation with Auto-Resizing (1. is nominal)
    #[3]: Allow (1) or not (0) for semi-analytical treatment of the quadratic (leading) phase terms at the propagation
    #[4]: Do any Resizing on Fourier side, using FFT, (1) or not (0)
    #[5]: Horizontal Range modification factor at Resizing (1. means no modification)
    #[6]: Horizontal Resolution modification factor at Resizing
    #[7]: Vertical Range modification factor at Resizing
    #[8]: Vertical Resolution modification factor at Resizing
    #[9]: Type of wavefront Shift before Resizing (not yet implemented)
    #[10]: New Horizontal wavefront Center position after Shift (not yet implemented)
    #[11]: New Vertical wavefront Center position after Shift (not yet implemented)
    optBL = srwlib.SRWLOptC([optDrift], [propagParDrift]) #"Beamline" - Container of Optical Elements (together with the corresponding wavefront propagation instructions)

    print('   Simulating Electric Field Wavefront Propagation bu SRW ... ', end='\n')
    srwlib.srwl.PropagElecField(srw_wfr, optBL)


    amplitude2 = SRWEFieldAsNumpy(srw_wfr)
    amplitude2 = amplitude2[0,:,:,0]
    print("Amplitude shape before:",amplitude.shape,"; after: ",amplitude2.shape)



    # fft = np.fft.fft2(amplitude)
    #
    # # frequency for axis 1
    # pixelsize = p_x[1] - p_x[0]
    # npixels = p_x.size
    # freq_nyquist = 0.5/pixelsize
    # freq_n = np.linspace(-1.0,1.0,npixels)
    # freq_x = freq_n * freq_nyquist
    # # freq = freq * wavelength
    #
    # # frequency for axis 2
    # pixelsize = p_y[1] - p_y[0]
    # npixels = p_y.size
    # freq_nyquist = 0.5/pixelsize
    # freq_n = np.linspace(-1.0,1.0,npixels)
    # freq_y = freq_n * freq_nyquist
    # # freq_y = freq_y * wavelength
    #
    # freq_xy = np.array(np.meshgrid(freq_y,freq_x))
    #
    # fft *= np.exp((-1.0j) * np.pi * wavelength * propagation_distance *
    #               np.fft.fftshift(freq_xy[0]*freq_xy[0] + freq_xy[1]*freq_xy[1]) )
    # ifft = np.fft.ifft2(fft)

    p_x2 = np.linspace(srw_wfr.mesh.xStart, srw_wfr.mesh.xFin, srw_wfr.mesh.nx)
    p_y2 = np.linspace(srw_wfr.mesh.yStart, srw_wfr.mesh.yFin, srw_wfr.mesh.ny)

    return p_x2,p_y2,amplitude2
Exemple #24
0
 def __init__(self, f):
     self.length = 0
     self._srwc = srwlib.SRWLOptC(
         [srwlib.SRWLOptL(f, f)],
         [[0, 0, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]])
Exemple #25
0
 def __init__(self, length):
     self.length = length
     self._srwc = srwlib.SRWLOptC(
         [srwlib.SRWLOptD(length)],
         [[0, 0, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]],
     )
Exemple #26
0
 def _createDriftBL(Lc):
     optDrift = srwlib.SRWLOptD(Lc)
     propagParDrift = [0, 0, 1., 0, 0, 1., 1., 1., 1., 0, 0, 0]
     #propagParDrift = [0, 0, 1., 0, 0, 1.1, 1.2, 1.1, 1.2, 0, 0, 0]
     return srwlib.SRWLOptC([optDrift], [propagParDrift])
Exemple #27
0
    def __init__(self,
                 slice_index,
                 nslice,
                 sigrW=0.00043698412731784714,
                 propLen=15,
                 sig_s=0.1,
                 pulseE=0.001,
                 poltype=1,
                 phE=1.55,
                 sampFact=5,
                 mx=0,
                 my=0,
                 **_ignore_kwargs):
        """
        #nslice: number of slices of laser pulse
        #slice_index: index of slice
        #sigrW: beam size at waist [m]
        #propLen: propagation length [m] required by SRW to create numerical Gaussian
        #propLen=15,
        #sig_s RMS pulse length [m]
        #pulseE: energy per pulse [J]
        #poltype: polarization type (0=linear horizontal, 1=linear vertical, 2=linear 45 deg, 3=linear 135 deg, 4=circular right, 5=circular left, 6=total)
        #phE: photon energy [eV]
        #sampFact: sampling factor to increase mesh density
        """
        #print([sigrW,propLen,pulseE,poltype])
        self.slice_index = slice_index
        self.phE = phE
        constConvRad = 1.23984186e-06 / (
            4 * 3.1415926536)  ##conversion from energy to 1/wavelength
        rmsAngDiv = constConvRad / (phE * sigrW
                                    )  ##RMS angular divergence [rad]
        sigrL = math.sqrt(
            sigrW**2 + (propLen * rmsAngDiv)**2
        )  ##required RMS size to produce requested RMS beam size after propagation by propLen

        #***********Gaussian Beam Source
        GsnBm = srwlib.SRWLGsnBm()  #Gaussian Beam structure (just parameters)
        GsnBm.x = 0  #Transverse Positions of Gaussian Beam Center at Waist [m]
        GsnBm.y = 0
        numsig = 5.  #Number of sigma values to track. Total range is 2*numsig*sig_s
        ds = 2 * numsig * sig_s / (nslice - 1)
        self._pulse_pos = -numsig * sig_s + slice_index * ds
        GsnBm.z = propLen + self._pulse_pos  #Longitudinal Position of Waist [m]
        GsnBm.xp = 0  #Average Angles of Gaussian Beam at Waist [rad]
        GsnBm.yp = 0
        GsnBm.avgPhotEn = phE  #Photon Energy [eV]
        GsnBm.pulseEn = pulseE * np.exp(
            -self._pulse_pos**2 /
            (2 * sig_s**2))  #Energy per Pulse [J] - to be corrected
        GsnBm.repRate = 1  #Rep. Rate [Hz] - to be corrected
        GsnBm.polar = poltype  #1- linear horizontal?
        GsnBm.sigX = sigrW  #Horiz. RMS size at Waist [m]
        GsnBm.sigY = GsnBm.sigX  #Vert. RMS size at Waist [m]

        GsnBm.sigT = 10e-15  #Pulse duration [s] (not used?)
        GsnBm.mx = mx  #Transverse Gauss-Hermite Mode Orders
        GsnBm.my = my

        #***********Initial Wavefront
        wfr = srwlib.SRWLWfr()  #Initial Electric Field Wavefront
        wfr.allocate(
            1, 1000, 1000
        )  #Numbers of points vs Photon Energy (1), Horizontal and Vertical Positions (dummy)
        wfr.mesh.zStart = 0.0  #Longitudinal Position [m] at which initial Electric Field has to be calculated, i.e. the position of the first optical element
        wfr.mesh.eStart = GsnBm.avgPhotEn  #Initial Photon Energy [eV]
        wfr.mesh.eFin = GsnBm.avgPhotEn  #Final Photon Energy [eV]

        wfr.unitElFld = 1  #Electric field units: 0- arbitrary, 1- sqrt(Phot/s/0.1%bw/mm^2), 2- sqrt(J/eV/mm^2) or sqrt(W/mm^2), depending on representation (freq. or time)

        distSrc = wfr.mesh.zStart - GsnBm.z
        #Horizontal and Vertical Position Range for the Initial Wavefront calculation
        #can be used to simulate the First Aperture (of M1)
        #firstHorAp = 8.*rmsAngDiv*distSrc #[m]
        xAp = 8. * sigrL
        yAp = xAp  #[m]

        wfr.mesh.xStart = -0.5 * xAp  #Initial Horizontal Position [m]
        wfr.mesh.xFin = 0.5 * xAp  #Final Horizontal Position [m]
        wfr.mesh.yStart = -0.5 * yAp  #Initial Vertical Position [m]
        wfr.mesh.yFin = 0.5 * yAp  #Final Vertical Position [m]

        sampFactNxNyForProp = sampFact  #sampling factor for adjusting nx, ny (effective if > 0)
        arPrecPar = [sampFactNxNyForProp]

        srwlib.srwl.CalcElecFieldGaussian(wfr, GsnBm, arPrecPar)

        ##Beamline to propagate to waist

        optDriftW = srwlib.SRWLOptD(propLen)
        propagParDrift = [0, 0, 1., 0, 0, 1.1, 1.2, 1.1, 1.2, 0, 0, 0]
        optBLW = srwlib.SRWLOptC([optDriftW], [propagParDrift])
        #wfrW=deepcopy(wfr)
        srwlib.srwl.PropagElecField(wfr, optBLW)
        self._wfr = wfr
Exemple #28
0
def set_optics(v=None):
    el = []
    pp = []
    for el_name in names:
        if el_name == 'Aperture':
            # Aperture: aperture 20.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_Aperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_Aperture_Dx,
                    _Dy=v.op_Aperture_Dy,
                    _x=v.op_Aperture_x,
                    _y=v.op_Aperture_y,
                ))
            pp.append(v.op_Aperture_pp)
        elif el_name == 'Aperture_HFM':
            # Aperture_HFM: drift 20.0m
            el.append(srwlib.SRWLOptD(_L=v.op_Aperture_HFM_L, ))
            pp.append(v.op_Aperture_HFM_pp)
        elif el_name == 'HFM':
            # HFM: sphericalMirror 42.0m
            el.append(
                srwlib.SRWLOptMirSph(
                    _r=v.op_HFM_r,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)

        elif el_name == 'Watchpoint':
            # Watchpoint: watch 42.0m
            pass
        elif el_name == 'Watchpoint_Watchpoint2':
            # Watchpoint_Watchpoint2: drift 42.0m
            el.append(srwlib.SRWLOptD(_L=v.op_Watchpoint_Watchpoint2_L, ))
            pp.append(v.op_Watchpoint_Watchpoint2_pp)
        elif el_name == 'Watchpoint2':
            # Watchpoint2: watch 55.0m
            pass
        elif el_name == 'SSA':
            # SSA: aperture 55.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_SSA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_SSA_Dx,
                    _Dy=v.op_SSA_Dy,
                    _x=v.op_SSA_x,
                    _y=v.op_SSA_y,
                ))
            pp.append(v.op_SSA_pp)
        elif el_name == 'SSA_Watchpoint3':
            # SSA_Watchpoint3: drift 55.0m
            el.append(srwlib.SRWLOptD(_L=v.op_SSA_Watchpoint3_L, ))
            pp.append(v.op_SSA_Watchpoint3_pp)
        elif el_name == 'Watchpoint3':
            # Watchpoint3: watch 66.0m
            pass
        elif el_name == 'KB_Aperture':
            # KB_Aperture: aperture 66.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_KB_Aperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_KB_Aperture_Dx,
                    _Dy=v.op_KB_Aperture_Dy,
                    _x=v.op_KB_Aperture_x,
                    _y=v.op_KB_Aperture_y,
                ))
            pp.append(v.op_KB_Aperture_pp)
        elif el_name == 'KB_Aperture_KBh':
            # KB_Aperture_KBh: drift 66.0m
            el.append(srwlib.SRWLOptD(_L=v.op_KB_Aperture_KBh_L, ))
            pp.append(v.op_KB_Aperture_KBh_pp)
        elif el_name == 'KBh':
            # KBh: ellipsoidMirror 66.5m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_KBh_p,
                    _q=v.op_KBh_q,
                    _ang_graz=v.op_KBh_ang,
                    _size_tang=v.op_KBh_size_tang,
                    _size_sag=v.op_KBh_size_sag,
                    _nvx=v.op_KBh_nvx,
                    _nvy=v.op_KBh_nvy,
                    _nvz=v.op_KBh_nvz,
                    _tvx=v.op_KBh_tvx,
                    _tvy=v.op_KBh_tvy,
                    _x=v.op_KBh_x,
                    _y=v.op_KBh_y,
                ))
            pp.append(v.op_KBh_pp)

        elif el_name == 'KBh_Sample':
            # KBh_Sample: drift 66.5m
            el.append(srwlib.SRWLOptD(_L=v.op_KBh_Sample_L, ))
            pp.append(v.op_KBh_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 67.0m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
Exemple #29
0
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'VFM', 'VFM_HFM', 'HFM', 'HFM_Watchpoint', 'Watchpoint',
        'Watchpoint_Mask', 'Mask', 'Watchpoint2'
    ]
    for el_name in names:
        if el_name == 'VFM':
            # VFM: ellipsoidMirror 50.0m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_VFM_p,
                    _q=v.op_VFM_q,
                    _ang_graz=v.op_VFM_ang,
                    _size_tang=v.op_VFM_size_tang,
                    _size_sag=v.op_VFM_size_sag,
                    _nvx=v.op_VFM_nvx,
                    _nvy=v.op_VFM_nvy,
                    _nvz=v.op_VFM_nvz,
                    _tvx=v.op_VFM_tvx,
                    _tvy=v.op_VFM_tvy,
                    _x=v.op_VFM_x,
                    _y=v.op_VFM_y,
                ))
            pp.append(v.op_VFM_pp)

        elif el_name == 'VFM_HFM':
            # VFM_HFM: drift 50.0m
            el.append(srwlib.SRWLOptD(_L=v.op_VFM_HFM_L, ))
            pp.append(v.op_VFM_HFM_pp)
        elif el_name == 'HFM':
            # HFM: ellipsoidMirror 50.2m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_HFM_p,
                    _q=v.op_HFM_q,
                    _ang_graz=v.op_HFM_ang,
                    _size_tang=v.op_HFM_size_tang,
                    _size_sag=v.op_HFM_size_sag,
                    _nvx=v.op_HFM_nvx,
                    _nvy=v.op_HFM_nvy,
                    _nvz=v.op_HFM_nvz,
                    _tvx=v.op_HFM_tvx,
                    _tvy=v.op_HFM_tvy,
                    _x=v.op_HFM_x,
                    _y=v.op_HFM_y,
                ))
            pp.append(v.op_HFM_pp)

        elif el_name == 'HFM_Watchpoint':
            # HFM_Watchpoint: drift 50.2m
            el.append(srwlib.SRWLOptD(_L=v.op_HFM_Watchpoint_L, ))
            pp.append(v.op_HFM_Watchpoint_pp)
        elif el_name == 'Watchpoint':
            # Watchpoint: watch 50.4m
            pass
        elif el_name == 'Watchpoint_Mask':
            # Watchpoint_Mask: drift 50.4m
            el.append(srwlib.SRWLOptD(_L=v.op_Watchpoint_Mask_L, ))
            pp.append(v.op_Watchpoint_Mask_pp)
        elif el_name == 'Mask':
            # Mask: mask 50.6m
            el.append(
                srwlib.srwl_opt_setup_mask(
                    _delta=v.op_Mask_delta,
                    _atten_len=v.op_Mask_atten_len,
                    _thick=v.op_Mask_thick,
                    _grid_sh=v.op_Mask_grid_sh,
                    _grid_dx=v.op_Mask_grid_dx,
                    _grid_dy=v.op_Mask_grid_dy,
                    _pitch_x=v.op_Mask_pitch_x,
                    _pitch_y=v.op_Mask_pitch_y,
                    _grid_nx=v.op_Mask_grid_nx,
                    _grid_ny=v.op_Mask_grid_ny,
                    _mask_Nx=v.op_Mask_mask_Nx,
                    _mask_Ny=v.op_Mask_mask_Ny,
                    _grid_angle=v.op_Mask_gridTiltAngle,
                    _hx=v.op_Mask_hx,
                    _hy=v.op_Mask_hy,
                    _mask_x0=v.op_Mask_mask_x0,
                    _mask_y0=v.op_Mask_mask_y0,
                ))
            pp.append(v.op_Mask_pp)
        elif el_name == 'Watchpoint2':
            # Watchpoint2: watch 50.6m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)
def set_optics(v=None):
    el = []
    pp = []
    names = [
        'M1', 'M1_Grating', 'Grating', 'GA', 'GA_M3A', 'M3A', 'M3', 'M3_SSA',
        'SSA', 'SSA_KBAperture', 'KBAperture', 'KBh', 'KBh_KBv', 'KBv',
        'KBv_Sample', 'Sample'
    ]
    for el_name in names:
        if el_name == 'M1':
            # M1: mirror 34.366m
            mirror_file = v.op_M1_hfn
            assert os.path.isfile(mirror_file), \
                'Missing input file {}, required by M1 beamline element'.format(mirror_file)
            el.append(
                srwlib.srwl_opt_setup_surf_height_1d(
                    srwlib.srwl_uti_read_data_cols(mirror_file, "\t", 0, 1),
                    _dim=v.op_M1_dim,
                    _ang=abs(v.op_M1_ang),
                    _amp_coef=v.op_M1_amp_coef,
                    _size_x=v.op_M1_size_x,
                    _size_y=v.op_M1_size_y,
                ))
            pp.append(v.op_M1_pp)
        elif el_name == 'M1_Grating':
            # M1_Grating: drift 34.366m
            el.append(srwlib.SRWLOptD(_L=v.op_M1_Grating_L, ))
            pp.append(v.op_M1_Grating_pp)
        elif el_name == 'Grating':
            # Grating: grating 55.0m
            mirror = srwlib.SRWLOptMirPl(
                _size_tang=v.op_Grating_size_tang,
                _size_sag=v.op_Grating_size_sag,
                _nvx=v.op_Grating_nvx,
                _nvy=v.op_Grating_nvy,
                _nvz=v.op_Grating_nvz,
                _tvx=v.op_Grating_tvx,
                _tvy=v.op_Grating_tvy,
                _x=v.op_Grating_x,
                _y=v.op_Grating_y,
            )
            el.append(
                srwlib.SRWLOptG(
                    _mirSub=mirror,
                    _m=v.op_Grating_m,
                    _grDen=v.op_Grating_grDen,
                    _grDen1=v.op_Grating_grDen1,
                    _grDen2=v.op_Grating_grDen2,
                    _grDen3=v.op_Grating_grDen3,
                    _grDen4=v.op_Grating_grDen4,
                ))
            pp.append(v.op_Grating_pp)
        elif el_name == 'GA':
            # GA: aperture 55.0m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_GA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_GA_Dx,
                    _Dy=v.op_GA_Dy,
                    _x=v.op_GA_x,
                    _y=v.op_GA_y,
                ))
            pp.append(v.op_GA_pp)
        elif el_name == 'GA_M3A':
            # GA_M3A: drift 55.0m
            el.append(srwlib.SRWLOptD(_L=v.op_GA_M3A_L, ))
            pp.append(v.op_GA_M3A_pp)
        elif el_name == 'M3A':
            # M3A: aperture 89.63m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_M3A_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_M3A_Dx,
                    _Dy=v.op_M3A_Dy,
                    _x=v.op_M3A_x,
                    _y=v.op_M3A_y,
                ))
            pp.append(v.op_M3A_pp)
        elif el_name == 'M3':
            # M3: ellipsoidMirror 89.63m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_M3_p,
                    _q=v.op_M3_q,
                    _ang_graz=v.op_M3_ang,
                    _size_tang=v.op_M3_size_tang,
                    _size_sag=v.op_M3_size_sag,
                    _nvx=v.op_M3_nvx,
                    _nvy=v.op_M3_nvy,
                    _nvz=v.op_M3_nvz,
                    _tvx=v.op_M3_tvx,
                    _tvy=v.op_M3_tvy,
                    _x=v.op_M3_x,
                    _y=v.op_M3_y,
                ))
            pp.append(v.op_M3_pp)

        elif el_name == 'M3_SSA':
            # M3_SSA: drift 89.63m
            el.append(srwlib.SRWLOptD(_L=v.op_M3_SSA_L, ))
            pp.append(v.op_M3_SSA_pp)
        elif el_name == 'SSA':
            # SSA: aperture 97.636m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_SSA_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_SSA_Dx,
                    _Dy=v.op_SSA_Dy,
                    _x=v.op_SSA_x,
                    _y=v.op_SSA_y,
                ))
            pp.append(v.op_SSA_pp)
        elif el_name == 'SSA_KBAperture':
            # SSA_KBAperture: drift 97.636m
            el.append(srwlib.SRWLOptD(_L=v.op_SSA_KBAperture_L, ))
            pp.append(v.op_SSA_KBAperture_pp)
        elif el_name == 'KBAperture':
            # KBAperture: aperture 103.646m
            el.append(
                srwlib.SRWLOptA(
                    _shape=v.op_KBAperture_shape,
                    _ap_or_ob='a',
                    _Dx=v.op_KBAperture_Dx,
                    _Dy=v.op_KBAperture_Dy,
                    _x=v.op_KBAperture_x,
                    _y=v.op_KBAperture_y,
                ))
            pp.append(v.op_KBAperture_pp)
        elif el_name == 'KBh':
            # KBh: ellipsoidMirror 103.646m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_KBh_p,
                    _q=v.op_KBh_q,
                    _ang_graz=v.op_KBh_ang,
                    _size_tang=v.op_KBh_size_tang,
                    _size_sag=v.op_KBh_size_sag,
                    _nvx=v.op_KBh_nvx,
                    _nvy=v.op_KBh_nvy,
                    _nvz=v.op_KBh_nvz,
                    _tvx=v.op_KBh_tvx,
                    _tvy=v.op_KBh_tvy,
                    _x=v.op_KBh_x,
                    _y=v.op_KBh_y,
                ))
            pp.append(v.op_KBh_pp)

        elif el_name == 'KBh_KBv':
            # KBh_KBv: drift 103.646m
            el.append(srwlib.SRWLOptD(_L=v.op_KBh_KBv_L, ))
            pp.append(v.op_KBh_KBv_pp)
        elif el_name == 'KBv':
            # KBv: ellipsoidMirror 104.146m
            el.append(
                srwlib.SRWLOptMirEl(
                    _p=v.op_KBv_p,
                    _q=v.op_KBv_q,
                    _ang_graz=v.op_KBv_ang,
                    _size_tang=v.op_KBv_size_tang,
                    _size_sag=v.op_KBv_size_sag,
                    _nvx=v.op_KBv_nvx,
                    _nvy=v.op_KBv_nvy,
                    _nvz=v.op_KBv_nvz,
                    _tvx=v.op_KBv_tvx,
                    _tvy=v.op_KBv_tvy,
                    _x=v.op_KBv_x,
                    _y=v.op_KBv_y,
                ))
            pp.append(v.op_KBv_pp)

        elif el_name == 'KBv_Sample':
            # KBv_Sample: drift 104.146m
            el.append(srwlib.SRWLOptD(_L=v.op_KBv_Sample_L, ))
            pp.append(v.op_KBv_Sample_pp)
        elif el_name == 'Sample':
            # Sample: watch 104.557m
            pass
    pp.append(v.op_fin_pp)
    return srwlib.SRWLOptC(el, pp)