srxraylib.sources package
Submodules
srxraylib.sources.srfunc module
srfunc: calculates synchrotron radiation emission (radiation and angle distributions).
functions:
basic:
fintk53: integral of the Bessel function K5/3(x).
sync_g1: energy spectrum integrated over the full vertical angle.
sync_f: angular dependence of synchrotron radiation.
sync_hi: function Hi(x) = x^i * BeselK(x/2,2/3).
bending magnet radiation:
sync_ang: angular distributions.
sync_ene: energy distributions.
wiggler radiation:
wiggler_trajectory: computes the electron trajectroy in a magnetic field (sinusoidal or from a file with B[T] or its harmonic decomposition).
wiggler_spectrum: computes the wiggler spectrum (full emission) given the trajectory.
wiggler_nphoton: computes the number of photons emtted versus bending radius per (1mA 1mrad (horizontal) 0.1% bandwidth).
wiggler_harmonics: computes the harmonic decomposition of the magnetic field B(s).
wiggler_cdf: computes the cumulative distribution function from radiation.
- srxraylib.sources.srfunc.fintk53(xd)[source]
Calculates the integral from x to infinity of the Bessel function K5/3(x).
Calculates the function consisting of the integral, from x to infinity,of the Bessel function K5/3(x). g_one=fintk53*x is the universal curve from which the energy spectrum of the synchrotron bending magnet is calculated.
- Parameters:
xd (float or numpy array) – the argument of the function.
- Returns:
returns the value of the fintk53 function.
- Return type:
float or numpy array
Notes
Translated from a Fortran program, original from Umstatter.
C C C Routines taken from C C http://www.slac.stanford.edu/grp/arb/tn/arbvol2/ARDB162.pdf C The reference 1981 CERN/PS/SM/81-13 is cited in C 'Synchrotron Radiation Spectra' by G.Brown and W. C Lavender pp.37-61 Handbook on Synchrotron Radiation, C vol. 3 edited by G.S. Brown and D.E. Moncton (Elsevier C Science Publishers B.V. 1991 North-Holland, Amsterdam) C
I have performed a comparison of the result with Mathematica with very good agreement (note that Mathematica values diverge for x> 20. I do not know why): (Mathematica evaluation N[g_one[0.001],20]) (x = 5.0 & print,fintk53(x),x*fintk53(x),format=’(2G32.18)’).
x mathematica idl (x*fintk53(x)) python x*fintk3(x) 0.001 0.2131390650914501 0.213139096577768417 2.13139066e-01 0.01 0.4449725041142102 0.444972550630643671 4.44972505e-01 0.1 0.818185534872854 0.818185588215680770 8.18185536e-01 1.0 0.6514228153553639697 0.651422821506926542 6.51422815e-01 5.0 0.021248129774982 0.0212481300729910755 2.12481298e-02 10.0 0.00019223826428 0.000192238266987909711 1.92238264e-04 20.0 5.960464477539063E-7 1.19686346217633044E-08 1.19686345e-08 50.0 6.881280000000002E7 1.73478522828932108E-21 1.73478520e-21 100.0 4.642275147320176E29 4.69759373162073832E-43 4.69759367e-43 1000.0 -1.7E424 Floating underflow (<620 OK) 0.00000000e+00
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-04-22
20120208 srio@esrf.eu: python version
- srxraylib.sources.srfunc.resample_array(array, new_size, method='linear')[source]
Resample a 1D array to a new size using the specified interpolation method.
Parameters: array (numpy.ndarray): The input array to resample. new_size (int): The desired size of the resampled array. method (str): The interpolation method to use. Options are ‘linear’, ‘nearest’, ‘cubic’.
Returns: numpy.ndarray: The resampled array.
- srxraylib.sources.srfunc.sync_ang(flag, angle_mrad, polarization=0, e_gev=1.0, i_a=0.001, hdiv_mrad=1.0, r_m=1.0, energy=1.0, ec_ev=1.0)[source]
Calculates the synchrotron radiation angular distribution.
- Parameters:
flag (int) – 0: Flux fully integrated in photon energy, 1: Flux at a given photon energy.
angle_mrad (float or numpy array) – the angle array [in mrad].
polarization (int, optional) – 0: Total, 1: Parallel (l2=1, l3=0, in Sokolov&Ternov notation), 2: Perpendicular (l2=0, l3=1). IF flag=0 THE FOLLOWING KEYWORDS MUST BE ENTERED : e_geV, i_a, hdiv_mrad, r_m. IF flag=1 THE FOLLOWING KEYWORDS MUST BE ENTERED : e_geV, i_a, hdiv_mrad, r_m, energy, ec_ev.
e_gev (float, optional) – The electron energy [in GeV] (default=1.0).
i_a (float, optional) – the electron beam intensity [in A] (default=1.0e-3).
hdiv_mrad (float, optional) – the horizontal divergence [in mrad] (default=1).
r_m (float or numpy array, optional) – the bending magnet radius [in m] (default=1.0).
energy (float or numpy array, optional) – the energy value [in eV] (default=1).
ec_ev (float or numpy array, optional) – The critical energy [eV] (default=1).
- Returns:
returns the array with the angular distribution. If flag is 1 returns power density [Watts/mrad(Psi)]
- Return type:
float or tuple
Notes
References
G K Green, “Spectra and optics of synchrotron radiation”, BNL 50522 report (1976)
A A Sokolov and I M Ternov, Synchrotron Radiation, Akademik-Verlag, Berlin, 1968
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-06-03
20120208 srio@esrf.eu: python version
- srxraylib.sources.srfunc.sync_ene(f_psi, energy_ev, ec_ev=1.0, polarization=0, e_gev=1.0, i_a=0.001, hdiv_mrad=1.0, psi_min=0.0, psi_max=0.0, psi_npoints=1)[source]
Calculates the synchrotron radiation energy spectrum.
- Parameters:
f_psi (int) – flag with the type of calculation: * 0: Flux fully integrated in angle (Psi), * 1: Flux at Psi=0, * 2: Flux integrated in the angular interval [Psi_Min,Psi_Max], * 3: Flux at Psi=Psi_Min, * 4: Flux versus angle in [Psi_Min,Psi_Max] and energy.
energy_ev (float or numpy array) – the energy array [in eV].
polarization (int, optional) – 0: Total, 1: Parallel (l2=1, l3=0, in Sokolov&Ternov notation), 2: Perpendicular (l2=0, l3=1).
ec_ev (float, optional) – The critical energy [eV] (for f_psi=0 or f_psi=1).
e_gev (float, optional) – The electron energy [in GeV] (for f_psi=0 or f_psi=1).
i_a (float, optional) – the electron beam intensity [in A] (for f_psi=0 or f_psi=1).
hdiv_mrad (float, optional) – the horizontal divergence [in mrad] (for f_psi=0 or f_psi=1).
psi_min (float, optional) – Psi_Min the minimum integration angle [in mrad] for f_psi=2 or the integration angle for f_psi=3.
psi_max (float, optional) – Psi_Max the maximum integration angle [in mrad] (for f_psi=2).
psi_npoints (float, optional) – the number of points in psi for integration (for f_psi=2).
- Returns:
returns the array with the flux [photons/sec/0.1%bw] for f_psi=0,2 and the flux [photons/sec/0.1%bw/mrad] for f_psi=1,3,4.
- Return type:
numpy array
Notes
References
G K Green, “Spectra and optics of synchrotron radiation”, BNL 50522 report (1976).
A A Sokolov and I M Ternov, Synchrotron Radiation, Akademik-Verlag, Berlin, 1968.
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-06-03
2007-05-14 srio@esrf.fr debug with FLAG=2. The bandwith in angle depends on the number of points. Now it is 1mrad. Bug reported by flori@n-nolz.de Added default values.
2007-12-13 srio@esrf.eu fixes bug reported by Gernot.Buth@iss.fzk.de concerning the normalization of the angular integral.
20120208 srio@esrf.eu: python version
Example
This is an example code:
#create 10-points energy array in [20,30] keV e=numpy.linspace(20000.0,30000.0,10) # # test of spectra at Psi=0 # # at psi=0 (i.e., flag=1) In [274]: srfunc.sync_ene(1,e,ec_ev=19166.0,e_gev=6,i_a=0.1,hdiv_mrad=1) Out[274]: array([[ 6.89307648e+13, 6.81126315e+13, 6.71581119e+13, 6.60866137e+13, 6.49155481e+13, 6.36605395e+13, 6.23356084e+13, 6.09533305e+13, 5.95249788e+13, 5.80606485e+13]]) # at psi_min (FLAG=3) In [279]: srfunc.sync_ene(3,e,ec_ev=19166.0,e_gev=6,i_a=0.1, hdiv_mrad=1,psi_min=0.0) Out[279]: array([[ 6.89307648e+13, 6.81126315e+13, 6.71581119e+13, 6.60866137e+13, 6.49155481e+13, 6.36605395e+13, 6.23356084e+13, 6.09533305e+13, 5.95249788e+13, 5.80606485e+13]]) # # test of integrated spectra # # Integrating (by hand) using flag=3 # a is large enough to cover the full radiation fan a = numpy.linspace(-0.2,0.2,50) # create 10-points energy array in [20,30] keV e=numpy.linspace(20000.0,30000.0,10) y3=e*0.0 for i in range(a.size): y2=srfunc.sync_ene(3,e,ec_ev=19166.0,e_gev=6,i_a=0.1,hdiv_mrad=1,psi_min=a[i]) y3[i] = y3[i] + y2 y3=y3*(a[1]-a[0]) # Integrating (automatically) using FLAG=2 y4 = srfunc.sync_ene(2,e,ec_ev=19166.0,e_gev=6,i_a=0.1,hdiv_mrad=1,psi_min=-0.2,psi_max=0.2,psi_npoints=50) # Integrated (over all angles) using FLAG=0 y5 = srfunc.sync_ene(0,e,ec_ev=19166.0,e_gev=6,i_a=0.1,hdiv_mrad=1) In [475]: for i in range(y3.size): print e[i],y3[i],y4[i],y5[i] .....: .....: # The results obtained are: # energy int_by_hand int_num int # 20000.0 9.32554203564e+12 9.32554203564e+12 9.33199803948e+12 # 21111.1111111 8.95286605221e+12 8.95286605221e+12 8.9590640148e+12 # 22222.2222222 8.58856640727e+12 8.58856640727e+12 8.59451215453e+12 # 23333.3333333 8.2334342483e+12 8.2334342483e+12 8.2391341364e+12 # 24444.4444444 7.88805461639e+12 7.88805461639e+12 7.89351540031e+12 # 25555.5555556 7.55284456882e+12 7.55284456882e+12 7.55807329003e+12 # 26666.6666667 7.22808379127e+12 7.22808379127e+12 7.23308768405e+12 # 27777.7777778 6.91393939677e+12 6.91393939677e+12 6.91872581084e+12 # 28888.8888889 6.61048616971e+12 6.61048616971e+12 6.61506250643e+12 # 30000.0 6.31772320182e+12 6.31772320182e+12 6.32209686189e+12
- srxraylib.sources.srfunc.sync_f(rAngle, rEnergy=None, polarization=0, gauss=0, l2=1, l3=0)[source]
Angular dependency of synchrotron radiation emission.
Calculates the function used for calculating the angular dependence of synchrotron radiation.
- Parameters:
rAngle (float or numpy array) – the reduced angle in rad, i.e., angle[rads]*Gamma.
rEnergy (float or numpy array, optional) – a value for the reduced photon energy, i.e., energy/critical_energy. If this input is present, the calculation is done for this energy. Otherwise, the calculation results is the integration over all photon energies.
polarization (int, optional) – 0 Total, 1 Parallel (l2=1, l3=0, in Sokolov&Ternov notation), 2 Perpendicular (l2=0, l3=1), 3 Any (define l2 and l3).
gauss (int, optional) – When this keyword is set, the “Gaussian” approximaxion instead of the full calculation is used. Only valid for integrated flux aver all photon energies.
l2 (int, optional) – The polarization value of L2.
l3 (int, optional) – The polarization value of L3, If using L2 and L3, both L2 and L3 must be defined. In this case, the polarization keyword is ignored.
- Returns:
returns the value of the sync_f function. It is a scalar if both inputs are scalar. If one input is an array, the result is an array of the same dimension. If both inputs are arrays, the resulting array has dimension NxM, N=Dim(rAngle) and M=Dim(rEnergy)
- Return type:
float or numpy array
Notes
The number of emitted photons versus vertical angle Psi is proportional to sync_f, which value is given by the formulas in the references.
For angular distribution integrated over full photon energies (rEnergy optional input not present) we use the Formula 9, pag 4 in Green. For its gaussian approximation (in this case the polarization keyword has no effect) we use for 87 in pag 32 in Green. For angular distribution at a given photon energy (rEnergy optional input not present) we use the Formula 11, pag 6 in Green.
References
G K Green, “Spectra and optics of synchrotron radiation” BNL 50522 report (1976).
A A Sokolov and I M Ternov, Synchrotron Radiation, Akademik-Verlag, Berlin, 1968.
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-05-23
2002-07-12 srio@esrf.fr adds circular polarization term for wavelength integrated spectrum (S&T formula 5.25)
2012-02-08 srio@esrf.eu: python version
- srxraylib.sources.srfunc.sync_f_sigma_and_pi(rAngle, rEnergy)[source]
angular dependency of synchrotron radiation emission
- NAME:
sync_f_sigma_and_pi
- PURPOSE:
Calculates the function used for calculating the angular
dependence of synchrotron radiation.
- CATEGORY:
Mathematics.
- CALLING SEQUENCE:
Result = sync_f_sigma_and_pi(rAngle,rEnergy)
- INPUTS:
- rAngle: (array) the reduced angle, i.e., angle[rads]*Gamma. It can be a
scalar or a vector.
- rEnergy: (scalar) a value for the reduced photon energy, i.e.,
energy/critical_energy.
KEYWORD PARAMETERS:
- OUTPUTS:
- returns the value of the sync_f for sigma and pi polarizations
The result is an array of the same dimension as rAngle.
- PROCEDURE:
The number of emitted photons versus vertical angle Psi is
proportional to sync_f, which value is given by the formulas in the references.
- References:
- G K Green, “Spectra and optics of synchrotron radiation”
BNL 50522 report (1976)
- A A Sokolov and I M Ternov, Synchrotron Radiation,
Akademik-Verlag, Berlin, 1968
- OUTPUTS:
returns the value of the sync_f function
- PROCEDURE:
Uses BeselK() function
- MODIFICATION HISTORY:
Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-05-23
- 2002-07-12 srio@esrf.fr adds circular polarization term for
wavelength integrated spectrum (S&T formula 5.25)
2012-02-08 srio@esrf.eu: python version 2019-10-31 srio@lbl.gov speed-up changes for shadow4
- srxraylib.sources.srfunc.sync_f_sigma_and_pi_approx(rAngle, rEnergy)[source]
angular dependency of synchrotron radiation emission. Using approximated Modified Bessel functions.
- NAME:
sync_f_sigma_and_pi
- PURPOSE:
Calculates the function used for calculating the angular
dependence of synchrotron radiation.
- CATEGORY:
Mathematics.
- CALLING SEQUENCE:
Result = sync_f_sigma_and_pi(rAngle,rEnergy)
- INPUTS:
- rAngle: (array) the reduced angle, i.e., angle[rads]*Gamma. It can be a
scalar or a vector.
- rEnergy: (scalar) a value for the reduced photon energy, i.e.,
energy/critical_energy.
KEYWORD PARAMETERS:
- OUTPUTS:
- returns the value of the sync_f for sigma and pi polarizations
The result is an array of the same dimension as rAngle.
- PROCEDURE:
The number of emitted photons versus vertical angle Psi is
proportional to sync_f, which value is given by the formulas in the references.
- References:
- G K Green, “Spectra and optics of synchrotron radiation”
BNL 50522 report (1976)
- A A Sokolov and I M Ternov, Synchrotron Radiation,
Akademik-Verlag, Berlin, 1968
- OUTPUTS:
returns the value of the sync_f function
- PROCEDURE:
Uses BeselK() function
- MODIFICATION HISTORY:
Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-05-23
- 2002-07-12 srio@esrf.fr adds circular polarization term for
wavelength integrated spectrum (S&T formula 5.25)
2012-02-08 srio@esrf.eu: python version 2019-10-31 srio@lbl.gov speed-up changes for shadow4
- srxraylib.sources.srfunc.sync_g1(x, polarization=0)[source]
Calculates the synchrotron radiation g1 function.
Calculates the functions used for calculating synchrotron radiation energy spectrum integrated over the full vertical angle.
- Parameters:
x (float or numpy array) – the argument of the function.
polarization (int, optional) – POLARIZATION: 0 = Total; 1 = Parallel (l2=1, l3=0, in Sokolov&Ternov notation); 2 = Perpendicular (l2=0, l3=1)
- Returns:
returns the value of the g1 function.
- Return type:
float or numpy array
Notes
The number of emitted photons versus energy is: N(E) = 2.4605e13 I[A] Ee[Gev] Theta[mrad] Sync_G1(E/Ec] Where: I is the storage ring intensity in A; Ee is the energy of the electrons in the storage ring ; E is the photon energy; Ec is the critical energy; The value Sync_G1 returned by this function is:
sync_g1(x) (total polarization): x* Integrate[BeselK[x,5/3],{x,y,Infinity}]
sync_g1(x,Pol=1) (parallel polarization): (1/2)* [x* Integrate[BesselK[x,5/3],{x,y,Infinity}] + x*BesselK(x,2/3)]
sync_g1(x,Pol=2) (perpendicular polarization): (1/2)* [x* Integrate[BesselK[x,5/3],{x,y,Infinity}] - x*BesselK(x,2/3)]
For calculating the Integrate[BeselK[x,5/3],{x,y,Infinity}] function, the function fintk53 is used.
Reference: A A Sokolov and I M Ternov, Synchrotron Radiation, Akademik-Verlag, Berlin, 1968, Formula 5.19, pag 32.
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-05-24
20120208 srio@esrf.eu: python version
- srxraylib.sources.srfunc.sync_hi(x, i=2, polarization=0)[source]
Calculates the function Hi(x) used for Synchrotron radiation.
Hi(x) = x^i * BesselK(x/2,2/3) (for total polarization).
- Parameters:
x (float or numpy array) – the argument of the function.
i (int, optional) – the exponent. If this optional argument is not entered, it is set to 2.
polarization (int, optional) – 0 Total, 1 Parallel (l2=1, l3=0, in Sokolov&Ternov notation), 2 Perpendicular (l2=0, l3=1).
- Returns:
returns the value of the sync_hi function.
- Return type:
float or numpy array
Notes
Uses the relation ship Hi(x) = x^i * sync_f(0,x).
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-05-23
20120208 srio@esrf.eu: python version
- srxraylib.sources.srfunc.wiggler_cdf(traj, enerMin=10000.0, enerMax=10010.0, enerPoints=101, outFile='', elliptical=False)[source]
Calculates the cdf (cumulative density function) of a wiggler using the electron trajectory as input.
- Parameters:
traj (numpy array) – The array with the electron trajectory (created by wiggler_trajectory).
enerMin (float, optional) – Minimum photon energy [eV].
enerMax (float, optional) – Maximum photon energy [eV].
enerPoints (int, optional) – Number of points in photon energy, for internal integration.
outFile (str, optional) –
The file name with the output. If it is ‘’ no file is written. The results are stored in ASCII, in the format:
np step bener 1.0/curv_max 1.0/curv_min enerMin enerMax np fields with: x[i] y[i] cdf[i] angle[i] curv[i], where np: number of points in trajectory, step: the step in y in m from trajectory, bener: the electron energy in GeV, curv_max: trajectory maximum curvature in m^-1,, curv_min: trajectory maximum curvature in m^-1, x,y: electron coordinates in m, cdf: cumulative distribution function, angle: the deviation angle of the electron in rad, curv: the trajectory curvature in m^-1.
elliptical (boolean, optional) – [not used ] Flag for elliptical wigglers [not yet implemented].
- Returns:
a dictionary with data under the keys: “np”,”step”,”bener”,”inv_curv_max”,”inv_curv_min”,”emin”,”emax”,”x”,”y”,”cdf”,”angle”,”curv”.
- Return type:
dict
Notes
Based on SHADOW’s one. Uses wiggler_nphoton
Written by: M. Sanchez del Rio, srio@esrf.eu, 2014-10-21
- srxraylib.sources.srfunc.wiggler_harmonics(Bs, Nh=41, fileOutH='')[source]
Calculates the harmonic decomposition of the magnetic field map B[s].
- Parameters:
Bs (numpy array) – An array [npoints,2] with B [T] vs s[m]
Nh (int, optional) – The number of harmonics for the decomposition.
fileOutH (str, optional) – A file name where to write the resulting decomposition. If set to ‘’ (default) no file is written.
- Returns:
an array [2,nH] with the number of harmonic and the coefficient.
- Return type:
numpy array
Notes
Based on Fourier filtering. See http://stackoverflow.com/questions/5843085/fourier-series-in-numpy-question-about-previous-answer
Written by: M. Sanchez del Rio, srio@esrf.fr, 2014-10-08.
- srxraylib.sources.srfunc.wiggler_nphoton(r_m, electronEnergy=1.0, photonEnergy=1000.0, polarization=0, f_psi=0, psi_min=0.0, psi_max=0.0, psi_npoints=1)[source]
Calculates the synchrotron radiation spectrum versus bending radius.
Assumptions: Electron current = 1 mA, Horizontal divergence = 1mrad, Energy bandwidth = 1 eV.
- Parameters:
r_m (numpy array) – the array with the bending radii in m
electronEnergy (float, optional) – electrons energy in GeV.
photonEnergy (float or numpy array, optional) – photon energy in eV.
polarization (int, optional) – 0: Total, 1: Parallel (l2=1, l3=0, in Sokolov&Ternov notation) ,2: Perpendicular (l2=0, l3=1).
f_psi (int, optional) – flag with the type of calculation: * 0: Flux fully integrated in angle (Psi), * 1: Flux at Psi=0, * 2: Flux integrated in the angular interval [Psi_Min,Psi_Max], * 3: Flux at Psi=Psi_Min, * 4: Flux versus angle in [Psi_Min,Psi_Max] and energy.
psi_min (float, optional) – Psi_Min the minimum integration angle [in mrad] for f_psi=2 or the integration angle for f_psi=3.
psi_max (float, optional) – Psi_Max the maximum integration angle [in mrad] (for f_psi=2).
psi_npoints (float, optional) – the number of points in psi for integration (for f_psi=2).
- Returns:
returns the array with the flux [photons/sec/1eV/mrad/mA).
- Return type:
numpy array
Notes
It uses sync_ene
References
G K Green, “Spectra and optics of synchrotron radiation”, BNL 50522 report (1976).
A A Sokolov and I M Ternov, Synchrotron Radiation, Akademik-Verlag, Berlin, 1968.
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-06-24.
2012-10-08 srio@esrf.eu python version.
- srxraylib.sources.srfunc.wiggler_spectrum(traj, enerMin=1000.0, enerMax=100000.0, nPoints=100, per=0.2, electronCurrent=0.2, outFile='', elliptical=False, verbose=True, polarization=0)[source]
Calculates the spectrum of a wiggler using an electron trajectory as input.
- Parameters:
traj (numpy array) – The array with the electron trajectory (created by wiggler_trajectory).
enerMin (float, optional) – Minimum photon energy [eV].
enerMax (float, optional) – Maximum photon energy [eV].
nPoints (int, optional) – Number of energy points.
electronCurrent (float, optional) – The electron beam current in A.
per (float, optional) – [not used!] The ID period in m.
outFile (str, optional) – The file name with the output. If set to ‘’ it does not write a file.
elliptical (boolean, optional) – [not used!] Flag for elliptical wiggler [not yet implemented].
verbose (boolean, optional) – flag for verbose output.
polarization (int, optional) – 0: Total, 1: Parallel (l2=1, l3=0, in Sokolov&Ternov notation), 2: Perpendicular (l2=0, l3=1).
- Returns:
An array with the resulting spectrum.
- Return type:
numpy array
Notes
It is based on SHADOW’s wiggler_spectrum. It uses wiggler_nphoton.
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-07-15.
2002-07-18 srio@esrf.fr adds doc. Use “current” value.
2006-06-18 srio@esrf.fr uses hc from Physical_Constants().
2012-10-08 srio@esrf.eu python version.
- srxraylib.sources.srfunc.wiggler_spectrum_on_aperture(traj, enerMin=1000.0, enerMax=100000.0, nPoints=100, per=0.2, electronCurrent=0.2, outFile='', elliptical=False, verbose=True, polarization=0, psi_min=-0.001, psi_max=0.001, psi_npoints=100, theta_min=-0.001, theta_max=0.001, traj_res_fac=10000.0, slit_points_factor=1)[source]
Calculates the spectrum of a wiggler using an electron trajectory as input.
- Parameters:
traj (numpy array) – The array with the electron trajectory (created by wiggler_trajectory).
enerMin (float, optional) – Minimum photon energy [eV].
enerMax (float, optional) – Maximum photon energy [eV].
nPoints (int, optional) – Number of energy points.
electronCurrent (float, optional) – The electron beam current in A.
per (float, optional) – [not used!] The ID period in m.
outFile (str, optional) – The file name with the output. If set to ‘’ it does not write a file.
elliptical (boolean, optional) – [not used!] Flag for elliptical wiggler [not yet implemented].
verbose (boolean, optional) – flag for verbose output.
polarization (int, optional) – 0: Total, 1: Parallel (l2=1, l3=0, in Sokolov&Ternov notation), 2: Perpendicular (l2=0, l3=1).
psi_min (float, optional) – Psi_Min the minimum integration angle [in mrad].
psi_max (float, optional) – Psi_Max the maximum integration angle [in mrad].
psi_npoints (float, optional) – the number of points in psi for integration.
theta_min (float, optional) – Theta_Min the minimum horizontal angle [in mrad].
theta_max (float, optional) – Theta_Max the maximum horizontal angle [in mrad].
traj_res_fac (float, optional) – Factor to resample the original electron trajectory.
slit_points_factor (float, optional) – Factor to increase the number of points in trajectory on a given aperture.
- Returns:
An array with the resulting spectrum.
- Return type:
numpy array
Notes
It is based on SHADOW’s wiggler_spectrum. It uses wiggler_nphoton.
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-07-15.
2002-07-18 srio@esrf.fr adds doc. Use “current” value.
2006-06-18 srio@esrf.fr uses hc from Physical_Constants().
2012-10-08 srio@esrf.eu python version.
- srxraylib.sources.srfunc.wiggler_trajectory(b_from=0, inData='', nPer=12, nTrajPoints=100, ener_gev=6.04, per=0.125, kValue=14.0, trajFile='', shift_x_flag=0, shift_x_value=0.0, shift_betax_flag=0, shift_betax_value=0.0, verbose=False)[source]
Calculates the trajectory of the electrons under a magnetic field in Z direction.
It is based on btraj.f, a utility written in 10/91 by M. Sanchez del Rio and C. Vettier to input asymmetric wigglers in SHADOW.
See formulas in ESRF red book pag CIV-297.
- Parameters:
b_from (int, optional) – A Flag for the type of inpyt magnetic field, * 0: kValue (deflecting parameters) is given, * 1: A file with the magnetic field (y[m] B[T]) is given, * 2: A file with the magnetic field harmonics (n Bn[T]) is given.
inData (str, optional) – A string with the file with the file name containing the field information (for b_from:1,2), or a [npoint,2] numpy array with the field information.
nPer (int, optional) – Number of periods.
nTrajPoints (int, optional) – Number of trajectory points (per period).
ener_gev (float, optional) – The electron energy in GeV.
per (float, optional) – Wiggler period in meters (for b_from equal to 1 or 3).
kValue (float, optional) – The K (deflecting parameter) value.
trajFile (str, optional) – he name of a file where the resut is written. (Default: ‘’ no written file).
shift_x_flag (int, optional) – a flag to indicate how to shift x (electron transversal coordinate): 0 = No shift, 1 = Half excursion, 2 = Minimum, 3 = Maximum, 4 = Value at zero, 5 = User value.
shift_x_value (float, optional) – The user value for shift x (if shift_x_flag=5).
shift_betax_flag (int, optional) – a flag to indicate how to shift the betax coordinate (electron transversal velocity): 0 = No shift, 1 = Half excursion, 2 = Minimum, 3 = Maximum, 4 = Value at zero, 5 = User value.
shift_betax_value (float, optional) – The user value for shift betax (if shift_betax_flag=5).
verbose (int, optional) – if True prints some info.
- Returns:
(traj,pars): traj: a numpy array with the output data (8 colums with: x[m] y[m] z[m] BetaX BetaY BetaZ Curvature B[T]), pars: a variable with text info.
- Return type:
tuple
Notes
- Written by: M. Sanchez del Rio, srio@esrf.fr, 2002-07-17.
2002-07-17 srio@esrf.fr.
2012-10-08 srio@esrf.eu python version.