shadow4.sources.source_geometrical package

Submodules

shadow4.sources.source_geometrical.probability_distributions module

Samplers for typical mathematical probability distributions (1D and 2D).

class shadow4.sources.source_geometrical.probability_distributions.Cone2D(cone_max=1e-05, cone_min=0.0)[source]

Bases: Distribution2D

Defines the 2D Cone mathematical distribution.

Parameters:
  • cone_max (float, optional) – The maximum aperture of the cone in rad.

  • cone_min (float, optional) – The minimum aperture of the cone in rad.

get_sampled_points(N)[source]

Returns the sampled points.

Parameters:

N (int) – The number of points to be sampled.

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

classmethod sample(N, cone_max=1e-05, cone_min=0.0)[source]
class shadow4.sources.source_geometrical.probability_distributions.Distribution1D[source]

Bases: DistributionGeneric

Defines a generic 1D mathematical distribution class.

get_dimension()[source]

Returns the dimension of the distribution.

Returns:

returns 1.

Return type:

int

class shadow4.sources.source_geometrical.probability_distributions.Distribution2D[source]

Bases: DistributionGeneric

Defines a generic 2D mathematical distribution class.

get_dimension()[source]

Returns the dimension of the distribution.

Returns:

returns 2.

Return type:

int

class shadow4.sources.source_geometrical.probability_distributions.DistributionGeneric[source]

Bases: SynedObject

Base class for a mathematical distribution.

Note

It inherits from SynedObject to use the syned mechanism of displaying parameters.

get_dimension()[source]

Returns the dimension. To be defined in the derived class.

Raises:

NotImplementedError

get_sampled_points()[source]

Returns the number of sampling points. To be defined in the derived class.

Raises:

NotImplementedError

class shadow4.sources.source_geometrical.probability_distributions.Ellipse2D(h_min, h_max, v_min, v_max)[source]

Bases: Distribution2D

Defines an ellipse 2D mathematical distribution.

Parameters:
  • h_min (float) – The minimum coordinate of the ellipse in the horizontal direction.

  • h_max (float) – The maximum coordinate of the ellipse in the horizontal direction.

  • v_min (float) – The minimum coordinate of the ellipse in the vertical direction.

  • v_max (float) – The maximum coordinate of the ellipse in the vertical direction.

get_sampled_points(N)[source]

Returns the sampled points.

Parameters:

N (int) – The number of points to be sampled.

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

classmethod sample(N, h_min, h_max, v_min, v_max)[source]

Returns sampled points for a 2D ellipse distribution.

Parameters:
  • N (int) – The number of points to be sampled.

  • h_min (float) – The minimum coordinate of the ellipse in the horizontal direction

  • h_max (float) – The maximum coordinate of the ellipse in the horizontal direction

  • v_min (float) – The minimum coordinate of the ellipse in the vertical direction

  • v_max (float) – The maximum coordinate of the ellipse in the vertical direction

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

class shadow4.sources.source_geometrical.probability_distributions.Flat2D(h_min, h_max, v_min, v_max)[source]

Bases: Rectangle2D

Defines a flat 2D mathematical distribution (the same as Rectangle2D).

“Flat” means that the ray divergence distribution is constant versus the angles with the YZ and XY planes. Strictly speaking, the “angles” with the YZ and XY planes are indeed the direction cosines with the X and Z axis. In the small angle approximation, theta=sin(theta).

Parameters:
  • h_min (float) – The minimum coordinate of the rectangle in the horizontal direction.

  • h_max (float) – The maximum coordinate of the rectangle in the horizontal direction.

  • v_min (float) – The minimum coordinate of the rectangle in the vertical direction.

  • v_max (float) – The maximum coordinate of the rectangle in the vertical direction.

class shadow4.sources.source_geometrical.probability_distributions.Gaussian1D(sigma=0.001, center=0.0)[source]

Bases: Distribution1D

Defines a 1D Gaussian distribution.

Parameters:
  • sigma (float, optional) – The sigma of the Gaussian.

  • center (float, optional) – The center of the Gaussian.

get_sampled_points(N)[source]

Returns the sampled points.

Parameters:

N (int) – The number of points to be sampled.

Returns:

The arrays with the N sampled points.

Return type:

numpy array

