wpg.optical_elements
module¶
This module contains definitions custom optical elements.
Described mapping (or aliases) of some of SRW optical elements (SRWLOpt* <-> wpg)
-
wpg.optical_elements.
Aperture
(shape, ap_or_ob, Dx, Dy=1e+23, x=0, y=0)[source]¶ Defining an aperture/obstacle propagator: A wrapper to a SRWL function SRWLOptA()
Parameters: - shape – ‘r’ for rectangular, ‘c’ for circular
- ap_or_ob – ‘a’ for aperture, ‘o’ for obstacle
- Dy (Dx,) – transverse dimensions [m]; in case of circular aperture, only Dx is used for diameter
- y (x,) – transverse coordinates of center [m]
Returns: opAp - aperture propagator,
struct SRWLOptA
-
wpg.optical_elements.
CRL
(_foc_plane, _delta, _atten_len, _shape, _apert_h, _apert_v, _r_min, _n, _wall_thick, _xc, _yc, _void_cen_rad=None, _e_start=0, _e_fin=0, _nx=1001, _ny=1001)[source]¶ Setup Transmission type Optical Element which simulates Compound Refractive Lens (CRL).
Parameters: - _foc_plane – plane of focusing: 1- horizontal, 2- vertical, 3- both
- _delta – refractive index decrement (can be one number of array vs photon energy)
- _atten_len – attenuation length [m] (can be one number of array vs photon energy)
- _shape – 1- parabolic, 2- circular (spherical)
- _apert_h – horizontal aperture size [m]
- _apert_v – vertical aperture size [m]
- _r_min – radius (on tip of parabola for parabolic shape) [m]
- _n – number of lenses (/”holes”)
- _wall_thick – min. wall thickness between “holes” [m]
- _xc – horizontal coordinate of center [m]
- _yc – vertical coordinate of center [m]
- _void_cen_rad – flat array/list of void center coordinates and radii: [x1, y1, r1, x2, y2, r2,…]
- _e_start – initial photon energy
- _e_fin – final photon energy
Returns: transmission (SRWLOptT) type optical element which simulates CRL
-
class
wpg.optical_elements.
Empty
[source]¶ Bases:
wpg.optical_elements.WPGOpticalElement
Optical element: Empty. This is empty propagator used for sampling and zooming wavefront
-
wpg.optical_elements.
Mirror_elliptical
(orient, p, q, thetaE, theta0, length)[source]¶ Defining a plane elliptical focusing mirror propagator: A wrapper to a SRWL function SRWLOptMirEl()
Parameters: - orient – mirror orientation, ‘x’ (horizontal) or ‘y’ (vertical)
- p – distance to one ellipsis center (source), [m]
- q – distance to the other ellipsis center (focus), [m]
- thetaE – design incidence angle in the center of mirror, [rad]
- theta0 – “real” incidence angle in the center of mirror, [rad]
- length – mirror length, [m]
Returns: opEFM - elliptical mirror propagator,
struct SRWLOptMirEl
-
wpg.optical_elements.
Mirror_plane
(orient, theta, length, range_xy, filename, scale=1, delim='\t')[source]¶ Defining a plane mirror propagator with taking into account surface height errors
Parameters: - orient – mirror orientation, ‘x’ (horizontal) or ‘y’ (vertical)
- theta – incidence angle [rad]
- length – mirror length, [m]
Range_xy: range in which the incident WF defined [m]
Filename: full file name with mirror profile of two columns, x and h(x) - heigh errors [m]
Scale: scale factor, optical path difference OPD = 2*h*scale*sin(theta)
Delim: delimiter between data columns
Returns: opIPM - imperfect plane mirror propagator
-
class
wpg.optical_elements.
Use_PP
(auto_resize_before=None, auto_resize_after=None, releative_precision=None, semi_analytical_treatment=None, fft_resizing=None, zoom=None, zoom_h=None, zoom_v=None, sampling=None, sampling_h=None, sampling_v=None, srw_pp=None)[source]¶ Bases:
object
Short version of propagation parameters. Should be used with wpg.beamline.Beamline
Params srw_pp: propagation parameters in srw style -
auto_resize_after
¶ Auto-Resize (1) or not (0) After propagation
-
auto_resize_before
¶ Auto-Resize (1) or not (0) Before propagation
-
fft_resizing
¶ Do any Resizing on Fourier side, using FFT, (1) or not (0)
-
get_srw_pp
()[source]¶ Return SRW propagation parameters list. Useful for interoperations with SRW tools.
Returns: list of floats (propagation parameters)
-
releative_precision
¶ Relative Precision for propagation with Auto-Resizing (1. is nominal)
-
sampling
¶ Resolution modification factor at Resizing
-
sampling_h
¶ Horizontal Resolution modification factor at Resizing
-
sampling_v
¶ Vertical Resolution modification factor at Resizing
-
semi_analytical_treatment
¶ Allow (1) or not (0) for semi-analytical treatment of quadratic phase terms at propagation
-
zoom
¶ Range modification factor at Resizing (1. means no modification)
-
zoom_h
¶ Horizontal Range modification factor at Resizing (1. means no modification)
-
zoom_v
¶ Vertical Range modification factor at Resizing
-
-
wpg.optical_elements.
VLS_grating
(_mirSub, _m=1, _grDen=100, _grDen1=0, _grDen2=0, _grDen3=0, _grDen4=0, _grAng=0)[source]¶ Optical Element: Grating.
param _mirSub: SRWLOptMir (or derived) type object defining substrate of the grating :param _m: output (diffraction) order :param _grDen: groove density [lines/mm] (coefficient a0 in the polynomial groove density: a0 + a1*y + a2*y^2 + a3*y^3 + a4*y^4) :param _grDen1: groove density polynomial coefficient a1 [lines/mm^2] :param _grDen2: groove density polynomial coefficient a2 [lines/mm^3] :param _grDen3: groove density polynomial coefficient a3 [lines/mm^4] :param _grDen4: groove density polynomial coefficient a4 [lines/mm^5] :param _grAng: angle between the grove direction and the saggital direction of the substrate [rad] (by default, groves are made along saggital direction (_grAng=0))
-
wpg.optical_elements.
WF_dist
(nx, ny, Dx, Dy)[source]¶ Create a ‘phase screen’ propagator for wavefront distortions: A wrapper to SRWL struct SRWLOptT
Params nx: number of points in horizontal direction Params ny: number of points in vertical direction Params Dx: size in m Params Dy: size in
-
class
wpg.optical_elements.
WPGOpticalElement
[source]¶ Bases:
object
Base class for optical elements.
-
wpg.optical_elements.
Xtal
(_d_sp=5.4309, _psi0r=-1.446e-05, _psi0i=3.202e-07, _psi_hr=8.8004e-06, _psi_hi=3.0808e-07, _psi_hbr=8.8004e-06, _psi_hbi=3.0808e-07, _tc=0.0001, _ang_as=0)[source]¶ Optical Element: Crystal.
Parameters: - _d_sp – (_d_space) crystal reflecting planes d-spacing (John’s dA) [A]
- _psi0r – real part of 0-th Fourier component of crystal polarizability (John’s psi0c.real) (units?)
- _psi0i – imaginary part of 0-th Fourier component of crystal polarizability (John’s psi0c.imag) (units?)
- _psi_hr – (_psiHr) real part of H-th Fourier component of crystal polarizability (John’s psihc.real) (units?)
- _psi_hi – (_psiHi) imaginary part of H-th Fourier component of crystal polarizability (John’s psihc.imag) (units?)
- _psi_hbr – (_psiHBr:) real part of -H-th Fourier component of crystal polarizability (John’s psimhc.real) (units?)
- _psi_hbi – (_psiHBi:) imaginary part of -H-th Fourier component of crystal polarizability (John’s psimhc.imag) (units?)
- _tc – crystal thickness [m] (John’s thicum)
- _ang_as – (_Tasym) asymmetry angle [rad] (John’s alphdg)
- _nvx – horizontal coordinate of outward normal to crystal surface (John’s angles: thdg, chidg, phidg)
- _nvy – vertical coordinate of outward normal to crystal surface (John’s angles: thdg, chidg, phidg)
- _nvz – longitudinal coordinate of outward normal to crystal surface (John’s angles: thdg, chidg, phidg)
- _tvx – horizontal coordinate of central tangential vector (John’s angles: thdg, chidg, phidg)
- _tvy – vertical coordinate of central tangential vector (John’s angles: thdg, chidg, phidg)
-
wpg.optical_elements.
append_Xtal
(bl, xtal='C', h=1, k=1, l=1, tc=0.0001, _dE=0.0, doPrint=False)[source]¶ Append to a beamline Xtal propagator
Parameters: bl – Beamline() structure
-
wpg.optical_elements.
calculateOPD
(wf_dist, mdatafile, ncol, delim, Orient, theta, scale=1.0, stretching=1.0)[source]¶ Calculates optical path difference (OPD) from mirror profile and fills the struct wf_dist (
struct SRWLOptT
) for wavefront distortionsParams wf_dist: struct SRWLOptT Params mdatafile: an ascii file with mirror profile data Params ncol: number of columns in the file Params delim: delimiter between numbers in an row, can be space (‘ ‘), tab ‘ ‘, etc Params orient: mirror orientation, ‘x’ (horizontal) or ‘y’ (vertical) Params theta: incidence angle Params scale: scaling factor for the mirror profile Parameters: stretching – scaling factor for the mirror profile x-axis (@TODO a hack, should be removed ASAP) :return filled
-
wpg.optical_elements.
define_Xtal
(xtal='C', h=4, k=0, l=0, tc=0.0001, idx=0, _dE=0.0, doPrint=False)[source]¶ Parameters: - xtal – crystal type (now only ‘Si’ and ‘C’ are suppoted)
- h,k,l – Miller indices
- tc – crystal thickness, [m]
- idx – the given photon energy line number in crystal parameters tables (ascii files ‘<xtal>_xih_<hkl>.dat’ and ‘<xtal>_xi0.dat’)
- _dE – photon energy offset, eV
- doPrint – if True additional printouts for crystal orientation matrixes
:return
-
wpg.optical_elements.
Drift
¶ alias of
wpg.srwlib.SRWLOptD
-
wpg.optical_elements.
Lens
¶ alias of
wpg.srwlib.SRWLOptL
-
class
wpg.optical_elements.
Aperture
[source] Defining an aperture/obstacle propagator: A wrapper to a SRWL function SRWLOptA()
Parameters: - shape – ‘r’ for rectangular, ‘c’ for circular
- ap_or_ob – ‘a’ for aperture, ‘o’ for obstacle
- Dy (Dx,) – transverse dimensions [m]; in case of circular aperture, only Dx is used for diameter
- y (x,) – transverse coordinates of center [m]
Returns: opAp - aperture propagator,
struct SRWLOptA
-
class
wpg.optical_elements.
WF_dist
[source] Create a ‘phase screen’ propagator for wavefront distortions: A wrapper to SRWL struct SRWLOptT
Params nx: number of points in horizontal direction Params ny: number of points in vertical direction Params Dx: size in m Params Dy: size in