Module: util
#
Utility functions and structures.
|
Limitations on acceptable positions from computed forward() solutions. |
|
Built-in immutable sequence. |
|
Return dict of information about installed package, by name. |
|
Return a namedtuple with the positions. |
alias of |
|
|
List the runs with orientation information. |
|
Create a new HKL-library detector |
|
Simplify for high-symmetry crystal systems. |
|
Restore any constraints from orientation information. |
|
Restore energy from orientation information. |
|
Restore all orientation information. |
|
Restore any reflections from orientation information. |
|
Restore sample & lattice from orientation information. |
|
Restore UB matrix from orientation information. |
|
Return a dictionary with orientation information in this run. |
|
Report the package versions, in a dictionary. |
Also provides SI_LATTICE_PARAMETER as defined by the 2018 CODATA recommended lattice parameter of silicon. [1]
- class hkl.util.Constraint(low_limit, high_limit, value, fit=True)[source]#
Limitations on acceptable positions from computed forward() solutions.
- Parameters:
low_limit (float) – Lowest acceptable value for this axis when computing real-space solutions from given reciprocal-space positions.
high_limit (float) – Highest acceptable value for this axis when computing real-space solutions from given reciprocal-space positions.
value (float) –
Constant value used (on condition) for
forward(hkl)
calculation.Implemented by diffractometer
mode
.The diffractometer engine’s
mode
(such as E4CV’sconstant_phi
mode) controls whether or not the axis is to be held constant.fit (bool) –
(deprecated) Not used as a constraint.
The value of
fit
is ignored. It remains now for compatibility with previous hklpy releases. It will be dropped in a future hklpy release.While this parameter is used by libhkl to adjust lattice parameters when refining the UB matrix from more than 2 reflections, it is not used in the calculation of rotation angles from reciprocal-space coordinates.
- hkl.util.Lattice#
alias of
LatticeTuple
- hkl.util.get_package_info(package_name)[source]#
Return dict of information about installed package, by name.
- hkl.util.get_position_tuple(axis_names, class_name='Position')[source]#
Return a namedtuple with the positions.
- hkl.util.list_orientation_runs(catalog, *args, limit=20)[source]#
List the runs with orientation information.
- Returns:
orientation information
- Return type:
Pandas DataFrame object
- Parameters:
*args ([str]) –
A list of additional data column names to be displayed, corresponding to the names of available orientation information in the descriptor document.
Example:
list_orientation_runs( "class_name", energy", "energy_units", "lattice")
catalog (object) – Instance of a databroker catalog.
limit (int) – Limit the list to the first
limit
rows. (default=20)
- hkl.util.new_lattice(a, b=None, c=None, alpha=90.0, beta=None, gamma=None)[source]#
Simplify for high-symmetry crystal systems.
EXAMPLES (highest to lowest symmetry):
system
command
a
b
c
alpha
beta
gamma
cubic
new_lattice(5.)
5
5
5
90
90
90
hexagonal
new_lattice(4., c=3., gamma=120)
4
4
3
90
90
120
rhombohedral
new_lattice(4., alpha=80.0)
4
4
4
80
80
80
tetragonal
new_lattice(4, c=3)
4
4
3
90
90
90
orthorhombic
new_lattice(4, 5, 3)
4
5
3
90
90
90
monoclinic
new_lattice(4, 5, 3, beta=75)
4
5
3
90
75
90
triclinic
new_lattice(4, 5, 3, 75., 85., 95.)
4
5
3
75
85
95
- hkl.util.restore_UB(orientation, diffractometer)[source]#
Restore UB matrix from orientation information.
- Parameters:
orientation (dict) – Dictionary of orientation parameters (from
run_orientation_info()
) recovered from run.diffractometer (
Diffractometer()
) – Diffractometer object.
- hkl.util.restore_constraints(orientation, diffractometer)[source]#
Restore any constraints from orientation information.
- Parameters:
orientation (dict) – Dictionary of orientation parameters (from
run_orientation_info()
) recovered from run.diffractometer (
Diffractometer()
) – Diffractometer object.
- hkl.util.restore_energy(orientation, diffractometer)[source]#
Restore energy from orientation information.
NOTE: This makes blocking calls so do not use in bluesky plan.
- Parameters:
orientation (dict) – Dictionary of orientation parameters (from
run_orientation_info()
) recovered from run.diffractometer (
Diffractometer()
) – Diffractometer object.
- hkl.util.restore_orientation(orientation, diffractometer)[source]#
Restore all orientation information.
- Parameters:
orientation (dict) – Dictionary of orientation parameters (from
run_orientation_info()
) recovered from run.diffractometer (
Diffractometer()
) – Diffractometer object.
- hkl.util.restore_reflections(orientation, diffractometer)[source]#
Restore any reflections from orientation information.
- Parameters:
orientation (dict) – Dictionary of orientation parameters (from
run_orientation_info()
) recovered from run.diffractometer (
Diffractometer()
) – Diffractometer object.
- hkl.util.restore_sample(orientation, diffractometer)[source]#
Restore sample & lattice from orientation information.
- Parameters:
orientation (dict) – Dictionary of orientation parameters (from
run_orientation_info()
) recovered from run.diffractometer (
Diffractometer()
) – Diffractometer object.
- hkl.util.run_orientation_info(run)[source]#
Return a dictionary with orientation information in this run.
Dictionary is keyed by “detector” name (in case more than one diffractometer was added as a “detector” to the run).
The orientation information is found in the descriptor document of the primary stream.
- Parameters:
run (from Databroker) – A Bluesky run, from databroker v2, such as
cat.v2[-1]
.
- hkl.util.software_versions(keys=[])[source]#
Report the package versions, in a dictionary.
EXAMPLE:
In [1]: import gi ...: ...: gi.require_version("Hkl", "5.0") ...: ...: import hkl.util In [2]: hkl.util.software_versions() Out[2]: {'hkl': '5.0.0.2173', 'hklpy': '0.3.16+131.ga5a449a.dirty', 'pygobject': '3.40.1'}
Here, it shows (albeit indirectly) Hkl 5.0.0 tag 2173. Proceed to the Hkl source repository, list of tags [2], and find tag
2173
[3].[2] Hkl source tags: https://repo.or.cz/hkl.git/refs
[3] Hkl tag 2173: https://repo.or.cz/hkl.git/tree/refs/tags/v5.0.0.2173)