classmethod sample(N=1000, sigma=0.25, center=0.0)[source]

Returns sampled points for a 1D Uniform distribution.

Parameters:
  • N (int) – The number of points to be sampled.

  • sigma (float, optional) – The sigma of the Gaussian.

  • center (float, optional) – The center of the Gaussian.

Returns:

The arrays with the N sampled points.

Return type:

numpy array

class shadow4.sources.source_geometrical.probability_distributions.Gaussian2D(sigma_h, sigma_v)[source]

Bases: Distribution2D

Defines a Gaussian 2D mathematical distribution.

Parameters:
  • sigma_h (float) – The sigma in the horizontal direction.

  • sigma_v (float) – The sigma in the vertical direction.

get_sampled_points(N)[source]

Returns the sampled points.

Parameters:

N (int) – The number of points to be sampled.

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

classmethod sample(N, sigma_h, sigma_v)[source]

Returns sampled points for a 2D Gaussian distribution.

Parameters:
  • N (int) – The number of points to be sampled.

  • sigma_h (float) – The Gaussian sigma in the horizontal direction.

  • sigma_v (float) – The Gaussian sigma in the vertical direction.

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

class shadow4.sources.source_geometrical.probability_distributions.Point2D(h_center=0.0, v_center=0.0)[source]

Bases: Distribution2D

get_sampled_points(N)[source]

Returns the sampled points.

Notes:

The multiple resulting points are always identical, as it is a point.

param N:

The number of points to be sampled.

type N:

int

returns:

(H,V) The arrays for the H and V.

rtype:

tuple

class shadow4.sources.source_geometrical.probability_distributions.Rectangle2D(h_min, h_max, v_min, v_max)[source]

Bases: Distribution2D

get_sampled_points(N)[source]

Returns the sampled points.

Parameters:

N (int) – The number of points to be sampled.

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

classmethod sample(N, h_min, h_max, v_min, v_max)[source]

Returns sampled points for a 2D rectangular distribution.

Parameters:
  • N (int) – The number of points to be sampled.

  • h_min (float) – The minimum coordinate of the rectangle in the horizontal direction

  • h_max (float) – The maximum coordinate of the rectangle in the horizontal direction

  • v_min (float) – The minimum coordinate of the rectangle in the vertical direction

  • v_max (float) – The maximum coordinate of the rectangle in the vertical direction

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

class shadow4.sources.source_geometrical.probability_distributions.Uniform1D(x_min=-0.01, x_max=0.01)[source]

Bases: Distribution1D

get_sampled_points(N)[source]

Returns the sampled points.

Parameters:

N (int) – The number of points to be sampled.

Returns:

The arrays with the N sampled points.

Return type:

numpy array

classmethod sample(N=1000, x_min=-0.01, x_max=0.01)[source]

Returns sampled points for a 1D Uniform distribution.

Parameters:
  • N (int) – The number of points to be sampled.

  • x_min (float, optional) – The minimum coordinate.

  • x_max (float, optional) – The maximum coordinate.

Returns:

The arrays with the N sampled points.

Return type:

numpy array

class shadow4.sources.source_geometrical.probability_distributions.Uniform2D(h_min, h_max, v_min, v_max)[source]

Bases: Distribution2D

Defines a uniform 2D mathematical distribution.

“Uniform” means that the rays will illuminate homogeneously a screen at a given distance of the source. This corresponds to the isotropic emitter.

Parameters:
  • h_min (float) – The minimum angular coordinate in the horizontal direction.

  • h_max (float) – The maximum angular coordinate in the horizontal direction.

  • v_min (float) – The minimum angular coordinate in the vertical direction.

  • v_max (float) – The maximum angular coordinate in the vertical direction.

get_sampled_points(N)[source]

Returns the sampled points.

Parameters:

N (int) – The number of points to be sampled.

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

classmethod sample(N, h_min, h_max, v_min, v_max)[source]

Returns sampled points for a 2D Uniform distribution.

Parameters:
  • N (int) – The number of points to be sampled.

  • h_min (float) – The minimum angular coordinate in the horizontal direction.

  • h_max (float) – The maximum angular coordinate in the horizontal direction.

  • v_min (float) – The minimum angular coordinate in the vertical direction.

  • v_max (float) – The maximum angular coordinate in the vertical direction.

Returns:

