nexus_transformations¶
NXtransformations code taken from https://github.com/DanPorter/i16_diffractometer
NxTransformation
¶
Class containing single NXTransformation axis
Source code in mmg_toolbox/nexus/nexus_transformations.py
NxTransformationChain
¶
Class containing chain of transformation operations
Source code in mmg_toolbox/nexus/nexus_transformations.py
RotationAxis
¶
Bases: TransformationAxis
Holder for data to define a rotation NXtransformation dataset with units Degrees
Source code in mmg_toolbox/nexus/nexus_transformations.py
TransformationAxis
¶
Holder for data to define an NXtransformation dataset
Source code in mmg_toolbox/nexus/nexus_transformations.py
TranslationAxis
¶
Bases: TransformationAxis
Holder for data to define a translation NXtransformation dataset with units mm
Source code in mmg_toolbox/nexus/nexus_transformations.py
generate_nxtranformations_string(filename)
¶
return a string describing all the transformation chains in the NeXus file
Source code in mmg_toolbox/nexus/nexus_transformations.py
get_depends_on(root)
¶
Return depends_on value from group or dataset
Source code in mmg_toolbox/nexus/nexus_transformations.py
load_transformation(path, index, hdf_file, parent='')
¶
Read Transformation Operation from HDF file
Source code in mmg_toolbox/nexus/nexus_transformations.py
nx_depends_on_chain(path, hdf_file)
¶
Returns list of paths in a transformation chain, linked by 'depends_on'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
hdf path of initial dataset or group |
required |
hdf_file
|
Group
|
Nexus file object |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
|
Source code in mmg_toolbox/nexus/nexus_transformations.py
nx_direction(path, hdf_file)
¶
Return a unit-vector direction from a dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
hdf path of NXtransformation path or component group with 'depends_on' |
required |
hdf_file
|
Group
|
Nexus file object |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
unit-vector array |
Source code in mmg_toolbox/nexus/nexus_transformations.py
nx_transform_vector(xyz, path, index, hdf_file)
¶
Transform a vector or position [x, y, z] by an NXtransformations chain
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xyz
|
3D coordinates, n*3 [[x, y, z], ...] |
required | |
path
|
str
|
hdf path of first object in NXtransformations chain |
required |
index
|
int
|
int index of point in scan |
required |
hdf_file
|
Group
|
Nexus file object |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
n*3 array([[x, y, z], ...]) transformed by operations |
Source code in mmg_toolbox/nexus/nexus_transformations.py
nx_transformations(path, index, hdf_file, print_output=False)
¶
Create list of 4x4 transformation matrices matching transformations along an NXtransformations chain
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
str hdf path of the first point in the chain (Group or Dataset) |
required |
index
|
int
|
int index of point in scan |
required |
hdf_file
|
Group
|
Nexus file object |
required |
print_output
|
bool, if true the operations will be printed |
False
|
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
list of 4x4 arrays [T1, T2, T3, ... Tn] |
Source code in mmg_toolbox/nexus/nexus_transformations.py
nx_transformations_matrix(path, index, hdf_file)
¶
Combine chain of transformation operations into single matrix
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
str hdf path of the first point in the chain (Group or Dataset) |
required |
index
|
int
|
int index of point in scan |
required |
hdf_file
|
Group
|
Nexus file object |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
4x4 array |
Source code in mmg_toolbox/nexus/nexus_transformations.py
nx_transformations_max_size(path, hdf_file)
¶
Return the maximum dataset size from a chain of transformations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
hdf dataset path of NX transformation, or group containing 'depends_on' |
required |
hdf_file
|
Group
|
Nexus file object |
required |
Returns:
| Type | Description |
|---|---|
int
|
int : largest dataset.size |