crystalpy.util package
Submodules
crystalpy.util.CalculationStrategy module
Numeric strategy for calculation. The exp, sin and cos functions are calculated using numpy, numpy with truncation of the arguments, or arbitrary precision using mpmath.
- class crystalpy.util.CalculationStrategy.CalculationStrategy[source]
Bases:
objectAbstract strategy for calculation. Can be plain python or arbitrary precision like mpmath.
- cos(power)[source]
Cos to the power.
- Parameters:
power – The power to raise to.
- Raises:
Exception – Must override this method.
- createVariable(initial_value)[source]
Factory method for calculation variable.
- Parameters:
initial_value – Initial value of the variable.
- Raises:
Exception – Must override this method.
- exponentiate(power)[source]
Exponentiates to the power.
- Parameters:
power – The power to raise to.
- Raises:
Exception – Must override this method.
- class crystalpy.util.CalculationStrategy.CalculationStrategyMPMath[source]
Bases:
CalculationStrategyUse mpmath for calculation.
- cos(power)[source]
Cos function.
- Parameters:
power (float or numpy array) – The arg of cos.
- Returns:
Cos.
- Return type:
mpmath variable
- createVariable(initial_value)[source]
Factory method for calculation variable.
- Parameters:
initial_value (float, complex or numpy array) – Initial value of the variable.
- Returns:
variable.
- Return type:
instance of CalculationStrategyMPMath
- exponentiate(power)[source]
Exponentiates to the power.
- Parameters:
power (float) – The power to raise to.
- Returns:
Exponential.
- Return type:
mpmath variable
- class crystalpy.util.CalculationStrategy.CalculationStrategyNumpy[source]
Bases:
CalculationStrategyUse plain python for calculation.
- cos(power)[source]
Cos function.
- Parameters:
power – The coa argument.
- Returns:
Cos.
- Return type:
numpy array
- createVariable(initial_value)[source]
Factory method for calculation variable.
- Parameters:
initial_value – Initial value of the variable.
- Returns:
variable.
- Return type:
instance of CalculationStrategyNumpy
- exponentiate(power)[source]
Exponentiates to the power.
- Parameters:
power (float) – The power to raise to.
- Returns:
Exponential.
- Return type:
numpy array
- class crystalpy.util.CalculationStrategy.CalculationStrategyNumpyTruncated(limit=1000)[source]
Bases:
CalculationStrategyUse plain python for calculation.
- cos(power)[source]
Cos function.
- Parameters:
power – The coa argument.
- Returns:
Cos.
- Return type:
numpy array
- createVariable(initial_value)[source]
Factory method for calculation variable.
- Parameters:
initial_value – Initial value of the variable.
- Returns:
variable.
- Return type:
instance of CalculationStrategyNumpy
- exponentiate(power)[source]
Exponentiates to the power.
- Parameters:
power (float) – The power to raise to.
- Returns:
Exponential.
- Return type:
numpy array
crystalpy.util.ComplexAmplitudePhoton module
Represents a photon defined by its energy, direction vector and pi and sigma complex amplitudes.
- class crystalpy.util.ComplexAmplitudePhoton.ComplexAmplitudePhoton(energy_in_ev, direction_vector, Esigma=None, Epi=None)[source]
Bases:
PhotonConstructor.
- Parameters:
energy_in_ev (float) – Photon energy in eV.
direction_vector (Vector instance) – The direction of the photon (no need to be normalized).
Esigma (complex) – The sigma-amplitude.
Esigma – The pi-amplitude.
- getComplexAmplitudeP()[source]
Gets the pi complex amplitude.
- Returns:
Pi-complex amplitude.
- Return type:
complex
- getComplexAmplitudeS()[source]
Gets the sigma complex amplitude.
- Returns:
Sigma-complex amplitude.
- Return type:
complex
- getIntensity()[source]
Gets the total (sigma plus pi) intensity.
- Returns:
Intensity of photon.
- Return type:
float
- getIntensityP()[source]
Gets the pi intensity.
- Returns:
Intensity (pi) of photon.
- Return type:
float
- getIntensityS()[source]
Gets the sigma intensity.
- Returns:
Intensity (sigma) of photon.
- Return type:
float
- rescaleEpi(factor)[source]
Multiply the pi complex amplitude by a factor.
- Parameters:
factor (float) – The multiplying factor.
- rescaleEsigma(factor)[source]
Multiply the sigma complex amplitude by a factor.
- Parameters:
factor (float) – The multiplying factor.
crystalpy.util.ComplexAmplitudePhotonBunch module
A stack of “complex-amplitude” photons characterized by photon energy, direction vector and sigma and pi complex amplitudes.
- class crystalpy.util.ComplexAmplitudePhotonBunch.ComplexAmplitudePhotonBunch(complex_amplitude_photons=None)[source]
Bases:
ComplexAmplitudePhoton,ComplexAmplitudePhotonBunchDecoratorThe ComplexAmplitudePhotonBunch is a ComplexAmplitudePhoton stack.
It inheritates from ComplexAmplitudePhoton and uses stacks for more efficient stockage. Additional methods useful for stacks or bunches are defined in ComplexAmplitudePhotonBunchDecorator.
Constructor.
- Parameters:
complex_amplitude_photons (list, optional) – List of ComplexAmplitudePhoton instances.
- classmethod initializeFromArrays(energy=[], vx=[], vy=[], vz=[], Esigma=[], Epi=[])[source]
Construct a complex amplitude photon bunch from arrays with photon energies, directions and amplitudes.
- Parameters:
energies (list, numpy array) – the array with photon energy in eV.
vx (list, numpy array) – the array with X component of the direction vector.
vy (list, numpy array) – the array with Y component of the direction vector.
vz (list, numpy array) – the array with Z component of the direction vector.
Esigma (list, numpy array) – the array with S complex amplitude.
Epi (list, numpy array) – the array with P complex amplitude.
- Return type:
ComplexAmplitudePhotonBunch instance
- classmethod initializeFromComplexAmplitudePhoton(photon_stack)[source]
Construct a complex amplitude photon bunch from a complex amplitude photon stack.
- Parameters:
photon_stack (instance of ComplexAmplitudePhoton) –
- Return type:
ComplexAmplitudePhotonBunch instance
- class crystalpy.util.ComplexAmplitudePhotonBunch.ComplexAmplitudePhotonBunchDecorator[source]
Bases:
PhotonBunchDecorator- addPhoton(to_be_added)[source]
Adds a photon to the bunch.
- Parameters:
to_be_added (Photon instance) –
- getPhotonIndex(index)[source]
Returns the photon in the bunch with a given index.
- Parameters:
index (int) – The photon index to be referenced.
- Returns:
The photon (referenced, not copied).
- Return type:
Photon instance
- class crystalpy.util.ComplexAmplitudePhotonBunch.ComplexAmplitudePhotonBunchOld(complex_amplitude_photons=None)[source]
Bases:
PhotonBunchConstructor.
- Parameters:
complex_amplitude_photons (list, optional) – List of ComplexAmplitudePhoton instances.
- rescaleEpi(factor)[source]
Multiply the pi complex amplitudes by a factor array.
- Parameters:
factor (list. numpy array) – The multiplying factor array.
- rescaleEsigma(factor)[source]
Multiply the sigma complex amplitudes by a factor array.
- Parameters:
factor (list. numpy array) – The multiplying factor array.
crystalpy.util.Photon module
Represents a photon defined by its energy and direction vector
- class crystalpy.util.Photon.Photon(energy_in_ev=1000.0, direction_vector=<crystalpy.util.Vector.Vector object>)[source]
Bases:
objectConstructor.
- Parameters:
energy_in_ev (float, optional) – Photon energy in eV.
direction_vector (Vector instance, optional) – The direction of the photon (no need to be normalized).
- deviation()[source]
Returns the deviation angle (angle of the projection on YZ plane with Y axis)
- Returns:
the deviation angle. The deviations are calculated supposing that the bunch moves along the y axis
- Return type:
float
- setUnitDirectionVector(vector=<crystalpy.util.Vector.Vector object>)[source]
Sets the Photon direction.
- Parameters:
vector (Vector instance) – The vector with the direction (may be not normalized).
- unitDirectionVector()[source]
Returns the photon direction vector.
- Returns:
the photon dicection.
- Return type:
Vector instance
- wavelength()[source]
Returns the photon wavelength in m.
- Returns:
the photon wavelength
- Return type:
float
crystalpy.util.PhotonBunch module
A stack of photons, each one characterized by energy and direction.
- class crystalpy.util.PhotonBunch.PhotonBunch(photons=None)[source]
Bases:
Photon,PhotonBunchDecoratorThe PhotonBunch is a Photon stack.
It inheritates from Photon and uses stacks for more efficient stockage. Additional methods useful for stacks or bunches are defined in PhotonBunchDecorator.
Constructor.
- Parameters:
photons (list) – List of Photon instances.
- classmethod initializeFromArrays(energy=[], vx=[], vy=[], vz=[])[source]
Construct a bunch from arrays with photon energies and directions.
- Parameters:
energies (list, numpy array) – the array with photon energy in eV.
vx (list, numpy array) – the array with X component of the direction vector.
vy (list, numpy array) – the array with Y component of the direction vector.
vz (list, numpy array) – the array with Z component of the direction vector.
- Return type:
PhotonBunch instance
- class crystalpy.util.PhotonBunch.PhotonBunchDecorator[source]
Bases:
object- addBunch(to_be_added)[source]
Adds photons in a PhotonBunch instance.
- Parameters:
to_be_added (PhotonBunch instance) – Photons to be added.
- addPhoton(to_be_added)[source]
Adds a photon to the bunch.
- Parameters:
to_be_added (Photon instance) –
- addPhotonsFromList(to_be_added)[source]
Adds a list of photons to the bunch.
- Parameters:
to_be_added (list) – The photons to be added
- energies()[source]
Return the energies of the photons.
- Returns:
The energies of the photons (copied, not referenced).
- Return type:
numpy array
- getArrayByKey(key)[source]
Returns the array of a givem key in from toDictionary method
- Parameters:
key – deviations’, ‘s0’, ‘s1’, ‘s2’, ‘s3’.
- Return type:
numpy array
- getListOfPhotons()[source]
Returns a list with the photons in the bunch.
- Returns:
List with photons.
- Return type:
list
- getNumberOfPhotons()[source]
Returns the number of photons in the bunch.
- Returns:
Number of photons.
- Return type:
int
- getPhotonIndex(index)[source]
Returns the photon in the bunch with a given index.
- Parameters:
index (int) – The photon index to be referenced.
- Returns:
The photon (referenced, not copied).
- Return type:
Photon instance
- isMonochromatic(places)[source]
Inquires about bunch monochromaticity.
- Parameters:
places – number of decimal places to be taken into account for comparing energies.
- Returns:
True if all photons in the bunch have the same energy.
- Return type:
bool
- isUnidirectional()[source]
Inquires if all photons in the bunch have the same direction.
- Returns:
True if all photons have the same direction.
- Return type:
bool
- setPhotonIndex(index, polarized_photon)[source]
Sets the photon in the bunch with a given index.
- Parameters:
index (int) – The photon index to be modified.
polarized_photon (Photon instance) – The photon to be stored.
- class crystalpy.util.PhotonBunch.PhotonBunchOld(photons=None)[source]
Bases:
objectThe PhotonBunch is Photon stack instances, making up the photon bunch or beam.
Constructor.
- Parameters:
photons (list) – List of Photon instances.
- addBunch(to_be_added)[source]
Adds photons in a PhotonBunch instance.
- Parameters:
to_be_added (PhotonBunch instance) – Photons to be added.
- addPhoton(to_be_added)[source]
Adds a photon to the bunch.
- Parameters:
to_be_added (Photon instance) –
- addPhotonsFromList(to_be_added)[source]
Adds a list of photons to the bunch.
- Parameters:
to_be_added (list) – The photons to be added
- energies()[source]
Return the energies of the photons.
- Returns:
The energies of the photons (copied, not referenced).
- Return type:
numpy array
- energy()[source]
Return the energies of the photons.
- Returns:
The energies of the photons (copied, not referenced).
- Return type:
numpy array
- getArrayByKey(key)[source]
Returns the array of a givem key in from toDictionary method
- Parameters:
key – deviations’, ‘s0’, ‘s1’, ‘s2’, ‘s3’.
- Return type:
numpy array
- getListOfPhotons()[source]
Returns a list with the photons in the bunch.
- Returns:
List with photons.
- Return type:
list
- getNumberOfPhotons()[source]
Returns the number of photons in the bunch.
- Returns:
Number of photons.
- Return type:
int
- getPhotonIndex(index)[source]
Returns the photon in the bunch with a given index.
- Parameters:
index (int) – The photon index to be referenced.
- Returns:
The photon (referenced, not copied).
- Return type:
Photon instance
- classmethod initialize_from_energies_and_directions(energies, V)[source]
Construct a bunch from arrays with photon energies and directions
- Parameters:
energies (list, numpy array) –
V (Vector instance (with a tack of vectors)) –
- Return type:
PhotonBunch instance
- isMonochromatic(places)[source]
Inquires about bunch monochromaticity.
- Parameters:
places – number of decimal places to be taken into account for comparing energies.
- Returns:
True if all photons in the bunch have the same energy.
- Return type:
bool
- isUnidirectional()[source]
Inquires if all photons in the bunch have the same direction.
- Returns:
True if all photons have the same direction.
- Return type:
bool
- setPhotonIndex(index, polarized_photon)[source]
Sets the photon in the bunch with a given index.
- Parameters:
index (int) – The photon index to be modified.
polarized_photon (Photon instance) – The photon to be stored.
- setUnitDirectionVector(vector)[source]
Sets the directions of the photons.
- Parameters:
vector (Vector instance) – Stack of vectors with the directions.
- toDictionary()[source]
Created a dictionary containing information about the bunch.
- Returns:
Information in tags: “number of photons”, “energies”, “deviations”, “vx”, “vy” and “vz”.
- Return type:
dict
- toString()[source]
Returns a string containing the parameters characterizing each photon in the bunch.
- unitDirectionVector()[source]
Return the directions of the photons.
- Returns:
The directions in stacked vectors.
- Return type:
Vector instance
- wavelength()[source]
Return the wavelengths of the photons (in m).
- Returns:
The wavelengths of the photons.
- Return type:
numpy array
crystalpy.util.PlotData1D module
—OK—
- class crystalpy.util.PlotData1D.PlotData1D(title, title_x_axis, title_y_axis)[source]
Bases:
objectRepresents a 1D plot. The graph data together with related information.
- add_plot_info(name, info)[source]
Adds a plot info. :param name: Name of the info. :param info: The info.
- add_xy_point(x_point, y_point)[source]
Adds an x-y point. :param x_point: x coordinate. :param y_point: y coordinate.
- smart_unwrap(intervals, intervals_number, phase_limits, deg)[source]
Unwraps data correctly by avoiding discontinuities. :param intervals: list of pairs. Each element is a pair with the two extrema of the x interval. :param phase_limits: min and max tolerable values for the phase plot, [min, max]. :param intervals_number: number of intervals to set to zero. :param deg: True if values are in degrees. False if radians.
crystalpy.util.PolarizedPhoton module
This object represents a polarized photon, characterized by energy, direction vector and Stokes parameters.
- class crystalpy.util.PolarizedPhoton.PolarizedPhoton(energy_in_ev, direction_vector, stokes_vector)[source]
Bases:
PhotonConstructor.
- Parameters:
energy_in_ev (float) – Photon energy in eV.
direction_vector (Vector instance) – The direction of the photon (no need to be normalized).
stokes_vector (StokesVector instance) – Stokes vector describing the polarization state.
- applyMuellerMatrix(mueller_matrix=<crystalpy.polarization.MuellerMatrix.MuellerMatrix object>)[source]
Modify the stokes vector by a Muller matrix.
- Parameters:
mueller_matrix (MuellerMatrix instance, optional) – The Mueller matrix
- circularPolarizationDegree()[source]
Returns the degree of circular polarization.
- Returns:
The polarization degree.
- Return type:
float
crystalpy.util.PolarizedPhotonBunch module
A stack of polarized photons characterized by photon energy, direction vector and Stokes vector.
- class crystalpy.util.PolarizedPhotonBunch.PolarizedPhotonBunch(polarized_photons=None)[source]
Bases:
PolarizedPhoton,PolarizedPhotonBunchDecoratorThe PolarizedPhotonBunch is a PolarizedPhoton stack.
It inheritates from PolarizedPhoton and uses stacks for more efficient stockage. Additional methods useful for stacks or bunches are defined in PolarizedPhotonBunchDecorator.
Constructor.
- Parameters:
polarized_photons (list, optional) – List of PolarizedPhoton instances.
- classmethod initializeFromArrays(energy=[], vx=[], vy=[], vz=[], s0=[], s1=[], s2=[], s3=[])[source]
Construct a polarized photon bunch from arrays with photon energies, directions and stokes components.
- Parameters:
energies (list, numpy array) – the array with photon energy in eV.
vx (list, numpy array) – the array with X component of the direction vector.
vy (list, numpy array) – the array with Y component of the direction vector.
vz (list, numpy array) – the array with Z component of the direction vector.
s0 (list, numpy array) – the array with S0 stokes vector.
s1 (list, numpy array) – the array with S1 stokes vector.
s2 (list, numpy array) – the array with S2 stokes vector.
s3 (list, numpy array) – the array with S4 stokes vector.
- Return type:
PolarizedPhotonBunch instance
- classmethod initializeFromPolarizedPhoton(photon_stack)[source]
Construct a polarized photon bunch from a polarized photon stack.
- Parameters:
photon_stack (instance of PolarizedPhoton) –
- Return type:
PolarizedPhotonBunch instance
- class crystalpy.util.PolarizedPhotonBunch.PolarizedPhotonBunchDecorator[source]
Bases:
PhotonBunchDecorator- addPhoton(to_be_added)[source]
Adds a photon to the bunch.
- Parameters:
to_be_added (Photon instance) –
- getPhotonIndex(index)[source]
Returns the photon in the bunch with a given index.
- Parameters:
index (int) – The photon index to be referenced.
- Returns:
The photon (referenced, not copied).
- Return type:
Photon instance
- class crystalpy.util.PolarizedPhotonBunch.PolarizedPhotonBunchOld(polarized_photons=None)[source]
Bases:
PhotonBunchThe PolarizadPhotonBunch is is a collection of PolarizedPhoton objects, making up the polarized photon beam.
Constructor.
- Parameters:
polarized_photons (list, optional) – List of PolarizedPhoton instances.
crystalpy.util.StokesVector module
Represents a Stokes vector (four components s0, s1, s2, s3). It accepts a stack (s0, etc. are arrays).
- class crystalpy.util.StokesVector.StokesVector(element_list=[0.0, 0.0, 0.0, 0.0])[source]
Bases:
objectStokesVector Constructor.
- Parameters:
element_list (list, optional) – the Stokes parameters [S0,S1,S2,S3]
- append(vector)[source]
Appends a stoked-vector to the stack.
- Parameters:
vector (instance of StokesVector) –
- circularPolarizationDegree()[source]
Calculates the degree of circular polarization of the radiation described by the Stokes parameter.
- Returns:
Degree of circular polarization S3/S0
- Return type:
float
- components()[source]
Generates a numpy 1x4 array from the Stokes vector components.
- Returns:
The four stokes components.
- Return type:
numpy array
- concatenate(vector)[source]
Concatenates a vector to the stack.
- Parameters:
vector (instance of StokesVector) –
- Returns:
The resulting vector with the concatenation.
- Return type:
instance of StokesVector
- duplicate()[source]
Duplicates a StokesVector.
- Returns:
New StokesVector instance with identical x,y,z components.
- Return type:
StokesVector instance
- getList()[source]
Generates a 1x4 list with the four Stokes components.
- Returns:
list containing the Stokes parameters.
- Return type:
list
- property s0
Gets s0 (first stokes parameter).
- Return type:
float or numpy array
- property s1
Gets s1 (second stokes parameter).
- Return type:
float or numpy array
- property s2
Gets s2 (first stokes parameter).
- Return type:
float or numpy array
- property s3
Gets s3 (first stokes parameter).
- Return type:
float or numpy array
- setFromArray(array)[source]
Set stokes components from a given array
- Parameters:
array (list or numpy array) –
crystalpy.util.Vector module
Represents a 3d vector. Accept arrays of vectors.
vector.components() gives a numpy array with shape (3) or (3, npoints)
- class crystalpy.util.Vector.Vector(x, y, z)[source]
Bases:
objectVector Constructor.
- Parameters:
x (float) – x component. It can be an array.
y (float) – y component. It can be an array of the same size of x.
z (float) – z component. It can be an array of the same size of x.
- addVector(summand)[source]
Adds two vectors.
- Parameters:
summand (Vector instance) – The vector to be added.
- Returns:
The sum as a new vector.
- Return type:
Vector instance
- angle(factor)[source]
Return the angle between this vector and the given vector.
- Parameters:
factor (Vector instance) – Vector to determine the angle with.
- Returns:
Angle between this vector and the given vector.
- Return type:
float or numpy array
- components()[source]
Returns the components of this vector a 1d three element array.
- Returns:
The Vector components (referenced, not copied).
- Return type:
numpy array
- componentsStack()[source]
Returns the components stack of shape (3, npoints) of this vector.
- Returns:
The Vector components (referenced, not copied).
- Return type:
numpy array
- crossProduct(factor)[source]
Calculates the cross product of two vectors.
- Parameters:
factor – The vector to form the cross product with.
- Returns:
Cross product of the two vectors as a new vector.
- Return type:
Vector instance
- duplicate()[source]
Duplicates a vector.
- Returns:
result – New Vector instance with identical x,y,z components.
- Return type:
Vector instance
- extractStackItem(i)[source]
- Parameters:
i (int) – Index of vector to be extracted
- Returns:
A new vector instance with components of the i-th element only.
- Return type:
Vector instance
- getNormalizedVector()[source]
Returns a normalized vector of this vector. :return: Normalized vector of this vector.
- Returns:
The Normalized vector as a new vector.
- Return type:
Vector instance
- getOnePerpendicularVector()[source]
Returns one arbitrary vector perpendicular to this vector.
- Returns:
One arbitrary vector perpendicular to this vector.
- Return type:
Vector instance
- getVectorH(surface_normal, d_spacingSI, asymmetry_angle=0.0, azimuthal_angle=0.0, vector_parallel_surface=None)[source]
Returns the vector H. It is obtained from * copy the surface_normal * set its module to 2 pi / d_spacingSI * calculate an axis perpendicular to vector_parallel_surface and surface_normal * rotate it an angle -asymmetry_angle around this axis * rotate it an angle azimuthal_angle around this the surface_normal
- Parameters:
surface_normal (instance of Vector) – the (normalized) upwards normal to the surface.
d_spacingSI (float or numpy array) – the d-spacing in m.
asymmetry_angle (float or numpy array) – the asymmetry angle in rad (from the crystal surface to crystal planes, positive if clockwise)
azimuthal_angle (float or numpy array) – the azimuthal angle in rad. It is the angle between the YZ plane and the diffraction plane.
vector_parallel_surface (instance of Vector, optional) – the vector parallel to the surface. If None it uses Vector(0,1,0)
- Return type:
instance of Vector
- getVectorWithAngle(angle)[source]
Returns one arbitrary vector with the vector rotated with a given angle.
- Parameters:
angle (float) – The requested angle in radiants.
- Returns:
Vector with given angle to this vector.
- Return type:
Vector instance
- getX()[source]
Returns the x component.
- Returns:
The x component(s) (referenced, not copied).
- Return type:
float, numpy array
- getY()[source]
Returns the y component (referenced, not copied).
- Returns:
The y component(s).
- Return type:
float, numpy array
- getZ()[source]
Returns the z component (referenced, not copied).
- Returns:
The z component(s).
- Return type:
float, numpy array
- static initializeFromComponents(components)[source]
Creates a vector from a list/array of at least three elements.
- Parameters:
components (list, numpy array) – A list with the [x,y,z] components of the vector.
- isArray()[source]
Inform if the Vector instance contains a stack of vectors.
- Returns:
True if Vector contsins a stack of vector, False if there is a single vector.
- Return type:
bool
- nStack()[source]
Returns the number of stacked vectors
- Returns:
Number of stacked vectors
- Return type:
int
- norm()[source]
Returns the standard norm of this norm. :return: Norm of this vector,
- Returns:
The vector norm.
- Return type:
float, numpy array
- parallelTo(vector)[source]
Returns the (parallel) projection of this vector along the given vector.
- Parameters:
vector (Vector instance) – Vector defining the projection direction. It does not need to be normalized.
- Returns:
Parallel projection along the vector.
- Return type:
Vector instance
- perpendicularTo(vector)[source]
Returns the projection perpendicular to the given vector.
- Parameters:
vector (Vector instance) – Vector that defines the direction. It does not need to be normalized.
- Returns:
Projection perpendicular to the given vector.
- Return type:
Vector instance
- rotateAroundAxis(rotation_axis, angle)[source]
Rotates the vector around an axis. It uses the Rodrigues formula [rf]
- Parameters:
rotation_axis (Vector instance) – Vector specifying the rotation axis (not necessarily unit vector).
angle (float) – Rotation angle in radiants.
- Returns:
Rotated vector as a new vector.
- Return type:
Vector instance
References
- scalarMultiplication(k)[source]
Scalar multiplication of a vectors.
- Parameters:
k – The scalar to multiply with.
- Returns:
The scalar multiplied vector as a new vector.
- Return type:
Vector instance
- scalarProduct(factor)[source]
Calculates the scalar product of this vector with the given vector.
- Parameters:
factor – The vector to calculate the scalar product with.
- Returns:
Scalar product of the two vectors as a new vector.
- Return type:
Vector instance
- scatteringOnSurface(NORMAL, H, use_sign_of=1)[source]
- Returns K_OUT vector following the scattering equation at a surface:
K_OUT_parallel = K_IN_parallel + H_parallel |K_OUT| = |K_IN|
- Parameters:
- Returns:
Vector with K_OUT.
- Return type:
Vector instance
- setComponents(x, y, z)[source]
Sets vector components.
- Parameters:
x – x component.
y – y component.
z – z component.
crystalpy.util.bragg_preprocessor_file_io module
Utilities to read and write Bragg preprocessor files and dictionaries.
Copied from xoppylib (https://github.com/oasys-kit/xoppylib) so that crystalpy does not depend on xoppylib.
- crystalpy.util.bragg_preprocessor_file_io.bragg_preprocessor_file_v1_read(filename)[source]
Reads data from Bragg-preprocessor file V1 to dictionary.
- Parameters:
filename (str) – Filename with input.
- Return type:
dict
- crystalpy.util.bragg_preprocessor_file_io.bragg_preprocessor_file_v1_write(out_dict, fileout='')[source]
Writes data from dictionary to Bragg-preprocessor file V1.
- Parameters:
out_dict (dict) – Input dictionary to write to file
fileout (str) – Filename for output.
crystalpy.util.calc_xcrystal module
Utility functions for crystal diffraction calculations (xcrystal tools).
- crystalpy.util.calc_xcrystal.apply_convolution_on_bunch_out_dict(bunch_out_dict, sigma=0.1)[source]
- crystalpy.util.calc_xcrystal.calc_xcrystal_alphazachariasen_scan(crystal_name='Si', miller_h=1, miller_k=1, miller_l=1, thickness=0.01, asymmetry_angle=0.0, geometry_type_index=0, material_constants_library_flag=0, energy=8000.0, angle_deviation_min=-2, angle_deviation_max=2, angle_deviation_points=200, calculation_method=0, is_thick=0, use_transfer_matrix=0, do_plot=0, calculation_strategy_flag=0, dabax=None)[source]
- crystalpy.util.calc_xcrystal.calc_xcrystal_angular_scan(crystal_name='Si', miller_h=1, miller_k=1, miller_l=1, thickness=0.01, asymmetry_angle=0.0, geometry_type_index=0, material_constants_library_flag=0, energy=8000.0, angle_deviation_min=-0.0001, angle_deviation_max=0.0001, angle_deviation_points=200, angle_center_flag=2, flag_calculate_stokes=0, chi_deg=0.0, jones_in=[1, 1], calculation_method=0, is_thick=0, use_transfer_matrix=0, do_plot=0, calculation_strategy_flag=0, dabax=None)[source]
- crystalpy.util.calc_xcrystal.calc_xcrystal_double_scan(material_constants_library_flag=0, crystal_name='Si', thickness=0.01, miller_h=1, miller_k=1, miller_l=1, asymmetry_angle=0.0, energy_min=7990, energy_max=8010, energy_points=200, angle_deviation_min=-0.0001, angle_deviation_max=0.0001, angle_deviation_points=200, angle_center_flag=2, calculation_method=0, is_thick=0, use_transfer_matrix=0, geometry_type_index=0, do_plot=0, calculation_strategy_flag=0, dabax=None)[source]
- crystalpy.util.calc_xcrystal.calc_xcrystal_energy_scan(crystal_name='Si', miller_h=1, miller_k=1, miller_l=1, thickness=0.01, asymmetry_angle=0.0, geometry_type_index=0, material_constants_library_flag=0, theta=None, energy_min=7990, energy_max=8010, energy_points=200, calculation_method=0, is_thick=0, use_transfer_matrix=0, do_plot=0, calculation_strategy_flag=0, dabax=None)[source]