Module: calc
#
Calculation support for diffractometers
|
The default decision function - returns the first solution. |
|
Position is unreachable. |
|
Reciprocal space calculations |
Specific Geometries
|
Geometry: APS POLAR |
|
Geometry: E4CH |
|
Geometry: E4CV |
|
Geometry: E6C |
|
Geometry: K4CV |
|
Geometry: K6C |
|
Geometry: PETRA3 P09 EH2 |
|
Geometry: PETRA3 P23 4C |
|
Geometry: PETRA3 P23 6C |
|
Geometry: SOLEIL MARS |
|
Geometry: SOLEIL NANOSCOPIUM ROBOT |
|
Geometry: SOLEIL SIRIUS KAPPA |
|
Geometry: SOLEIL SIRIUS TURRET |
|
Geometry: SOLEIL SIXS MED1+2 |
|
Geometry: SOLEIL SIXS MED2+2 |
|
Geometry: SOLEIL SIXS MED2+3 |
|
Geometry: SOLEIL SIXS MED2+3 v2 |
|
Geometry: ZAXIS |
- class hkl.calc.CalcRecip(dtype, engine='hkl', sample='main', lattice=None, degrees=True, units='user', lock_engine=False, inverted_axes=None)[source]#
Reciprocal space calculations
add_sample
(sample[, select])Add an HklSample
calc_linear_path
(start, end, n[, num_params])Construct a trajectory from start to end with n steps (n+1 points).
The energy associated with the geometry, in keV
If set, do not allow the engine to be changed post-initialization
forward
(position[, engine])Calculate real positions from pseudo positions.
forward_iter
(start, end, max_iters, *[, ...])Iteratively attempt to go from a pseudo start -> end position
Name of this geometry, as defined in libhkl.
geometry_table
([rst])Describe this geometry in a table.
get_path
(start[, end, n, path_type])inverse
(real)Calculate pseudo positions from real positions.
The physical axis names to invert
new_sample
(name[, select])Convenience function to add a sample by name
Physical (real) motor positions as an OrderedDict
Physical (real) motor positions
Dynamically-generated physical motor position class
Ordered dictionary of axis name to position
Pseudo axis names from the current engine
Pseudo axis positions/values from the current engine
Currently selected sample.
The name of the currently selected sample.
The units used for calculations
update
()Calculate the pseudo axis positions from the real axis positions
The wavelength associated with the geometry, in angstrom
- Parameters:
dtype (str) – Diffractometer type (usually specified by a subclass)
engine (str, optional) – ‘hkl’, for example
sample (str, optional) – Default sample name (default: ‘main’)
lattice (Lattice, optional) – Lattice to use with the default sample
degrees (bool, optional) – Use degrees instead of radians (default: True)
units ({'user', }) – The type of units to use internally
lock_engine (bool, optional) – Don’t allow the engine to be changed during the life of this object
inverted_axes (list, optional) – Names of axes to invert the sign
- property Position#
Dynamically-generated physical motor position class
- property _cfg_reciprocal#
Return reciprocal lattice to save as configuration.
- _get_axis_by_name(name)[source]#
Given an axis name, return the HklParameter
- Parameters:
name (str) – If a name map is specified, this is the mapped name.
- _invert_physical_positions(pos)[source]#
Invert the physical axis positions based on the settings
- Parameters:
pos (OrderedDict) – NOTE: Modified in-place
- add_sample(sample, select=True)[source]#
Add an HklSample
- Parameters:
sample (HklSample instance) – The sample name, or optionally an already-created HklSample instance
select (bool, optional) – Select the sample to focus calculations on
- property axes_c#
User-defined real-space axes held constant during forward() calculation.
- property axes_r#
User-defined real-space axes used for forward() calculation.
- property axes_w#
User-defined real-space axes written by forward() calculation.
- calc_linear_path(start, end, n, num_params=0, **kwargs)[source]#
Construct a trajectory from start to end with n steps (n+1 points).
Example (for
hkl
engine):>>> e4cv.calc.calc_linear_path((1,1,0), (1,-1,0), 4, num_params=3) [(1.0, 1.0, 0.0), (1.0, 0.5, 0.0), (1.0, 0.0, 0.0), (1.0, -0.5, 0.0), (1.0, -1.0, 0.0)]
- property energy#
The energy associated with the geometry, in keV
- property engine#
- property engine_locked#
If set, do not allow the engine to be changed post-initialization
- property engines#
- forward_iter(start, end, max_iters, *, threshold=0.99, decision_fcn=None)[source]#
Iteratively attempt to go from a pseudo start -> end position
For every solution failure, the position is moved back. For every success, the position is moved closer to the destination.
After up to max_iters, the position can be reached, the solutions will be returned. Otherwise, ValueError will be raised stating the last position that was reachable and the corresponding motor positions.
- Parameters:
start (Position)
end (Position)
max_iters (int) – Maximum number of iterations
threshold (float, optional) – Normalized proximity to end position to stop iterating
decision_fcn (callable, optional) –
Function to choose a solution from several. Defaults to picking the first solution. Here is the default
decision_fcn()
:def decision(pseudo_position, solution_list): return solution_list[0]
- Returns:
solutions
- Return type:
- Raises:
UnreachableError (ValueError) – Position cannot be reached The last valid HKL position and motor positions are accessible in this exception instance.
- property geometry_name#
Name of this geometry, as defined in libhkl.
- geometry_table(rst=False)[source]#
Describe this geometry in a table.
- Parameters:
rst (bool) – When True, format using restructured text. Otherwise, use a simpler representation
- property inverted_axes#
The physical axis names to invert
- new_sample(name, select=True, **kwargs)[source]#
Convenience function to add a sample by name
Keyword arguments are passed to the new HklSample initializer.
- property parameters#
- property physical_axes#
Physical (real) motor positions as an OrderedDict
- property physical_axis_names#
- property physical_positions#
Physical (real) motor positions
- property pseudo_axes#
Ordered dictionary of axis name to position
- property pseudo_axis_names#
Pseudo axis names from the current engine
- property pseudo_positions#
Pseudo axis positions/values from the current engine
- property sample#
Currently selected sample.
- property sample_name#
The name of the currently selected sample.
- property units#
The units used for calculations
- property wavelength#
The wavelength associated with the geometry, in angstrom