InteractCrystal

New Members

class InteractCrystal(config=None, strict=None, initialize=None)[source]

Bases: InteractMirror

Model for simple Bragg reflections.

Configuration Options:

crystal_spacingfloat [angstroms]

The spacing between crystal planes. .. Note:

This is the nominal 'd' crystal spacing, not the '2d' spacing
often used in the literature.
reflectivityfloat (1.0)

A reflectivity factor for this optic. The reflectivity will modify the probability that a ray will reflect from this optic.

check_braggbool (True)

Switch between x-ray Bragg reflections and optical reflections for this optic. If True, a rocking curve will be used to determine the probability of reflection for rays based on their incident angle. If false this optic will act as a perfect mirror.

rocking_typestr (‘gaussian’)

The type of shape to use for the crystal rocking curve. Allowed types are ‘step’, ‘gaussian’ and ‘file’.

rocking_fwhmfloat [rad]

The width of the rocking curve, in radians. This option only used when rocking_type is ‘step’ or ‘gaussian’.

rocking_filestr or list

A filename from which to read rocking curve data. A list may be used if sigma and pi data are in separate files.

rocking_filetypestr

The type of rocking curve file to be loaded. The following formats are currently supported: ‘xop’, ‘x0h’, ‘simple’. .. Note:

Actually at this point only 'xop' is supported. np 2020-10-13
rocking_mixfloat

A mixing factor to combine the sigma and pi reflectivities. This value will be interpreted as sigma/pi and will mix the reflection probabilities linearly. ref = sigma*mix + pi*(1-mix)

xsize

The size of this element along the xaxis direction. Typically corresponds to the ‘width’ of the optic.

ysize

The size of this element along the yaxis direction. Typically corresponds to the ‘height’ of the optic.

zsize

The size of this element along the zaxis direction. Typically not required, but if needed will correspond to the ‘depth’ of the optic.

pixel_sizefloat (None)

The pixel size, used for binning rays into images. This is currently a single number signifying square pixels.

aperturedict or array (None)

Define one or more apertures to to apply to this optic. Each aperture is defined as a dictionary with the following keys: shape, size, origin, logic. The origin and logic field keys are optional. The interpretation of size will depend on the provided shape.

trace_localbool (False)

If true: transform rays to optic local coordinates before raytracing, do raytracing in local coordinates, then transform back to global coordinates. The default is ‘false’ as most built-in optics can perform raytracing in global coordinates. This option is convenient for optics with complex geometry for which intersection and reflection equations are easier or more clear to program in fixed local coordinates.

check_sizebool (true)

Perform a check for whether the rays intersect the optic within the defined bounds (usually defined by ‘xsize’ and ‘ysize’). If set to False all rays with a defined reflection/transmission condition will be traced if an intersection can be determined.

check_aperturebool (true)

Perform a check for whether the rays intersect the optic within the defined bounds (usually defined by ‘xsize’ an ‘ysize’). If set to False all rays with a defined reflection/transmission condition will be traced if an intersection can be determined.

filters

No documentation yet. Please help improve XICSRT!

origin

The x,y,x origin of this element in global coordinates.

zaxis

A unit-vector defining the z-axis of the element in global coordinates. For most optics: z-axis defines the surface normal direction.

xaxis(optional)

A unit-vector defining the x-axis of the element in global coordinates. For most optics: x-axis defines the ‘width’ direction. If xaxis is not provided it will be automatically generated by: cross(zaxis, [0,1,0]). The yaxis is always automatically generated and defined by: cross(zaxis, xaxis)

class_name

Automatically generated.

yo_mama

Is a wonderful person!

default_config()[source]
crystal_spacing: float [angstroms]

The spacing between crystal planes.

Note

This is the nominal ‘d’ crystal spacing, not the ‘2d’ spacing often used in the literature.

reflectivity: float (1.0)

A reflectivity factor for this optic. The reflectivity will modify the probability that a ray will reflect from this optic.

check_bragg: bool (True)

Switch between x-ray Bragg reflections and optical reflections for this optic. If True, a rocking curve will be used to determine the probability of reflection for rays based on their incident angle. If false this optic will act as a perfect mirror.

rocking_type: str (‘gaussian’)

The type of shape to use for the crystal rocking curve. Allowed types are ‘step’, ‘gaussian’ and ‘file’.

rocking_fwhm: float [rad]

The width of the rocking curve, in radians. This option only used when rocking_type is ‘step’ or ‘gaussian’.

rocking_file: str or list

A filename from which to read rocking curve data. A list may be used if sigma and pi data are in separate files.

rocking_filetype: str

The type of rocking curve file to be loaded. The following formats are currently supported: ‘xop’, ‘x0h’, ‘simple’.

Note

Actually at this point only ‘xop’ is supported. np 2020-10-13