(H,V) The arrays for the H and V.

Return type:

tuple

shadow4.sources.source_geometrical.source_gaussian module

This is a Gaussian source in both space and divergence coordinates.

It may be redundant with SourceGeometrical.

Notes

Not used in OASYS. Not creating python scripts.

class shadow4.sources.source_geometrical.source_gaussian.SourceGaussian(name='Undefined', nrays=5000, seed=123456, sigmaX=1e-06, sigmaY=1e-06, sigmaZ=0.0, sigmaXprime=1e-06, sigmaZprime=1e-06, real_space_center=None, direction_space_center=None)[source]

Bases: S4LightSourceBase

Defines a Gaussian source in 3D.

Parameters:
  • sigmaX (float, optional) – The sigma in X direction (width).

  • sigmaY (float, optional) – The sigma in Y direction (depth).

  • sigmaZ (float, optional) – The sigma in Z direction (height).

  • sigmaXprime (float, optional) – The divergence in X direction in rad.

  • sigmaZprime (float, optional) – The divergence in Z direction in rad.

  • real_space_center (list, tuple or numpy array, optional) – The 3 coordinates of the center in real space.

  • direction_space_center (list, tuple or numpy array, optional) – The 2 coordinates of the center in divergence space (X,Z).

  • name (str, optional) – A name.

  • nrays (int, optional) – Number of rays generated using SourceGaussian.get_beam()

  • seed (int, optional) – Seed for the Monte Carlo generator.

get_beam(wavelength=1e-10)[source]

Returns an instance of S4Beam with the sampled rays.

Parameters:

wavelength (float, optional) – The photon wavelength in Angstroms.

Return type:

instance of S4Beam

get_info()[source]

Returns an array of strings with info.

Return type:

str

get_number_of_points()[source]

Returns the number of rays.

Return type:

int

get_sigmas_direction_space()[source]

Returns the sigmas in divergence space.

Returns:

(sigmaX’, sigmaZ’)

Return type:

tuple

get_sigmas_real_space()[source]

Returns the sigmas in real space.

Returns:

(sigmaX, sigmaY, sigmaZ)

Return type:

tuple

classmethod initialize_collimated_source(name='Undefined', nrays=10000, seed=12345, sigmaX=1.0, sigmaY=0.0, sigmaZ=1.0, real_space_center=None, direction_space_center=None)[source]

Creates a Gaussian source with zero dimension in divergence space space.

Parameters:
  • sigmaX (float, optional) – The sigma in X direction (width).

  • sigmaY (float, optional) – The sigma in Y direction (depth).

  • sigmaZ (float, optional) – The sigma in Z direction (height).

  • name (str, optional) – A name.

  • nrays (int, optional) – Number of rays generated using SourceGaussian.get_beam()

  • seed (int, optional) – Seed for the Monte Carlo generator.

Return type:

instance of SourceGaussian.

classmethod initialize_from_keywords(name='Undefined', nrays=10000, seed=12345, sigmaX=1e-06, sigmaY=1e-06, sigmaZ=0.0, sigmaXprime=1e-06, sigmaZprime=1e-06, real_space_center=None, direction_space_center=None)[source]

Creates a Gaussian source in 3D.

Parameters:
  • sigmaX (float, optional) – The sigma in X direction (width).

  • sigmaY (float, optional) – The sigma in Y direction (depth).

  • sigmaZ (float, optional) – The sigma in Z direction (height).

  • sigmaXprime (float, optional) – The divergence in X direction in rad.

  • sigmaZprime (float, optional) – The divergence in Z direction in rad.

  • real_space_center (list, optional) – The 3 coordinates of the center in real space.

  • direction_space_center (list, optional) – The 2 coordinates of the center in divergence space (X,Z).

  • name (str, optional) – A name.

  • nrays (int, optional) – Number of rays generated using SourceGaussian.get_beam()

  • seed (int, optional) – Seed for the Monte Carlo generator.

Return type:

instance of SourceGaussian.

classmethod initialize_point_source(name='Undefined', nrays=10000, seed=12345, sigmaXprime=1e-06, sigmaZprime=1e-06, real_space_center=None, direction_space_center=None)[source]

Creates a Gaussian source with zero dimension in real space.

