CBCTable#
- class cbclib.CBCTable(table, setup, crop=None)[source]#
Convergent beam crystallography tabular data. The data is stored in
pandas.DataFrametable. A table must contain the following columns:frames : Frame index.
index : Diffraction streak index.
x, y : x and y pixel coordinate.
p : Normalised pattern value. The value lies in (0.0 - 1.0) interval.
rp : Reflection profiles.
I_raw : Raw photon count.
bgd : Background intensity.
h, k, l : Miller indices.
sfac : Crystal structure factors.
xtal : Crystal diffraction efficiencies.
- Parameters
- drop_duplicates(method='keep_best')[source]#
Discard the pixel data, that has duplicate x, y coordinates.
- Parameters
method (
str) –Choose the policy of dealing with the pixel data that has duplicate x and y coordinates:
keep_all : Keep duplicated data.
keep_best : Keep the pixels that have higher likelihood value p.
ignore : Discard duplicated data.
- Return type
- Returns
New CBC table with the duplicate data discarded.
- fourier_index(samples, qx_arr, qy_arr, qz_arr, num_threads=1)[source]#
Map the measured normalised intensities to the reciprocal space. Returns a
cbclib.Map3D3D data container capable of performing the auto Fourier indexing.- Parameters
samples (
ScanSamples) – Set of scan samples.qx_arr (
ndarray) – Array of reciprocal x coordinates.qy_arr (
ndarray) – Array of reciprocal y coordinates.qz_arr (
ndarray) – Array of reciprocal z coordinates.num_threads (
int) – Number of threads used in the calculations.
- Return type
- Returns
3D data container of measured normalised intensities.
- generate_kins(basis, samples, num_threads=1)[source]#
Convert diffraction pattern locations to incoming wavevectors. The incoming wavevectors are normalised and specify the spatial frequencies of the incoming beam that bring about the diffraction signal measured on the detector.
- Parameters
basis (
Basis) – Basis vectors of crystal lattice unit cell.samples (
ScanSamples) – Set of scan samples.num_threads (
int) – Number of threads used in the calculations.
- Raises
AttributeError – If Miller indices (‘h’, ‘k’, ‘l’) are not present in the CBC table.
- Return type
- Returns
A set of incoming wavevectors.
- get_crop()[source]#
Return the region of interest on the detector plane.
- Return type
- Returns
A new crop object with the ROI, inferred from the CBC table.
- classmethod import_csv(path, setup)[source]#
Initialize a CBC table with a CSV file
pathand an experimental geometry objectsetup.
- classmethod import_hdf(path, key, setup)[source]#
Initialize a CBC table with data saved in a HDF5 file
pathat akeykey inside the file and an experimental geometry objectsetup.
- pattern_dataframe(frame)[source]#
Return a single pattern table. The x, y coordinates are transformed by the
cropattribute.- Parameters
frame (
int) – Frame index.- Return type
- Returns
A
pandas.DataFrametable.
- pattern_dict(frame)[source]#
Return a single pattern table in
dictformat. The x, y coordinates are transformed by thecropattribute.
- pattern_image(frame, key='rp')[source]#
Return a CBC pattern image array of the given attribute key. The x, y coordinates are transformed by the
cropattribute.
- refine_samples(bounds, basis, hkl, samples, width, alpha=0.0)[source]#
Return a
SampleRefinerobject designed to perform the sample refinement. The sample refinement yields a set of sample parameters, that attain the best fit between simulated and experimentally measured patterns. The refinement is performed for each pattern separately.- Parameters
bounds (
ndarray) – Bounds for sample refinement variables. A set of(min, max)pairs of the shape(N, 2), whereNis the number of variables. Each of the terms is diregarded in the refinement process, if the corresponding bounds are equal to 0.basis (
Basis) – Basis vectors of crystal lattice unit cell.hkl (
ndarray) – Array of Miller indices used in the refinement.samples (
ScanSamples) – Sample object. The object is given by the rotation matrix and a sample position.width (
float) – Diffraction streak width in pixels. The value is used to generate a predicted CBC pattern.alpha (
float) – Regularisation term in the loss function.
- Return type
- Returns
A CBC sample refinement object.
See also
cbclib.SampleRefiner : CBC sample refiner class.
- refine_setup(bounds, basis, hkl, tilts, width, alpha=0.0)[source]#
Return a
SetupRefinerobject designed to perform the setup refinement. Setup refinement yields a scattering geometry parameters, that attain the best fit between simulated and experimentally measured patterns. The refinement is performed for the whole scan in one go.- Parameters
bounds (
ndarray) – Bounds for setup refinement variables. A set of(min, max)pairs of the shape(N, 2), whereNis the number of variables. Each of the terms is diregarded in the refinement process, if the corresponding bounds are equal to 0.basis (
Basis) – Basis vectors of crystal lattice unit cell.sample – Sample object. The object is given by the rotation matrix and a sample position.
q_abs – Size of the recpirocal space. Reciprocal vectors are normalised, and span in [0.0 - 1.0] interval.
width (
float) – Diffraction streak width in pixels. The value is used to generate a predicted CBC pattern.alpha (
float) – Regularisation term in the loss function.
- Return type
- Returns
A CBC setup refinement object.
See also
cbclib.SetupRefiner : CBC setup refinement class.
- scale(xtal_shape, basis, samples, num_threads=1)[source]#
Return a
IntensityScalerCBC dataset intensity scaler. The scaler generates a crystal diffraction efficiency map and structure factors based on diffraction signal. The intensity scaling algorithm uses the crystal basis and sample objects to project the diffraction signal onto the crystal plane.- Parameters
- Raises
AttributeError – If Miller indices (‘h’, ‘k’, ‘l’) are not present in the CBC table.
- Return type
- Returns
A CBC dataset intensity scaler.