rocking_mix: float

A mixing factor to combine the sigma and pi reflectivities. This value will be interpreted as sigma/pi and will mix the reflection probabilities linearly. ref = sigma*mix + pi*(1-mix)

initialize()[source]

Initialize the object.

interact(rays, xloc, norm, mask=None)[source]

Evaluate interaction with a surface. The base-class has no interaction, rays just pass through.

angle_calc(rays, norm, mask=None)[source]
angle_check(rays, norm, mask=None)[source]
rocking_curve_filter(incident_angle, bragg_angle)[source]

New Private Members

class InteractCrystal[source]

Inherited Members

class InteractCrystal[source]
__init__(config=None, strict=None, initialize=None)
aim_to_point(aim_point, xaxis=None)

Set the Z-Axis to aim at a particular point.

angle_calc(rays, norm, mask=None)[source]
angle_check(rays, norm, mask=None)[source]
check_aperture(X_local, mask)

Check if the ray intersection is within the aperture as set by the ‘aperture’ config option.

Note

This method expects to be given the ray intersections in local coordinates. Generally this method should not be called directly instead use check_bounds.

check_bounds(X, mask)
check_config()

Check the config before copying to the internal param. This is called during object instantiation (__init__) and therefore before setup is called.

check_param()

Check the internal parameters prior to initialization. This will be called after setup and before initialize.

check_size(X_local, mask)

Check if the ray intersection is within the optic bounds as set by the xsize, ysize and zsize config options.

Note

This method expects to be given the ray intersections in local coordinates. Generally this method should not be called directly, instead use check_bounds.

default_config()[source]
crystal_spacing: float [angstroms]

The spacing between crystal planes.

Note

This is the nominal ‘d’ crystal spacing, not the ‘2d’ spacing often used in the literature.

reflectivity: float (1.0)

A reflectivity factor for this optic. The reflectivity will modify the probability that a ray will reflect from this optic.

check_bragg: bool (True)

Switch between x-ray Bragg reflections and optical reflections for this optic. If True, a rocking curve will be used to determine the probability of reflection for rays based on their incident angle. If false this optic will act as a perfect mirror.

rocking_type: str (‘gaussian’)

The type of shape to use for the crystal rocking curve. Allowed types are ‘step’, ‘gaussian’ and ‘file’.

rocking_fwhm: float [rad]

The width of the rocking curve, in radians. This option only used when rocking_type is ‘step’ or ‘gaussian’.

rocking_file: str or list

A filename from which to read rocking curve data. A list may be used if sigma and pi data are in separate files.

rocking_filetype: str

The type of rocking curve file to be loaded. The following formats are currently supported: ‘xop’, ‘x0h’, ‘simple’.

Note

Actually at this point only ‘xop’ is supported. np 2020-10-13

rocking_mix: float

A mixing factor to combine the sigma and pi reflectivities. This value will be interpreted as sigma/pi and will mix the reflection probabilities linearly. ref = sigma*mix + pi*(1-mix)

get_config()
get_default_xaxis(zaxis)

Get the X-axis using a default definition.

In order to fully define the orientation of a component both, a z-axis and an x-axis are expected. For certain types of components the x-axis definition is unimportant and can be defined using a default definition.

initialize()[source]

Initialize the object.

interact(rays, xloc, norm, mask=None)[source]

Evaluate interaction with a surface. The base-class has no interaction, rays just pass through.

intersect(rays)
make_image(rays)

Collect the rays that intersect with this optic into a pixel array that can be used to generate an intersection image.

Programming Notes

It is important that this calculation is compatible with intersect_check in terms of floating point errors. The simple way to achieve this is to ensure that both use the same calculation method.

point_to_external(point_local)
point_to_local(point_external)
ray_to_external(ray_local, copy=False)
ray_to_local(ray_external, copy=False)
reflect_vectors(rays, xloc, normals, mask=None)
rocking_curve_filter(incident_angle, bragg_angle)[source]
set_orientation(zaxis, xaxis=None)
setup()

Perform any setup actions that are needed prior to initialization.

to_ndarray(vector_in)
to_vector_array(vector_in)

Convert a vector to a numpy vector array (if needed).

trace(rays)

The main method that performs raytracing for this optic.

Raytracing here may be done in global or local coordinates depending on the how the optic is designed and the value of the configuration option: ‘trace_local’.

trace_global(rays)

This is method that is called by the dispacher to perform ray-tracing for this optic. Rays into and out of this method are always in global coordinates.

It may be convenient for some optics object to do raytracing in local coordinates rather than in global coordinates. This method facilitates this by implementing the ‘trace_local’ configuration option.

update_config(config_new, **kwargs)

Overwrite any config values in this object with the ones given. This will be done recursively for all nested dictionaries.

vector_to_external(vector)
vector_to_local(vector)