Parameters:
  • real_space_center (list, optional) – The 3 coordinates of the center in real space.

  • direction_space_center (list, optional) – The 2 coordinates of the center in divergence space (X,Z).

  • name (str, optional) – A name.

  • nrays (int, optional) – Number of rays generated using SourceGaussian.get_beam()

  • seed (int, optional) – Seed for the Monte Carlo generator.

Return type:

instance of SourceGaussian.

shadow4.sources.source_geometrical.source_geometrical module

Geometrical sources.

class shadow4.sources.source_geometrical.source_geometrical.SourceGeometrical(name='Undefined', spatial_type='Point', angular_distribution='Flat', energy_distribution='Single line', depth_distribution='Off', nrays=5000, seed=1234567)[source]

Bases: S4LightSourceBase

Implements a geometrical source in shadow4.

Parameters:
  • name (str, optional) – The source name.

  • spatial_type (str, optional) – A keyword of “Point”, “Rectangle”, “Ellipse”, “Gaussian”.

  • angular_distribution (str, optional) – A keyword of “Flat”, “Uniform”, “Gaussian”, “Cone”, “Collimated”.

  • energy_distribution (str, optional) – A keyword of “Single line”, “Several lines”, “Uniform”, “Relative intensities”, “Gaussian”, “User defined”.

  • depth_distribution (str, optional) – A keyword of “Off”, “Flat”, “Uniform”, “Gaussian”, “Cone”, “Collimated”.

  • nrays (int, optional) – The number of rays.

  • seed (int, optional) – The Monte Carlo seed.

classmethod angular_distribution_list()[source]

Returns the list of keywords or options for anglular distributions.

Returns:

[“Flat”, “Uniform”, “Gaussian”, “Cone”, “Collimated”]

Return type:

list

calculate_beam()[source]

Returns a beam sampled using the internal parameters stored.

Returns:

The sampled beam.

Return type:

instance of S4Beam

calculate_rays()[source]

Returns a numpy array (nrays,18) with the sampled rays.

Returns:

The sampled beam in a numpy array (nrays,18).

Return type:

numpy array

classmethod depth_distribution_list()[source]

Returns the list of options for spatial depth.

Returns:

[“Off”, “Uniform”, “Gaussian”]

Return type:

list

classmethod energy_distribution_list()[source]

Returns a list with the options of possible distributions of the photon energy.

Returns:

[“Single line”, “Several lines”, “Uniform”, “Relative intensities”, “Gaussian”, “User defined”]

Return type:

list

get_beam()[source]

Returns a beam sampled using the internal parameters stored.

Returns:

The sampled beam.

Return type:

instance of S4Beam

get_info()[source]

Returns an array of strings with info.

Return type:

str

set_angular_distribution_by_name(name)[source]

Sets the anglular distribution by keyword or name.

Parameters:

name (str) – The keyword (an element of angular_distribution_list() ).

set_angular_distribution_collimated()[source]

Sets the angular distribution as collimated.

set_angular_distribution_cone(cone_max=1e-05, cone_min=0.0)[source]

Sets the angular distribution as Cone.

Parameters:
  • cone_max (float, optional) – The maximum aperture of the cone in rad.

  • cone_min (float, optional) – The minimum aperture of the cone in rad.

set_angular_distribution_flat(hdiv1=-5e-06, hdiv2=5e-06, vdiv1=-5e-07, vdiv2=5e-07)[source]

Sets the angular distribution as flat.

Notes

The values of the limits are signed (contrary to shadow3).

Parameters:
  • hdiv1 (float, optional) – The minimum of the divergence along X (horizontal) in rad.

  • hdiv2 (float, optional) – The maximum of the divergence along X (horizontal) in rad.

  • vdiv1 (float, optional) – The minimum of the divergence along Z (vertical) in rad.

  • vdiv2 (float, optional) – The maximum of the divergence along Z (vertical) in rad.

set_angular_distribution_gaussian(sigdix=1e-06, sigdiz=1e-06)[source]

Sets the angular distribution as Gaussian.

Parameters:
  • sigdix (float, optional) – The sigma vale along X (horizontal).

  • sigdiz (float, optional) – The sigma vale along Z (vertical).

set_angular_distribution_uniform(hdiv1=-5e-06, hdiv2=5e-06, vdiv1=-5e-07, vdiv2=5e-07)[source]

