xoppylib.srcalc package
Submodules
xoppylib.srcalc.beam module
Beam class for shadow-like sequential ray-optics calculations.
- class xoppylib.srcalc.beam.Beam(N=1000, array=None)[source]
Bases:
object- get_column(column, nolost=0)[source]
- Possible choice for column are:
1 X spatial coordinate [user’s unit] 2 Y spatial coordinate [user’s unit] 3 Z spatial coordinate [user’s unit] 4 Xp direction or divergence [rads] 5 Yp direction or divergence [rads] 6 Zp direction or divergence [rads] 7 X component of the electromagnetic vector (s-polariz) 8 Y component of the electromagnetic vector (s-polariz) 9 Z component of the electromagnetic vector (s-polariz)
10 Lost ray flag 11 wavenumber (2 pi / lambda[cm]) 12 Ray index 13 Optical path length 14 Phase (s-polarization) in rad 15 Phase (p-polarization) in rad 16 X component of the electromagnetic vector (p-polariz) 17 Y component of the electromagnetic vector (p-polariz) 18 Z component of the electromagnetic vector (p-polariz)
19 Wavelength [A] 20 R= SQRT(X^2+Y^2+Z^2) 21 angle from Y axis 22 the magnituse of the Electromagnetic vector 23 |E|^2 (total intensity) 24 total intensity for s-polarization 25 total intensity for p-polarization 26 K = 2 pi / lambda [A^-1] 27 K = 2 pi / lambda * col4 [A^-1] 28 K = 2 pi / lambda * col5 [A^-1] 29 K = 2 pi / lambda * col6 [A^-1] 30 S0-stokes = |Ep|^2 + |Es|^2 31 S1-stokes = |Ep|^2 - |Es|^2 32 S2-stokes = 2 |Es| |Ep| cos(phase_s-phase_p) 33 S3-stokes = 2 |Es| |Ep| sin(phase_s-phase_p)
- Parameters:
column –
- Returns:
- get_photon_energy_eV(nolost=0)[source]
returns the array with photon energy
- Parameters:
nolost – 0: all rays 1: good rays, 2: bad rays
- Returns:
array
- get_standard_deviation(col, nolost=1, ref=0)[source]
returns the standard deviation of one viariable in the beam :param col: variable (shadow column number) :param nolost: 0 = use all rays, 1=good only, 2= lost only :param ref: 0 = no weight, 1=weight with intensity (col23) :return:
- histo2(col_h, col_v, nbins=25, ref=23, nbins_h=None, nbins_v=None, nolost=0, xrange=None, yrange=None, calculate_widths=1)[source]
performs 2d histogram to prepare data for a plotxy plot It uses histogram2d for calculations Note that this Shadow.Beam.histo2 was previously called Shadow.Beam.plotxy :param col_h: the horizontal column :param col_v: the vertical column :param nbins: number of bins :param ref :
0, None, “no”, “NO” or “No”: only count the rays 23, “Yes”, “YES” or “yes”: weight with intensity (look at col=23 |E|^2 total intensity) other value: use that column as weight
- Parameters:
nbins_h – number of bins in H
nbins_v – number of bins in V
nolost – 0 or None: all rays, 1=good rays, 2=only losses
xrange – range for H
yrange – range for V
calculate_widths – 0=No, 1=calculate FWHM (default), 2=Calculate FWHM and FW at 25% and 75% if Maximum
- Returns:
a dictionary with all data needed for plot
xoppylib.srcalc.conic module
Conic optical surface for ray tracing (mirrors and lenses).
- class xoppylib.srcalc.conic.Conic(ccc=array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]))[source]
Bases:
object- height(y=0, x=0, return_solution=0)[source]
- Parameters:
y – a scalar, vector or mesh
x –
a scalar, vector or mesh y and x must be homogeneous, otherwise an error will occur:
both scalars both mesh one scalar and another vector
return_solution – 0 = guess the solution with zero at pole, 1 = get first solution 2 = get second solution
- Returns:
the height scalar/vector/mesh depending on inputs
- classmethod initialize_as_ellipsoid_from_focal_distances(p, q, theta1, cylindrical=0, cylangle=0.0, switch_convexity=0)[source]
- classmethod initialize_as_hyperboloid_from_focal_distances(p, q, theta1, cylindrical=0, cylangle=0.0, switch_convexity=0)[source]
- classmethod initialize_as_paraboloid_from_focal_distances(p, q, theta1, cylindrical=0, cylangle=0.0, switch_convexity=0)[source]
- classmethod initialize_as_sphere_from_curvature_radius(radius, cylindrical=0, cylangle=0.0, switch_convexity=0)[source]
- classmethod initialize_as_sphere_from_focal_distances(p, q, theta1, cylindrical=0, cylangle=0.0, switch_convexity=0)[source]
xoppylib.srcalc.srcalc module
SRCALC: auxiliary functions for mirror and grating ray-optics calculations.
- xoppylib.srcalc.srcalc.compute_power_density_footprint(dict1, verbose=True, interpolation_method=0, ratio_pixels_0=1.0, ratio_pixels_1=1.0, flip_pixels_number=[0, 0, 0, 0, 0, 0])[source]
- xoppylib.srcalc.srcalc.compute_power_density_image(dict1, verbose=True, interpolation_or_histogramming=False, interpolation_method=0, ratio_pixels_0=1.0, ratio_pixels_1=1.0, flip_pixels_number=[0, 0, 0, 0, 0, 0])[source]
- xoppylib.srcalc.srcalc.interpolate_to_regular_grid(power_density_footprint, XX_FOOTPRINT, YY_FOOTPRINT, nx=None, ny=None, xrange=None, yrange=None, renormalize_integrals=True, interpolation_method=0)[source]
- xoppylib.srcalc.srcalc.load_srcalc_output_file(filename='D_IDPower.TXT', skiprows=5, four_quadrants=True, do_plot=False, verbose=True)[source]
- Parameters:
filename –
skiprows –
four_quadrants –
do_plot –
verbose –
- Returns:
out_dictionary: Zlist 0 (63, 43) <== source out_dictionary: Zlist 1 (63, 43) <== oe1 out_dictionary: Zlist 2 (63, 43) <== oe2 out_dictionary: X (63,) out_dictionary: Y (43,) out_dictionary: RAWDATA (704, 3) out_dictionary: from D_IDPower.TXT: NELEMENTS
- xoppylib.srcalc.srcalc.ray_tracing(out_dictionary, SOURCE_SCREEN_DISTANCE=13.73, number_of_elements=1, oe_parameters={'EL0_ANG': 88.75, 'EL0_P_FOCUS': 0.0, 'EL0_P_POSITION': 13.73, 'EL0_Q_FOCUS': 0.0, 'EL0_Q_POSITION': 0.0, 'EL0_RELATIVE_TO_PREVIOUS': 2, 'EL0_SHAPE': 2, 'EL0_THICKNESS': 1000}, real_space_shuffle=[0, 0, 0], accumulate_results=True, store_footprint=True, store_image=True, verbose=False, run_index=None, undo_shadow_orientation_angle_rotation=False)[source]
- Parameters:
out_dictionary –
SOURCE_SCREEN_DISTANCE –
number_of_elements –
oe_parameters –
real_space_shuffle –
accumulate_results –
verbose –
- Returns:
adds in the out_dictionary the keys: OE_FOOTPRINT: list[oe_index] ndarray(3, 2709) (shadow: col2,col1,col23) OE_IMAGE: list[oe_index] ndarray(3, 2709) (shadow: col2,col1,col23)
xoppylib.srcalc.toroid module
Toroid optical surface for ray tracing.