pysrw.lib.srwlib

pysrw.lib.srwlib#

Functions

srwl_opt_setup_CRL(_foc_plane, _delta, ...)

Setup Transmission type Optical Element which simulates Compound Refractive Lens (CRL) :param _foc_plane: plane of focusing: 1- horizontal, 2- vertical, 3- both :param _delta: refractive index decrement (can be one number of array vs photon energy) :param _atten_len: attenuation length [m] (can be one number of array vs photon energy) :param _shape: 1- parabolic, 2- circular (spherical) :param _apert_h: horizontal aperture size [m] :param _apert_v: vertical aperture size [m] :param _r_min: radius (on tip of parabola for parabolic shape) [m] :param _n: number of lenses (/"holes") :param _wall_thick: min.

srwl_opt_setup_Hartmann_sensor(_delta, ...)

Setup Transmission type Optical Element which simulates a mask array for at-wavelength metrology.

srwl_opt_setup_Hartmann_sensor_dev(_per_x, ...)

Setup Transmission type Optical Element which simulates a Harmann sensor, i.e. mask array/matrix for at-wavelength metrology.

srwl_opt_setup_bumps(_ampl, _sx, _sy, _n, ...)

Setup Transmission type Optical Element which simulates a set of Gaussian-shape "Bumps" randomly placed in transverse plane :param _ampl: amplitude of bumps [m] or list of min.

srwl_opt_setup_cyl_fiber(_foc_plane, ...)

Setup Transmission type Optical Element which simulates Cylindrical Fiber :param _foc_plane: plane of focusing: 1- horizontal (i.e. fiber is parallel to vertical axis), 2- vertical (i.e. fiber is parallel to horizontal axis) :param _delta_ext: refractive index decrement of external layer :param _delta_core: refractive index decrement of core :param _atten_len_ext: attenuation length [m] of external layer :param _atten_len_core: attenuation length [m] of core :param _diam_ext: diameter [m] of external layer :param _diam_core: diameter [m] of core :param _xc: horizontal coordinate of center [m] :param _yc: vertical coordinate of center [m] :return: transmission (SRWLOptT) type optical element which simulates Cylindrical Fiber.

srwl_opt_setup_gen_transm(_func_path, ...[, ...])

Setup Transmission type Optical Element similar to the one simulating CRL, but with arbitrary optical path in material over hor.

srwl_opt_setup_mask(_delta, _atten_len, ...)

Setup Transmission type Optical Element which simulates a mask array for at-wavelength metrology.

srwl_opt_setup_saw_tooth_lens(_delta, ...[, ...])