Sets the angular distribution as Uniform.

Notes

The values of the limits are signed (contrary to shadow3).

Parameters:
  • hdiv1 (float, optional) – The minimum of the divergence along X (horizontal) in rad.

  • hdiv2 (float, optional) – The maximum of the divergence along X (horizontal) in rad.

  • vdiv1 (float, optional) – The minimum of the divergence along Z (vertical) in rad.

  • vdiv2 (float, optional) – The maximum of the divergence along Z (vertical) in rad.

set_depth_distribution(depth=0, source_depth_y=0.0)[source]

Set the depth distribution type and parameters.

Parameters:
  • depth (int, optional) – a flag for the type of depth distribution: 0=off, 1=uniform, 2=Gaussian

  • source_depth_y (float, optional) – width of the depth: width for uniform (depth=1) or sigma for Gaussian (depth=2).

set_depth_distribution_by_name(name, value=0.0)[source]

Sets the source depth distribution by name.

Parameters name : str

The keyword (an element of depth_distribution_list() ).

value

set_depth_distribution_gaussian(value)[source]

Sets the depth distribution as Gaussian.

Parameters:

value (float) – The sigma of the Gaussian distribution.

set_depth_distribution_off()[source]

Sets no depth.

set_depth_distribution_uniform(value)[source]

Sets depth distribution as Unifom.

Parameters:

value (float, optional) – The depth width in m.

set_energy_distribution_by_name(name)[source]

Sets the photon energy option by keyword or name.

Parameters:

name (str) – The keyword ( an element of energy_distribution_list() ).

set_energy_distribution_gaussian(center=1000.0, sigma=10.0, unit='eV')[source]

Sets the energy distribution as Gaussian.

Parameters:
  • center (float) – The Gaussian center.

  • sigma (float) – The Gaussian sigma.

  • unit (str, optional) – set to ‘eV’ for photon energy in eV or ‘A’ for wavelength in Angstroms.

set_energy_distribution_relativeintensities(values=[1000.0, 2000.0], weights=[1.0, 2.0], unit='eV')[source]

Sets the energy distribution as a several or multiple line with different intensities.

Parameters:
  • value (list, optional) – The energy or wavelength values.

  • weights (list, optional) – The intensity weights.

  • unit (str, optional) – set to ‘eV’ for photon energy in eV or ‘A’ for wavelength in Angstroms.

set_energy_distribution_severallines(values=[1000.0, 2000.0], unit='eV')[source]

Sets the energy distribution as a several or multiple line.

Parameters:
  • value (list, optional) – The energy or wavelength values.

  • unit (str, optional) – set to ‘eV’ for photon energy in eV or ‘A’ for wavelength in Angstroms.

set_energy_distribution_singleline(value=1000, unit='eV')[source]

Sets the energy distribution as a single line.

Parameters:
  • value (float, optional) – The energy or wavelength value.

  • unit (str, optional) – set to ‘eV’ for photon energy in eV or ‘A’ for wavelength in Angstroms.

set_energy_distribution_uniform(value_min=1000.0, value_max=2000.0, unit='eV')[source]

Sets the energy distribution as Uniform.

Parameters:
  • value_min (float) – The minimum valye of photon energy or wavelength.

  • value_max (float) – The minimum valye of photon energy or wavelength.

  • unit (str, optional) – set to ‘eV’ for photon energy in eV or ‘A’ for wavelength in Angstroms.

set_energy_distribution_userdefined(spectrum_abscissas, spectrum_ordinates, unit='eV')[source]

Sets the energy distribution as a user-defined array.

Parameters:
  • spectrum_abscissas (numpy.array) – The array with the abscissas of the spectrum.

  • spectrum_ordinates (numpy.array) – The array with the ordinates of the spectrum.

  • unit (str, optional) – set to ‘eV’ for photon energy in eV or ‘A’ for wavelength in Angstroms.

set_polarization(polarization_degree=1, phase_diff=0.0, coherent_beam=0)[source]

Sets the polarization.

Parameters:
  • polarization_degree (float, optional) – The polarization degree .

  • phase_diff (float, optional) – The phase difference in rad (0=linear polarization, pi/2=elliptical-right).

  • coherent_beam (int, optional) – A flag to indicate that the phase for the s-component is set to zero (coherent_beam=1) or is random for incoherent.

