wpg.optical_elements
module¶
This module contains definitions of 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, roll=0.0, yaw=0.0, distance=0.0)[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] :param roll: misaligned roll axis :param yaw: misaligned yaw axis
Returns: opEFM - elliptical mirror propagator,
struct SRWLOptMirEl
-
wpg.optical_elements.
Mirror_plane
(orient, theta, length, range_xy, filename, scale=1, delim=' ', xscale=1, x0=0.0, bPlot=False)[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 –
- height errors scale factor, optical path difference OPD = 2*h*scale*sin(theta)
- delim – delimiter between data columns
- xscale – scaling factor for the mirror profile x-axis (for taking an arbitrary scaled axis, i.e. im mm)
- x0 – shift of mirror longitudinal position [m]
Returns: opIPM - imperfect plane mirror propagator
-
wpg.optical_elements.
Mirror_plane_2d
(orient, theta, length, range_xy, filename, scale=1, x0=0.0, y0=0.0, xscale=1.0, yscale=1.0, bPlot=False)[source]¶ Defining a plane mirror propagator with taking into account 2D 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 2d mirror profile of three columns, x, y, and h(x, y) - heigh errors [m]
- scale – scale factor, optical path difference OPD = 2*h*scale*sin(theta)
- x0 – shift of mirror longitudinal position [m]
- y0 – shift of mirror transverse position [m]
- xscale – units of 1st column of filename, x[m]=x[nits]*xscale [m]
- yscale – units of 1st column of filename, y[m]=y[nits]*yscale [m]
Returns: opIPM - imperfect plane mirror propagator
-
class
wpg.optical_elements.
Screen
(filename=None)[source]¶ Bases:
wpg.optical_elements.Empty
class: Implements the Screen optical element
Constructor for the Screen class.
Parameters: filename (str) – Name of file to store wavefront data. Raises: IOError – File exists.
-
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.
Parameters: - _mirSub – SRWLOptMir (or derived) type object defining substrate of the grating
- _m – output (diffraction) order
- _grDen – groove density [lines/mm] (coefficient a0 in the polynomial groove density: a0 + a1*y + a2*y^2 + a3*y^3 + a4*y^4)
- _grDen1 – groove density polynomial coefficient a1 [lines/mm^2]
- _grDen2 – groove density polynomial coefficient a2 [lines/mm^3]
- _grDen3 – groove density polynomial coefficient a3 [lines/mm^4]
- _grDen4 – groove density polynomial coefficient a4 [lines/mm^5]
- _grAng – angle between the grove direction and the saggital direction of the substrate [rad] (by default, groves are made along saggital direction (_grAng=0))
Returns: SRWLOptG: VLS grating propagator,
struct SRWLOptG
-
wpg.optical_elements.
WF_dist
(nx, ny, Dx, Dy)[source]¶ Create a ‘phase screen’ propagator for wavefront distortions: A wrapper to SRWL struct SRWLOptT
Parameters: - nx – number of points in horizontal direction
- ny – number of points in vertical direction
- Dx – size in m
- Dy – size in
-
class
wpg.optical_elements.
WPGOpticalElement
[source]¶ Bases:
object
Base class for optical elements.
-
wpg.optical_elements.
calculateOPD
(wf_dist, mdatafile, ncol, delim, Orient, theta, scale=1.0, length=1.0, xscale=1.0, x0=0.0, bPlot=False)[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: - xscale – scaling factor for the mirror profile x-axis (for taking an arbitrary scaled axis, i.e. im mm)
- length – mirror length, m, default value 1 m
Returns: filled
struct SRWLOptT
-
wpg.optical_elements.
create_CRL
(directory, voids_params, _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]¶ This function build CLR or load it from file if it was created beforehand. Out/input filename builded as sequence of function parameters.
Adiitinal parameters (*args) passed to srwlib.srwl_opt_setup_CRL function
Parameters: - directory – output directory to save file.
- voids_params – void params to build CRL and construct unique file name
- _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: SRWL CRL object
-
wpg.optical_elements.
create_CRL_from_file
(directory, file_name, _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]¶ This function build CLR or load it from file. Out/input filename builded as sequence of function parameters. Adiitinal parameters (*args) passed to srwlib.srwl_opt_setup_CRL function
Parameters: - directory – output directory
- fiel_name – CRL file name
- _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: SRWL CRL object
-
wpg.optical_elements.
mkdir_p
(path)[source]¶ Create directory with subfolders (like Linux mkdir -p)
Parameters: path – Path to be created
-
wpg.optical_elements.
Drift
¶
-
wpg.optical_elements.
Lens
¶