Sample#

class cbclib.Sample(rotation, z)[source]#

A convergent beam sample implementation. Stores position and orientation of the sample.

Parameters
  • rotation (Rotation) – rotation matrix, that defines the orientation of the sample.

  • position – Sample’s position [m].

detector_to_kout(x, y, setup, rec_vec=None, num_threads=1)[source]#

Project detector coordinates (x, y) to the output wave-vectors space originating from the sample’s position.

Parameters
  • x (ndarray) – A set of x coordinates.

  • y (ndarray) – A set of y coordinates.

  • setup (ScanSetup) – Experimental setup.

  • rec_vec (Optional[ndarray]) – A set of scattering vectors corresponding to the detector points.

  • num_threads (int) – Number of threads used in the calculations.

Return type

ndarray

Returns

An array of output wave-vectors.

classmethod import_dataframe(data)[source]#

Initialize a new Sample object with a pandas.Series array. The array must contain the following columns:

  • Rxx, Rxy, Rxz, Ryx, Ryy, Ryz, Rzx, Rzy, Rzz : Rotational matrix.

  • z : z coordinate [m].

Parameters

data (Series) – A pandas.Series array.

Return type

Sample

Returns

A new Sample object.

kin_to_sample(setup, kin=None, num_threads=1)[source]#

Project incident wave-vectors kin to the sample plane.

Parameters
  • setup (ScanSetup) – Experimental setup.

  • kin (Optional[ndarray]) – Incident wave-vectors.

  • num_threads (int) – Number of threads used in the calculations.

Return type

ndarray

Returns

An array of points belonging to the sample plane.

kout_to_detector(kout, setup, rec_vec=None, num_threads=1)[source]#

Project output wave-vectors originating from the sample’s position to the detector plane.

Parameters
  • kout (ndarray) – Output wave-vectors.

  • setup (ScanSetup) – Experimental setup.

  • rec_vec (Optional[ndarray]) – A set of scattering vectors corresponding to the output wave-vectors.

  • num_threads (int) – Number of threads used in the calculations.

Return type

Tuple[ndarray, ndarray]

Returns

A tuple of x and y detector coordinates.

replace(**kwargs)[source]#

Return a new Sample object with a set of attributes replaced.

Parameters

kwargs (Any) – A set of attributes and the values to to replace.

Return type

Sample

Returns

A new Sample object with the updated attributes.

rotate_basis(basis)[source]#

Rotate a cbclib.Basis by the rotation attribute.

Parameters

basis (Basis) – Indexing solution basis vectors.

Return type

Basis

Returns

A new rotated cbclib.Basis object.

to_dataframe()[source]#

Export the sample object to a pandas.Series array.

Returns

  • Rxx, Rxy, Rxz, Ryx, Ryy, Ryz, Rzx, Rzy, Rzz : Rotational matrix.

  • z : z coordinate [m].

Return type

A pandas.Series array with the following columns

to_dict()[source]#

Export the Sample object to a dict.

Return type

Dict[str, Any]

Returns

A dictionary of Sample object’s attributes.