set_spatial_type_by_name(name)[source]

Sets the spatial type by keword or name.

Parameters:

name (str) – The keyword (an element of spatial_type_list() ).

set_spatial_type_ellipse(width=2.0, height=1.0)[source]

Sets the spatial type as a Ellipse.

Parameters:
  • width (float, optional) – The source width (axis along X) in m.

  • height (float, optional) – The source height (axis along Z) in m.

set_spatial_type_gaussian(sigma_h=2.0, sigma_v=1.0)[source]

Sets the spatial type as a Gaussian.

Parameters:
  • sigma_h (float, optional) – The source sigma along X in m.

  • sigma_v (float, optional) – The source sigma along Z in m.

set_spatial_type_point()[source]

Sets the spatial type as Point.

set_spatial_type_rectangle(width=2.0, height=1.0)[source]

Sets the spatial type as a Rectangle.

Parameters:
  • width (float, optional) – The source width (along X) in m.

  • height (float, optional) – The source height (along Z) in m.

classmethod spatial_type_list()[source]

Returns the list of options for spatial depth.

Returns:

[“Point”, “Rectangle”, “Ellipse”, “Gaussian”]

Return type:

list

to_python_code()[source]

Returns the python code for calculating the geometrical source.

Returns:

The python code.

Return type:

str

shadow4.sources.source_geometrical.source_grid_cartesian module

Grid source defined in cartesian coordinates.

class shadow4.sources.source_geometrical.source_grid_cartesian.SourceGridCartesian(real_space_width=[0.001, 0.001, 0.001], direction_space_width=[0, 0], real_space_points=[10, 10, 10], direction_space_points=[1, 1], real_space_center=[0, 0, 0], direction_space_center=[0, 0], name='Undefined', nrays=0, seed=0, wavelength=1e-10, polarization_degree=1.0, polarization_phase_deg=0.0, coherent_beam=1)[source]

Bases: S4LightSourceBase

Defines a grid source, so points starting in a cube-like volume in real space and directions gridded in X,Z