Setup Transmission type Optical Element which simulates trapethoidal shape etched mask (requested by K.

srwl_opt_setup_surf_height_1d(...[, _ang_r, ...])

Setup Transmission type optical element with 1D (mirror or grating) surface Heght Profile data :param _height_prof_data: two- or one-column table containing, in case of two columns: longitudinal position in [m] (1st column) and the Height Profile in [m] (2nd column) data; in case of one column, it contains the Height Profile data :param _dim: orientation of the reflection (deflection) plane; can be 'x' or 'y' :param _ang: grazing angle (between input optical axis and mirror/grating plane) :param _ang_r: reflection angle (between output optical axis and mirror/grating plane) :param _amp_coef: height profile "amplification coefficient" :param _ar_arg_long: optional array of longitudinal position (along mirror/grating) in [m]; if _ar_arg_long is not None, any longitudinal position contained in _height_prof_data is ignored :param _nx: optional number of points in horizontal dimension of the output transmission optical element :param _ny: optional number of points in vertical dimension of the output transmission optical element :param _size_x: optional horizontal transverse size of the output transmission optical element (if <=0: _height_prof_data, _dim, _ar_arg_long, _ar_arg_tr data is used) :param _size_y: optional vertical transverse size of the output transmission optical element (if <=0: _height_prof_data, _dim, _ar_arg_long, _ar_arg_tr data is used) :param _xc: optional horizontal center position of the output transmission optical element :param _yc: optional vertical center position of the output transmission optical element :return: transmission (SRWLOptT) type optical element which simulates the effect of surface height error

srwl_opt_setup_surf_height_1d_old(...[, ...])

Setup Transmission type optical element with 1D (mirror or grating) surface Heght Profile data :param _height_prof_data: two- or one-column table containing, in case of two columns: longitudinal position in [m] (1st column) and the Height Profile in [m] (2nd column) data; in case of one column, it contains the Height Profile data :param _dim: orientation of the reflection (deflection) plane; can be 'x' or 'y' :param _ang: grazing angle (between input optical axis and mirror/grating plane) :param _ang_r: reflection angle (between output optical axis and mirror/grating plane) :param _amp_coef: height profile "amplification coefficient" :param _ar_arg_long: optional array of longitudinal position (along mirror/grating) in [m]; if _ar_arg_long is not None, any longitudinal position contained in _height_prof_data is ignored :param _nx: optional number of points in horizontal dimension of the output transmission optical element :param _ny: optional number of points in vertical dimension of the output transmission optical element :param _size_x: optional horizontal transverse size of the output transmission optical element (if <=0: _height_prof_data, _dim, _ar_arg_long, _ar_arg_tr data is used) :param _size_y: optional vertical transverse size of the output transmission optical element (if <=0: _height_prof_data, _dim, _ar_arg_long, _ar_arg_tr data is used) :param _xc: optional horizontal center position of the output transmission optical element :param _yc: optional vertical center position of the output transmission optical element :return: transmission (SRWLOptT) type optical element which simulates the effect of surface height error

srwl_opt_setup_surf_height_2d(...[, _ang_r, ...])

Setup Transmission type optical element with 2D (mirror or grating) surface Heght Profile data :param _height_prof_data: a matrix (2D array) containing the Height Profile data in [m]; if _ar_height_prof_x is None and _ar_height_prof_y is None: the first column in _height_prof_data is assumed to be the "longitudinal" position [m] and first row the "transverse" position [m], and _height_prof_data[0][0] is not used; otherwise the "longitudinal" and "transverse" positions on the surface are assumed to be given by _ar_height_prof_x, _ar_height_prof_y :param _dim: orientation of the reflection (deflection) plane; can be 'x' or 'y' :param _ang: grazing angle (between input optical axis and mirror/grating plane) :param _ang_r: reflection angle (between output optical axis and mirror/grating plane) :param _amp_coef: height profile "amplification coefficient" :param _ar_arg_long: optional array of longitudinal position (along mirror/grating) in [m] :param _ar_arg_tr: optional array of transverse position on mirror/grating surface in [m] :param _nx: optional number of points in horizontal dimension of the output transmission optical element :param _ny: optional number of points in vertical dimension of the output transmission optical element :param _size_x: optional horizontal transverse size of the output transmission optical element (if <=0: _height_prof_data, _dim, _ar_arg_long, _ar_arg_tr data is used) :param _size_y: optional vertical transverse size of the output transmission optical element (if <=0: _height_prof_data, _dim, _ar_arg_long, _ar_arg_tr data is used) :return: transmission (SRWLOptT) type optical element which simulates the effect of surface height error

srwl_opt_setup_transit_reg(_delta1, ...[, ...])

Setup Transmission type Optical Element simulating transition region cutting transverse plane into two half-planes with constant refraction / absorption properties :param _delta1: refractive index decrement of one part of the area :param _atten_len1: attenuation length of one part of the area :param _delta2: refractive index decrement of the other part of the area :param _atten_len2: attenuation length of the other part of the area :param _thick: thickness of the transmission element [m] :param _rx: horizontal coordiate range of the transmission element [m] :param _ry: vertical coordiate range of the transmission element [m] :param _w: width of transition region between two areas [m] :param _tr_typ: type of the transition: 1- linear, 2- .

srwl_opt_setup_zp_tilt(_zp, _ang_tilt[, ...])

Under Development!!! Setup Contained of Transmission type Optical Elements and Drift Spaces simulating tilted thick Zone Plate :param _zp: Zone Plate object (of type SRWLOptZP) :param _ang_tilt: tilt angle of the ZP [rad] :param _ang_ax: angle [rad] from horizontal axis defining orientation of ZP rotation / tilt axis (i.e. if it is equal to pi/2 zp is assumed to be rotated about vertical axis in the horizontal plane) :param _n_slices: number of "slices" in longitudinal direction to be used to represent the tilted "thick" Zone Plate :param _e_start: initial photon energy [eV] :param _e_fin: final photon energy [eV] :param _nx: number of points vs horizontal position to represent the transmission element :param _ny: number of points vs vertical position to represent the transmission element :return: optical element container (of type SRWLOptC) with Transmission optical elements (of type SRWLOptT) separated by drift spaces (of type SRWLOptD).

srwl_uti_array_alloc(_type, _n[, _list_base])

srwl_uti_math_seq_halton(i[, base])

srwl_uti_num_round(_x[, _ndig])

srwl_uti_ph_en_conv(_x[, _in_u, _out_u])

Photon Energy <-> Wavelength conversion :param _x: value to be converted :param _in_u: input unit :param _out_u: output unit :return: value in the output units

srwl_uti_proc_is_master()

Check if process is Master (in parallel processing sense)

srwl_uti_rand_fill_vol(_np, _x_min, _x_max, ...)

Generate coordinates of ponts randomly filling 3D volume limited by two arbitrary curves (defining base) and two surfaces :param _np: number of random points in rectangular parallelepiped to try :param _x_min: min.

srwl_uti_read_data_cols(_file_path, _str_sep)

Auxiliary function to read-in data comumns from ASCII file (2D table) :param _file_path: full path (including file name) to the file :param _str_sep: column separation symbol(s) (string) :param _i_col_start: initial data column to read :param _i_col_end: final data column to read :param _n_line_skip: number of lines to skip in the beginning of the file :return: 2D list containing data columns read

srwl_uti_read_intens(_file_path[, ...])

srwl_uti_read_intens_ascii(_file_path[, ...])

srwl_uti_read_intens_hdf5(_file_path[, ...])

srwl_uti_read_mag_fld_3d(_fpath[, _scom])

srwl_uti_read_wfr_cm_hdf5(_file_path[, _gen0s])

Reads-in Wavefront data file (with a number of wavefronts, calculated in the same mesh vs x nad y) :param _file_path: string specifying path do data file to be loaded :param _gen0s: switch defining whether zero-electric field array(s) need to be created if some polarization component(s) are missing in the file :return: list of wavefronts (objects of SRWLWfr type)

srwl_uti_save_intens(_ar_intens, _mesh, ...)

srwl_uti_save_intens_ascii(_ar_intens, ...)

srwl_uti_save_intens_hdf5(_ar_intens, _mesh, ...)

srwl_uti_save_intens_hdf5_exp(_ar_intens, ...)

srwl_uti_save_stat_wfr_emit_prop_multi_e([...])

The function to save .log and .json status files to monitor parallel MPI jobs progress.

srwl_uti_save_stat_wfr_emit_prop_multi_e_init(...)

Initialize parameters for the SRW status files and generate the files.

srwl_uti_save_text(_text, _file_path[, ...])

srwl_uti_save_wfr_cm_hdf5(_arEx, _arEy, ...)

Save CMD data (with a number of fully-coherent wavefronts, calculated in the same mesh vs x nad y) to a file :param _arE: 2D array of complex electric field data of the coherent modes :param _awfr: wavefront () of mesh :param _file_path: string specifying path do data file to be loaded

srwl_uti_write_data_cols(_file_path, _cols, ...)

Auxiliary function to write tabulated data (columns, i.e 2D table) to ASCII file :param _file_path: full path (including file name) to the file to be (over-)written :param _cols: array of data columns to be saves to file :param _str_sep: column separation symbol(s) (string) :param _str_head: header (string) to write before data columns :param _i_col_start: initial data column to write :param _i_col_end: final data column to write

srwl_wfr_cmd(_csd, _n_modes[, _awfr, _alg])

Perform Coherent Mode Decomposition (CMD) of (4D) Cross-Spectral Density / Mutual Intensity data.

srwl_wfr_csd_avg(_fp_core, _fp_ext, _fi_st, ...)

srwl_wfr_emit_prop_multi_e(_e_beam, _mag, ...)

Calculate Stokes Parameters of Emitted (and Propagated, if beamline is defined) Partially-Coherent SR. :param _e_beam: Finite-Emittance e-beam (SRWLPartBeam type) :param _mag: Magnetic Field container (magFldCnt type) or Coherent Gaussian beam (SRWLGsnBm type) or Point Source (SRWLPtSrc type) or list of Coherent Modes (of SRWLWfr type each) :param _mesh: mesh vs photon energy, horizontal and vertical positions (SRWLRadMesh type) on which initial SR should be calculated :param _sr_meth: SR Electric Field calculation method to be used: 0- "manual", 1- "auto-undulator", 2- "auto-wiggler" :param _sr_rel_prec: relative precision for SR Electric Field calculation (usually 0.01 is OK, the smaller the more accurate) :param _n_part_tot: total number of "macro-electrons" to be used in the calculation :param _n_part_avg_proc: number of "macro-electrons" to be used in calculation at each "slave" before sending Stokes data to "master" (effective if the calculation is run via MPI) :param _n_save_per: periodicity of saving intermediate average Stokes data to file by master process :param _file_path: path to file for saving intermediate average Stokes data by master process :param _sr_samp_fact: oversampling factor for calculating of initial wavefront for subsequent propagation (effective if >0) :param _opt_bl: optical beamline (container) to propagate the radiation through (SRWLOptC type) :param _pres_ang: switch specifying presentation of the resulting Stokes parameters: coordinate (0) or angular (1) or both (2, to implement !!!) :param _char: radiation characteristic to calculate: 0- Total Intensity, i.e. Flux per Unit Surface Area (s0); 1- Four Stokes components of Flux per Unit Surface Area; 2- Mutual Intensity Cut (2D) vs X; 3- Mutual Intensity Cut (2D) vs Y; 4- Mutual Intensity and Degree of Coherence Cuts (2D) vs X & Y; 5- Degree of Coherence Cuts (2D) vs X & Y; 6- Mutual Intensity / Cross-Spectral Density (4D) vs X & Y; 61- Coherent Modes (array of 2D distributions of Electric Field vs X & Y) and Mutual Intensity / Cross-Spectral Density (4D) vs X & Y it is based on; 7- Coherent Modes (array of 2D distributions of Electric Field vs X & Y); 10- Flux 11- Four Stokes components of Flux (?) 20- Electric Field (sum of fields from all macro-electrons, assuming CSR) 40- Total Intensity, i.e. Flux per Unit Surface Area (s0), Mutual Intensity and Degree of Coherence Cuts vs X & Y; 41- Total Intensity, i.e. Flux per Unit Surface Area (s0) and Degree of Coherence Cuts vs X & Y; :param _x0: horizontal center position for mutual intensity calculation :param _y0: vertical center position for mutual intensity calculation :param _e_ph_integ: integration over photon energy is required (1) or not (0); if the integration is required, the limits are taken from _mesh :param _rand_meth: method for generation of pseudo-random numbers for e-beam phase-space integration: 1- standard pseudo-random number generator 2- Halton sequences 3- LPtau sequences (to be implemented) :param _tryToUseMPI: switch specifying whether MPI should be attempted to be used :param _wr: initial wavefront radius [m] to assume at wavefront propagation (is taken into account if != 0) :param _wre: initial wavefront radius error [m] to assume at wavefront propagation (is taken into account if != 0) :param _det: detector object for post-processing of final intensity (instance of SRWLDet) :param _me_approx: approximation to be used at multi-electron integration: 0- none (i.e. do standard M-C integration over 5D phase space volume of e-beam), 1- integrate numerically only over e-beam energy spread and use convolution to treat transverse emittance :param _file_bkp: create or not backup files with resulting multi-electron radiation characteristics :param _rand_opt: randomize parameters of optical elements at each fully-coherent wavefront propagation (e.g. to simulate impact of vibrations) or not :param _file_form: format of output files ('ascii' / 'asc' and 'hdf5' supported) :param _n_mpi: number of independent "groups" of MPI processes (for 4D CSD calculation) :param _n_cm: number of coherent modes to calculate (is taken into account if _char==61 or _char==7) :param _ms: index of the first wavefront / coherent mode to start computation :param _del_aux_files: delete (or not) auxiliary files (applies to different types of calculations).

srwl_wfr_fn(_fn_core, _type[, _form])

Generate standard filenames for radiation characteristics from a given core name :param _fn_core: core filename :param _type: type of radiation characteristic: 0- Electric Field 1- Spectral Intensity, i.e. Spectral Flux per Unit Surface Area 2- Spectral Angular Intensity, i.e. Spectral Flux per Unit Solid Angle 3- Mutual Intensity (in real space, i.e. dependent on coordinates) 31- Mutual Intensity Cut vs X 32- Mutual Intensity Cut vs Y 4- Degree of Coherence 41- Degree of Coherence Cut vs X 42- Degree of Coherence Cut vs Y 5- Wigner Distribution / Brightness 51- Wigner Distribution / Brightness Cut vs X 52- Wigner Distribution / Brightness Cut vs Y 7- Coherent Modes :param _form: format of data file ('ascii' and 'hdf5' or 'h5' are supported).

srwl_wfr_fn_ext(_fp, _form[, _char])

Check / change file extension, depending on requested file format and type of calculation :param _fp: filename (/path) :param _form: required file format, can be: 'ascii' or 'ASCII' or 'asc' or 'ASC' for ASCII format 'hdf5' or 'HDF5' or 'h5' or 'H5' for HDF5 format :param _char: radiation characteristic to be calculated (one of values supported by the srwl_wfr_emit_prop_multi_e function) :return: updated / checked filename

srwl_wfr_from_intens(_ar_int, _mesh, ...[, ...])

Setup Coherent Wavefront from Intensity (assuming spherical or asigmatic wave): note this is an error-prone procedure :param _ar_int: input intensity array :param _mesh: mesh vs photon energy, horizontal and vertical positions (SRWLRadMesh type) on which initial SR should be calculated :param _part_beam: Finite-Emittance beam (SRWLPartBeam type) :param _Rx: horizontal wavefront radius [m] :param _Ry: vertical wavefront radius [m] :param _xc: horizontal wavefront center position [m] :param _yc: vertical wavefront center position [m]

srwl_wfr_prop_drifts(_wfr, _dz, _nz, _pp[, ...])

Propagates wavefront over free space in a number of steps and generates intensity distributions vs (z,x) and (z,y) and possibly (z,x,y) :param _wfr: input/output wavefront :param _dz: longitudinal step size for the drifts :param _nz: number of drift steps to be made :param _pp: list of propagation parameters to be used for each drift step :param _do3d: generate intensity vs (z,x,y) in addition to the cuts (z,x) and (z,y) :param _nx: number of points vs horizontal position (is taken into account if >0) :param _ny: number of points vs vertical position (is taken into account if >0) :param _rx: number of points vs horizontal position (is taken into account if >0) :param _ry: number of points vs vertical position(is taken into account if >0) :param _xc: horizontal position for vertical cut of intensity :param _yc: vertical position for horizontal cut of intensity :param _pol: switch specifying polarization component to be extracted: =0 -Linear Horizontal; =1 -Linear Vertical; =2 -Linear 45 degrees; =3 -Linear 135 degrees; =4 -Circular Right; =5 -Circular Left; =6 -Total :param _type: switch specifying "type" of a characteristic to be extracted: =0 -"Single-Electron" Intensity; =1 -"Multi-Electron" Intensity; =2 -"Single-Electron" Flux; =3 -"Multi-Electron" Flux; =4 -"Single-Electron" Radiation Phase; =5 -Re(E): Real part of Single-Electron Electric Field; =6 -Im(E): Imaginary part of Single-Electron Electric Field; =7 -"Single-Electron" Intensity, integrated over Time or Photon Energy (i.e. Fluence) :param _ord_interp: interpolation order for final intensity calc. :return resulting intensity distributions.

Classes

SRWLDet([_xStart, _xFin, _nx, _yStart, ...])

Detector of Radiation

SRWLGsnBm([_x, _y, _z, _xp, _yp, ...])

(Coherent) Gaussian (Radiation) Beam

SRWLKickM([_arKickMx, _arKickMy, _order, ...])

Kick Matrix (for fast trajectory calculation)

SRWLMagFld()

Magnetic Field (base class)

SRWLMagFld3D([_arBx, _arBy, _arBz, _nx, ...])

Magnetic Field: Arbitrary 3D

SRWLMagFldC([_arMagFld, _arXc, _arYc, ...])

Magnetic Field: Container

SRWLMagFldH([_n, _h_or_v, _B, _ph, _s, _a])

Magnetic Field: Undulator Harmonic

SRWLMagFldM([_G, _m, _n_or_s, _Leff, _Ledge, _R])

Magnetic Field: Multipole Magnet

SRWLMagFldS([_B, _Leff])

Magnetic Field: Solenoid

SRWLMagFldU([_arHarm, _per, _nPer])

Magnetic Field: Undulator

SRWLOpt()

Optical Element (base class)

SRWLOptA([_shape, _ap_or_ob, _Dx, _Dy, _x, _y])

Optical Element: Aperture / Obstacle

SRWLOptAng([_ang_x, _ang_y])

Optical Element: Angle

SRWLOptC([_arOpt, _arProp])

Optical Element: Container

SRWLOptCryst(_d_sp, _psi0r, _psi0i, _psi_hr, ...)

Optical Element: Ideal Crystal

SRWLOptD([_L, _treat])

Optical Element: Drift Space

SRWLOptG(_mirSub[, _m, _grDen, _grDen1, ...])

Optical Element: Grating

SRWLOptL([_Fx, _Fy, _x, _y])

Optical Element: Thin Lens

SRWLOptMir()

Optical Element: Mirror (focusing)

SRWLOptMirEl([_p, _q, _ang_graz, _r_sag, ...])

Optical Element: Mirror: Elliptical NOTE: in the Local frame of the Mirror tangential direction is X, saggital Y, mirror normal is along Z

SRWLOptMirPar([_f, _uc, _ang_graz, _r_sag, ...])

Optical Element: Mirror: Paraboloid NOTE: in the Local frame of the Mirror tangential direction is X, saggital Y, mirror normal is along Z

SRWLOptMirPl([_size_tang, _size_sag, ...])

Optical Element: Mirror: Plane

SRWLOptMirSph([_r, _size_tang, _size_sag, ...])

Optical Element: Mirror: Spherical

SRWLOptMirTor([_rt, _rs, _size_tang, ...])

Optical Element: Mirror: Toroid NOTE: in the Local frame of the Mirror tangential direction is X, saggital Y, mirror normal is along Z

SRWLOptShift([_shift_x, _shift_y])

Optical Element: Shirt

SRWLOptT([_nx, _ny, _rx, _ry, _arTr, ...])

Optical Element: Transmission (generic)

SRWLOptWG([_L, _Dx, _Dy, _x, _y])

Optical Element: Waveguide

SRWLOptZP([_nZones, _rn, _thick, _delta1, ...])

Optical Element: Thin Lens

SRWLPartBeam([_Iavg, _nPart, _partStatMom1, ...])

Particle Beam

SRWLParticle([_x, _y, _z, _xp, _yp, _gamma, ...])

Charged Particle

SRWLPrtTrj([_arX, _arXp, _arY, _arYp, _arZ, ...])

Charged Particle Trajectory

SRWLPtSrc([_x, _y, _z, _flux, _unitFlux, _polar])

Point Source (emitting coherent spherical wave)

SRWLRadMesh([_eStart, _eFin, _ne, _xStart, ...])

Radiation Mesh (Sampling)

SRWLStokes([_arS, _typeStokes, _eStart, ...])

Radiation Stokes Parameters

SRWLWfr([_arEx, _arEy, _typeE, _eStart, ...])

Radiation Wavefront (Electric Field)