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

classmethod column_names()[source]
difference(beam2)[source]
duplicate()[source]
genSource(source_object)[source]
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_columns(columns, nolost=0)[source]
get_intensity(nolost=0)[source]
get_number_of_rays(nolost=0)[source]
Parameters:

nolost – flag (default=0)

Returns:

number of rays

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_photon_wavelength()[source]
get_rays()[source]
Returns:

numpy array (npoints,18)

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

identical(beam2)[source]
info()[source]
Returns:

classmethod initialize_as_pencil(N=1000)[source]
Parameters:

array

Returns:

classmethod initialize_from_array(array)[source]
Parameters:

array

Returns:

intensity(nolost=0)[source]
classmethod load(filename, simulation_name='run001', beam_name='begin')[source]
retrace(dist, resetY=False)[source]
Parameters:
  • dist

  • resetY

Returns:

rotate(theta1, axis=1, rad=1)[source]
Parameters:
  • theta1 – the rotation angle in degrees (default=0)

  • axis – The axis number (Shadow’s column) for the rotation (i.e, 1:x (default), 2:y, 3:z)

  • file

  • rad – set this flag when theta1 is in radiants

Returns:

set_column(column, value)[source]
Parameters:
  • column

  • value

Returns:

set_photon_energy_eV(energy_eV)[source]
set_photon_wavelength(wavelength)[source]
traceOE(oe_object, n, overwrite=True)[source]
translation(qdist1)[source]
Parameters:

qdist1 – translation vector

Returns:

write(filename, overwrite=True, simulation_name='run001', beam_name='begin')[source]

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

apply_specular_reflection_on_beam(newbeam)[source]
calculate_intercept(XIN, VIN, keep=0)[source]
choose_solution(TPAR1, TPAR2, reference_distance=10.0)[source]
duplicate()[source]
get_coefficients()[source]
get_normal(x2)[source]
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

info()[source]
Returns:

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_plane()[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]
classmethod initialize_from_coefficients(ccc)[source]
rotation_surface_conic(alpha, axis)[source]
rotation_surface_conic_x(alpha)[source]
rotation_surface_conic_y(alpha)[source]
rotation_surface_conic_z(alpha)[source]
set_coefficients(ccc)[source]
set_cylindrical(CIL_ANG)[source]
set_ellipsoid_from_focal_distances(ssour, simag, theta_grazing, verbose=True)[source]
set_hyperboloid_from_focal_distances(SSOUR, SIMAG, theta_grazing, verbose=True)[source]
set_paraboloid_from_focal_distances(SSOUR, SIMAG, theta_grazing, infinity_location='', verbose=True)[source]
set_sphere_from_curvature_radius(rmirr)[source]
set_sphere_from_focal_distances(ssour, simag, theta_grazing, verbose=True)[source]
switch_convexity()[source]
translation_surface_conic(x0, axis='x')[source]
translation_surface_conic_x(x0)[source]
translation_surface_conic_y(y0)[source]
translation_surface_conic_z(z0)[source]
vector_reflection(v1, normal)[source]
z_vs_xy(x, y)[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.debug_plot_3d(zs, xs, ys, title='')[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.srcalc.trapezoidal_rule_2d(data2D, H=None, V=None)[source]
xoppylib.srcalc.srcalc.trapezoidal_rule_2d_1darrays(data2D, h=None, v=None)[source]
xoppylib.srcalc.srcalc.write_ansys_files(absorbed2d, H, V, oe_number=1, is_image=False)[source]

xoppylib.srcalc.toroid module

Toroid optical surface for ray tracing.

class xoppylib.srcalc.toroid.Toroid(coeff=None)[source]

Bases: object

apply_specular_reflection_on_beam(newbeam)[source]
calculate_intercept(XIN, VIN, keep=0)[source]
duplicate()[source]
get_coefficients()[source]
get_normal(x2)[source]
get_tangential_and_sagittal_radii()[source]
get_toroid_radii()[source]
info()[source]
Returns:

classmethod initialize_from_coefficients(coeff)[source]
set_coefficients(coeff)[source]
set_cylindrical(CIL_ANG)[source]
set_from_focal_distances(ssour, simag, theta_grazing)[source]
set_tangential_and_sagittal_radii(rtan, rsag)[source]
set_toroid_radii(r_maj, r_min)[source]
switch_convexity()[source]
vector_reflection(v1, normal)[source]

Module contents