Parameters:
  • real_space_width (list, optional) – the widths of the real_space volume (parallellepipedal) [Dx,Dy,Dz].

  • direction_space_width (list, optional) – The “angular” aperture [Dx’,Dz’].

  • real_space_points (list, optional) – Number of points [Nx,Ny,Nz].

  • direction_space_points (list, optional) – Number of points [Nx’,Nz’]

  • real_space_center (list, optional) – Center coordinates in real space [Cx,Cy,Cz].

  • direction_space_center (list, optional) – Center coordinates in divergence space [Cx’,Cz’]. Note that (Cx’)^2+(Cz’)^2 < 1.

  • name (str, optional) – A name.

  • nrays (int, optional) – Number of rays generated using SourceGaussian.get_beam()

  • seed (int, optional) – Seed for the Monte Carlo generator.

  • wavelength (float, optional) – The photon wavelength in m.

  • polarization_degree (float) – The polarization degree (cos_s / (cos_s + cos_p).

  • polarization_phase_deg (float, optional) – The polarization phase in degrees (0=linear).

  • coherent_beam (int, optional) –

    1. random (incoherent), or (1) constant (coherent) s-phases.

get_arrays_direction_space()[source]

Returns two arrays with the sampled angles (in fact, the components of the direction vector).

Returns:

(x’, z’)

Return type:

tuple

get_arrays_real_space()[source]

Returns three arrays with the sampled spatial coordinates.

Returns:

(x, y, z).

Return type:

tuple

get_beam()[source]

Returns an instance of S4Beam with the sampled rays.

Return type:

instance of S4Beam

get_info()[source]

Returns an array of strings with info.

Return type:

str

get_mesh_divergences()[source]

Returns two mesh arrays (Nx, Nz) with the Xp and Zp values.

Returns:

(X’,Z’)

Return type:

tuple

get_mesh_real_space()[source]

Returns two mesh arrays with the spatial cross section coordinates X,Z.

Returns:

(x,z)

Return type:

tuple

get_number_of_points()[source]

Returns the total number of points or rays.

Return type:

int

get_volume()[source]

Returns an array (6, npoints) with x,y,z,xp,yp,zp (first index 0,1,2,3,4,5 respectively) with the spatial and direction coordinates.

Return type:

numpy array

get_volume_divergences()[source]

Returns an array (3,npoints) with xp,yp,zp (first index 0,1,2, respectively) with the direction vectors.

Return type:

numpy array

get_volume_real_space()[source]

Returns an array (3,npoints) with x,y,z (first index 0,1,2, respectively) with the spatial coordinates.

Return type:

numpy array

classmethod initialize_collimated_source(real_space_width=[1e-06, 0.0, 1e-06], real_space_points=[100, 1, 100], real_space_center=[0.0, 0.0, 0.0])[source]

Initializes a collimated source (zero divergence). :param real_space_width: real_space_width [Xwidth, Ywidth, Zwidth]. :type real_space_width: list, optional :param real_space_points: real_space_points [Nx, Ny, Nz]. :type real_space_points: list, optional :param real_space_center: real_space_points [Xcenter, Ycenter, Zcenter]. :type real_space_center: list, optional

classmethod initialize_point_source(direction_space_width=[1e-06, 1e-06], direction_space_points=[100, 100], direction_space_center=[0.0, 0.0])[source]

Initializes a point source (zero size).

Parameters:
  • direction_space_width (list, optional) – Interval for the direction space [Xwidth, Zwidth].

  • direction_space_points (list, optional) – Number of points for the direction space [Nx, Nz].

  • direction_space_center (list, optional) – Center for the direction space [Xcenter, Zcenter].

Return type:

instance of SourceGridCartesian.

to_python_code()[source]

Returns the python code to recreate the grid source.

Returns:

The python code.

Return type:

str

shadow4.sources.source_geometrical.source_grid_polar module

Grid source defined in polar coordinates.

class shadow4.sources.source_geometrical.source_grid_polar.SourceGridPolar(real_space_width=[1e-06, 0, 1e-06], direction_space_width=[1e-06, 1e-06], real_space_points=[100, 36], direction_space_points=[1, 1], real_space_center=[0, 0, 0], direction_space_center=[0, 1, 0], name='Undefined', nrays=0, seed=0, wavelength=1e-10, polarization_degree=1.0, polarization_phase_deg=0.0, coherent_beam=1)[source]

Bases: S4LightSourceBase

get_beam()[source]

Returns an instance of S4Beam with the sampled rays.

Return type:

instance of S4Beam

get_info()[source]

Returns an array of strings with info.

Return type:

str

get_number_of_points()[source]

Returns the total number of points.

Return type:

int

get_number_of_points_direction_space()[source]

Returns the number of points in direction space.

Return type:

int

get_number_of_points_real_space()[source]

Returns the number of points in real space.

Return type:

int

classmethod initialize_collimated_source(real_space_width=[1e-06, 0.0, 1e-06], real_space_points=[100, 36], real_space_center=[0.0, 0.0, 0.0], direction_space_center=[0.0, 0.0])[source]
Parameters:
  • real_space_width (list, optional) – The widths of the real_space_width volume [2a, 2b, 2c] of the ellipsoid.

  • real_space_points (list, optional) – Number of points [Nradial, Nangular].

  • real_space_center (list, optional) – Center cartesian coordinates in real space [Xc, Yc, Zc].

  • direction_space_center (list, optional) – Center coordinates in divergence space [X’_c,Z’_c]. Note that (X’)^2+(Z’)^2 < 1.

Return type:

instance of SourceGridPolar.

classmethod initialize_point_source(real_space_center=[0.0, 0.0, 0.0], direction_space_width=[1e-06, 1e-06], direction_space_points=[5, 36], direction_space_center=[0.0, 0.0])[source]

Initializes a point source.

Parameters:
  • direction_space_width (list, optional) – The “angular” aperture [Dx’,Dz’].

  • direction_space_points (list, optional) – Number of points [Nradial’, Nangular’].

  • real_space_center (list, optional) – Center cartesian coordinates in real space [Xc,Yc,Zc].

  • direction_space_center (list, optional) – Center coordinates in divergence space [X’_c,Z’_c]. Note that (X’)^2+(Z’)^2 < 1.

Return type:

instance of SourceGridPolar.

to_python_code()[source]

Returns the python code to recreate the grid source.

Returns:

The python code.

Return type:

str

Module contents