API Documentation

pyddt.cif module

This module converts a Crystallographic Information File (CIF) into a structure file (.in).

pyddt.cif.to_in(fcif: str)[source]

Generates .in file from CIF.

Parameters

fcif (str) – CIF filename.

pyddt.cif.to_struc(fcif: str)[source]

Saves the .struc file.

Parameters

fcif (str) – CIF filename.

Notes

  • The .struc file presents some structural and electronic properties which might be useful for structural modelling.

  • Guesses of ionic charge (based on pymatgen.core.composition_oxi_state_guesses) are presented for inorganic crystals. If organic, the indices of the equivalent atoms are shown.

Attention

The number of asymmetric units probably isn’t correct for hydrated crystals.

pyddt.cif.visualizer_cif(fcif: str) NGLWidget[source]

Visualizes the CIF structure. This method is available exclusively in Jupyter Notebooks.

Parameters

fcif (str) – CIF filename.

Returns

Interactive visualization of the conventional unit cell.

Return type

nv.widget.NGLWidget

Attention

To avoid bugs, it’s highly recommended to assign this method to a variable, then close the figure after the visualization using variable_name.close().


pyddt.scatter module

This module provides the calculation of atomic scattering amplitudes (see Computer Simulation Tools for X-ray Analysis: Scattering and Diffraction Methods for reference).

pyddt.scatter.asfQ(atom: str, Q: list) ndarray[source]

Calculates the atomic scattering factor using the Cromer–Mann coefficients (highly inaccurate for Q > 30 1/angstrom).

Parameters
  • atom (str) – Atom or ion symbol.

  • Q (list or float or np.ndarray) – Reciprocal vector amplitude (1/angstrom) divided by 4pi.

Returns

Atomic scattering factor values.

Return type

np.ndarray or float

Usage:
  • asfQ('Na1+', np.linspace(0, 10, 1000))

  • asfQ('H', 3)

  • asfQ('Se', [0, 10, 20])

pyddt.scatter.aresE(atom: str, E: ndarray) ndarray[source]

Calculates the atomic resonance amplitude by using linear interpolation of tabulated values.

Parameters
  • atom (str) – Element symbol.

  • E (np.ndarray or float) – X-ray energy (from 1004.16 to 70000 eV).

Returns

Complex resonance amplitude.

Return type

np.ndarray or float

Usage:
  • aresE('Na', np.linspace(3000, 10000, 1000))

  • aresE('O', 8048)


pyddt.comparison module

This module performs the phase comparison between structural models.

pyddt.comparison.phase(data1: ndarray, data2: ndarray, min: float = 15)[source]

Comparison of the structure factor phase with respect to two structural models.

Parameters
  • data1 (np.ndarray) – List of structure factors for the 1st structure.

  • data2 (np.ndarray) – List of structure factors for the 2nd structure.

  • min (float) – Minimum phase difference (degrees). Default: 15.

Notes

  • The list of structure factors can be obtained by the Crystal.diffraction() method.

  • By default, the plotly.graph_objects will be displayed in an installed browser.

pyddt.comparison.triplet(data1: ndarray, data2: ndarray, G: list, wmin: float = 5)[source]

Comparison of the phase triplet with respect to two structural models for a given primary reflection.

Parameters
  • data1 (np.ndarray) – List of structure factors for the 1st structure.

  • data2 (np.ndarray) – List of structure factors for the 2nd structure.

  • G (list) – Indices of the primary reflection (eg [1, 0, 0]).

  • wmin (float) – Cutoff for the triplet amplitude (% ranging from 0 to 100). Default: 5.

Notes

  • The list of structure factors can be obtained by the Crystal.diffraction() method.

  • By default, the plotly.graph_objects will be displayed in an installed browser.

  • The method returns None for null or absent primary reflection.


pyddt.Crystal class

This class is used for performing crystallographic calculations.

class pyddt.Crystal(struc_obj: str)[source]

Given a structure, returns a new crystal object.

Parameters

struc_obj (str or Structure) – Filename or Structure object.

Notes

  • .in file columns: atom or ion symbols, fractional coordinates, occupancy numbers and B-factors. The first line must present the lattice parameters. Use the cif module to generate this file from CIF.

bragg(E: float, hkl: list) ndarray[source]

Determines the interplanar distance and Bragg angle from Miller indices and X-ray energy.

Parameters
  • E (float) – X-ray energy (eV).

  • hkl (list) – Miller indices (e.g [1, 0, 0]).

Returns

Interplanar distance and Bragg angle.

Return type

np.ndarray

hkl2Q(hkl: ndarray) ndarray[source]

Determines the reciprocal vector from Miller indices.

Parameters

hkl (np.ndarray) – Miller indices

Returns

Q values (1/angstrom).

Return type

np.ndarray

Usage:
  • hkl2Q([[1, 0, 0], [0, 1, 1]])

  • hkl2Q([1, 0, 0])

Fhkl(E: float, H: ndarray) ndarray[source]

Calculates the complex structure factor.

Parameters
  • E (float or np.ndarray) – X-ray energy (eV).

  • H (np.ndarray) – Miller indices.

Returns

List of structure factors (complex).

Return type

np.ndarray

Notes

This method accepts an array of energy for a fixed reflection or a fixed energy jointly a set of reflections.

Usage:
  • Fhkl(8048, [[1, 0, 0], [0, 1, 1]])

  • Fhkl([8048, 10004], [1, 0, 0])

hkl_generator(E: float) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Determines the Miller indices of all structure-allowed lattice planes.

Parameters

E (float) – X-ray energy (eV).

Returns

Miller indices, Bragg angles and interplanar distances.

Return type

tuple[np.ndarray, np.ndarray, np.ndarray]

diffraction(E: float, fout: str = '') tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Calculates the complex structure factor and interplanar distance of all structure-allowed lattice planes.

Parameters
  • E (float) – X-ray energy (eV).

  • fout (str) – Filename for output. Default: None - it doesn’t save.

Returns

Reflections, structure factors and interplanar distances.

Return type

tuple[np.ndarray, np.ndarray, np.ndarray]

triplet_relation(E: float, G_H: list) tuple[float, float][source]

Calculates the triplet phase.

Parameters
  • E (float) – X-ray energy (eV).

  • G_H (list) – Indices of primary and secondary reflection (in this order).

Returns

Triplet phase (deg) and interference amplitude W.

Return type

tuple[float, float]

klines(E: float, G: list, M: list, Fmin: float, dw: float = 0.1, npoints: int = 20)[source]

Calculates the Bragg Cones (BC lines) of all reflections.

Parameters
  • E (float) – X-ray energy (eV).

  • G (list or ndarray) – Primary reflection (eg [1, 0, 0]).

  • M (list or ndarray) – Reference direction (eg [1, 0, -1]).

  • Fmin (float) – Cutoff value for W (minimum).

  • dw (float) – Maximum distance between BC lines and primary reflection.

  • npoints (int) – Number of points of the 2D-cone representation.

Notes

The BC lines are saved in IN/OUT/THG_G_array_M_array_E_value.dat files:

  • IN_G_array_M_array_E_value.dat: BC lines entering the Ewald sphere.

  • OUT_G_array_M_array_E_value.dat: BC lines exiting the Ewald sphere.

  • THG_G_array_M_array_E_value.dat: MD positions (in-out and out-in geometries).

Usage:
  • klines(8048, [1, 1, 1], [1, 0, 0], 10)


pyddt.crystal_funcs module

Functions required by the Crystal class. In general, unuseful for external users.

pyddt.crystal_funcs.lattice(a: float, b: float, c: float, alpha: float, beta: float, gamma: float) tuple[source]

Calculates the direct and reciprocal lattice vectors.

Parameters
  • a (float) – 1st lattice parameter (amplitude - angstrom).

  • b (float) – 2nd lattice parameter (amplitude - angstrom).

  • c (float) – 3rd lattice parameter (amplitude - angstrom).

  • alpha (float) – 1st lattice angle (degrees).

  • beta (float) – 2nd lattice angle (degrees).

  • gamma (float) – 3rd lattice angle (degrees).

Returns

Direct and reciprocal vectors.

Return type

tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]

pyddt.crystal_funcs.save_diffraction(HKL: list, F: list, th: list, d: list, fout: str)[source]

Setting the output for the diffraction method.

Parameters
  • HKL (list) – Miller indices.

  • F (list) – Structure factors.

  • th (list) – Bragg angles.

  • d (list) – Interplanar distances.

  • fout (str) – Filename for output.

pyddt.crystal_funcs.phase_triplet(FG: ndarray, FH: ndarray, FGH: ndarray) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Calculates the phase triplet.

Parameters
  • FG (np.ndarray) – Structure factor (complex) of primary reflection.

  • FH (np.ndarray) – List of structure factors (complex) for the secondary reflection(s).

  • FGH (np.ndarray) – List of structure factors (complex) of the coupling reflections(s).

Returns

Cosine of phase triplet, phase triplet (deg) and W.

Return type

tuple[np.ndarray, np.ndarray, np.ndarray]

Notes

For unknown structure factors, use the triplet_relation method from Crystal class.


pyddt.ExpData class

This class is used for analyzing Renninger scans.

class pyddt.ExpData(E: float, G: list, fname: str, colx: int = 0, coly: int = 1, name: str = '')[source]

Given the experimental data, returns a new exp object.

Parameters
  • E (float) – X-ray energy (eV).

  • G (list) – Primary reflection (eg [1, 1, 1]).

  • fname (str) – Filename containing the data.

  • colx (int) – Column number of angle values. Default: 0 (1st column).

  • coly (int) – Column number of intensity values. Default: 1 (2nd column).

  • name (str) – Label for the current work. Default: None.

plot() Figure[source]

Plots the phi-scan.

Returns

Interactive plot.

Return type

matplotlib.figure.Figure

BC_plot(fname: str, M: list, Fmin: float, dw: float = 0.1, npoints: int = 20)[source]

Plots the phi-scan and BC lines for visual indexing.

Parameters
  • fname (str) – Structure filename (.in).

  • M (list) – Reference direction (eg [1, 0, 0]).

  • Fmin (float) – Cutoff for W (minimum absolute value).

  • dw (float) – Maximum distance between BC lines and primary reflection.

  • npoints (int) – Number of points of the 2D-cone representation.

Notes

  • By default, the plotly.graph_objects will be displayed in an installed browser or notebook.

  • BC lines ranging from -180 to 180 deg.

peak_picker()[source]

Manual selection of MD peaks.

Notes

  • To select a peak, stop the mouse over the maximum and press SPACE.

  • To unselect, stop the mouse over the maximum and press DEL.

  • Feel free to zoom in or out.

  • After finishing the selection, press ENTER. Then, close the figure (mouse or press q).

Attention

Press ENTER before closing the plot, even if no peak was selected.

peak_finder(minimum_intensity_p: float = 0.03)[source]

Automatic definition of the MD peak list.

Parameters

minimum_intensity_p (float) – Minimum intensity for considering a peak (% of the maximum intensity ranging between 0 and 1). Default: 0.03.

review()[source]

Plots the experimental data highlighting the selected MD peaks for user review.

Notes

  • To select a peak, stop the mouse over the maximum and press SPACE.

  • To unselect, stop the mouse over the maximum and press DEL.

  • Feel free to zoom in or out.

  • After finishing the selection, press ENTER. Then, close the figure (mouse or press q).

Attention

Press ENTER before closing the plot, even if no peak was selected.

region_of_fit(interval: int = 15, points: int = 60, flag: int = 0)[source]

Defines the region of fit for each selected MD peak.

Parameters
  • interval (int) – Number of fwhm defining the region of fit. Default: 15.

  • points (int) – Max number of points defining a peak.

  • flag (int) – If flag != 0, plots the data highlighting the calculated regions. Default: 0.

Notes

  • If flag != 0, it’s possible to delete peaks.

  • To select a peak, stop the mouse over the maximum and press SPACE.

  • To unselect, stop the mouse over the maximum and press DEL.

  • Feel free to zoom in or out.

  • After finishing the selection, press ENTER. Then, close the figure (mouse or press q).

Attention

Press ENTER before closing the plot, even if no peak was selected.

region_plot()[source]

Plots the calculated regions of fit for user review.

Notes

  • To select a peak, stop the mouse over the maximum and press SPACE.

  • To unselect, stop the mouse over the maximum and press DEL.

  • Feel free to zoom in or out.

  • After finishing the selection, press ENTER. Then, close the figure (mouse or press q).

Attention

Press ENTER before closing the plot, even if no peak was selected.

indexer(fname: str, M: list, Fmin: float, dmin: float = 0.1, flag: int = 0)[source]

Finds the secondary reflection related to each selected MD peak.

Parameters
  • fname (str) – Structure filename (the same used by Crystal class).

  • M (list) – Reference direction (eg [1, 0, 0]).

  • Fmin (float) – Cutoff for W (minimum absolute value).

  • dmin (float) – Maximum difference between MD peak and BC line crossing the primary. Default: 0.1 deg

  • flag (int) – If flag != 0, plots the secondary reflection indices. Default: 0.

Notes

  • Case two or more lattice planes are excited at the same angle with the same geometry: all will be displayed in the output file.

  • If the geometries are opposite, the peak is not indexable (so it’s excluded from the peak list).

  • It’s also not indexable the case with two excited reflections that distance themselves by less than 0.05º, whose smallest W value is at least half of the largest value. Except for these cases, the peak is indexed by the stronger reflection that is up to dmin of distance from the MD peak position.

indexation_plot(hkl: list, s: list, idx: list)[source]

Plots the phi-scan and corresponding MD indexing for user review.

Parameters
  • hkl (list) – Secondary reflections.

  • s (list) – Diffraction geometry of excitation.

  • idx (list) – Index of unindexable cases in peak list.

Notes

  • To select a peak, stop the mouse over the maximum and press SPACE.

  • To unselect, stop the mouse over the maximum and press DEL.

  • Feel free to zoom in or out.

  • After finishing the selection, press ENTER. Then, close the figure (mouse or press q).

Attention

Press ENTER before closing the plot, even if no peak was selected.

fitter(nsamples: int = 1000)[source]

Calculates the slope and slope error for each MD peak.

Parameters

nsamples (int) – Number of samples for bootstrap resampling.

Notes

If nsamples = 0, the slope error isn’t calculated.

asymmetry_assigner(sbar: float = 0.1, tau: float = 0.4, flag: int = 0)[source]

Assigns the asymmetry type.

Parameters
  • sbar (float) – Minimum value of the relative slope. Default: 0.1 (10%)

  • tau (float) – Maximum value for the ratio slope_error/slope. Default: 0.4 (40%)

  • flag (int) – If flag != 0, plots the data with read asymmetry types. Default: 0.

Notes

  • If flag != 0, it’s possible to delete peaks.

  • To select a peak, stop the mouse over the maximum and press SPACE.

  • To unselect, stop the mouse over the maximum and press DEL.

  • Feel free to zoom in or out.

  • After finishing the selection, press ENTER. Then, close the figure (mouse or press q).

Attention

Press ENTER before closing the plot, even if no peak was selected.

asymmetry_plot()[source]

Plots the phi-scan and corresponding asymmetry type assigned for each selected MD peak.

Notes

  • To invert the assigned asymmetry of an MD peak,, stop the mouse over the maximum and press SPACE.

  • To unselect, stop the mouse over the maximum and press DEL.

  • Feel free to zoom in or out.

  • After finishing the selection, press ENTER. Then, close the figure (mouse or press q).

Attention

Press ENTER before closing the plot, even if no peak was selected.

save(fout: str = '')[source]

Saves the current work.

Parameters

fout (str) – Filename of the output data. Default: NAME_E_value_G_indexes.ext/.red

Notes

  • The .ext file presents the azimuth position, hkl, slope, slope error, statistical properties, asymmetry type and excitation geometry.

  • The .red file only presents hkl, asymmetry and diffraction geometry, besides primary indices and energy in 1st line.

_peak_definer(peak_number: int, points: int) tuple[source]

Finds the indices of first and last points of an MD peak.

Parameters
  • peak_number (int) – Index of the peak center in the angles array.

  • points (int) – Max number of points defining a peak.

Returns

First and last points of the MD peak.

Return type

tuple

_index_find(dmin: float, ph: float, col: int, hkl: ndarray) tuple[source]

Find the closer MD case of a defined azimuth angle.

Parameters
  • dmin (float) – Maximum difference between peak position and BCs crossing the primary reflection.

  • ph (float) – Angle on the Renninger scan.

  • col (int) – 3 or 4 (in-out or out-in BC lines).

  • hkl (np.ndarray) – Miller indices.

Returns

Azimuth position, W amplitude, secondary reflection indices.

Return type

tuple


pyddt.expdata_funcs module

Functions required by the Expdata class. In general, unuseful for external users.

pyddt.expdata_funcs.dataframe_BClines(fname: str) tuple[source]

Constructs the required dataframe for BC lines plot.

Parameters

fname (str) – Filename with BC lines.

Returns

Bragg angle of primary reflection, FHFGH values, pd.DataFrame with BC lines.

Return type

tuple

pyddt.expdata_funcs.fwhm(x: ndarray, y: ndarray) tuple[source]

Calculates the full width at half maximum of a peak.

Parameters
  • x (np.ndarray) – Data points - azimuth angle.

  • y (np.ndarray) – Data points - intensity.

Returns

full width at half maximum (fwhm).

Return type

tuple

pyddt.expdata_funcs.peak_fit(x: ndarray, y: ndarray) float[source]

Fits the Gaussian + linear model.

Parameters
  • x (np.ndarray) – Data points (angle values).

  • y (np.ndarray) – Data points (intensity values).

Returns

Slope value.

Return type

float

pyddt.expdata_funcs.bootstrap_resampling(sample: DataFrame, n: int) float[source]

Calculates the slope error using the bootstrap resampling.

Parameters
  • sample (pd.DataFrame) – Dataframe with x and y values.

  • n (int) – Number of samples.

Returns

Width of the slope distribution.

Return type

float


pyddt.Structure class

This class is used for structural modelling from .in files.

class pyddt.Structure(fname: str)[source]

Given a .in file, returns a new struc object.

Parameters

fname (str) – Structure filename.

visualizer_in() NGLWidget[source]

Visualizes the structure. This method is available exclusively in Jupyter Notebooks.

Returns

Interactive visualization of the conventional unit cell.

Return type

nv.widget.NGLWidget

Attention

To avoid bugs, it’s highly recommended to assign this method to a variable, then close the figure after the visualization using variable_name.close().

replace_ion(old: str, new: str)[source]

Replaces atoms or ions.

Parameters
  • old (str) – Array indices or element symbol to be replaced.

  • new (str) – New atom/ion symbol.

Notes

  • There are many ways to pass indices as arguments: a number, numbers separated by commas, an interval of indices (first and last indices separated by “:” ) and intervals separated by commas. A string is expected.

  • If the new symbol isn’t in the current CromerMann list, the symbol is replaced by the most similar and a warning will be displayed.

Usage:
  • replace_ion('Ce', 'Ce3+')

  • replace_ion('1', 'O1-')

  • replace_ion('1, 2, 3', 'O1-')

  • replace_ion('1:3', 'Fe2+')

  • replace_ion('1:3, 5:6, 7:8', 'N3-')

replace_occupancy(index: str, value: str)[source]

Replaces a specific set of occupancy numbers.

Parameters
  • index (str) – Array indices of the occupancy numbers to be replaced.

  • value (str) – New values.

Notes

There are many ways to pass indices as arguments: a number, numbers separated by commas, an interval of indices (first and last indices separated by “:” ) and intervals separated by commas. A string is expected.

Usage:
  • replace_occupancy('1', 0.78)

  • replace_occupancy('1, 2, 3', 0.92)

  • replace_occupancy('1:3', 0)

  • replace_occupancy('1:3, 5:6, 7:8', 0.5)

replace_bfactor(index: str, value: str)[source]

Replaces a specific set of B-factors.

Parameters
  • index (str) – Array indices of B-factors to be replaced.

  • value (str) – New values.

Notes

There are many ways to pass indices as arguments: only a number, numbers separated by commas, an interval of indices (first and last indices separated by “:” ) and intervals separated by commas. A string is expected.

Usage:
  • replace_bfactor('1', 3.14)

  • replace_bfactor('1, 2, 3', 0.92)

  • replace_bfactor('1:3', 10.015)

  • replace_bfactor('1:3, 5:6, 7:8', 0.5)

append_atom(info: list)[source]

Appends a new atom to the structure.

Parameters

info (list) – Atom or ion symbol, fractional coordinates (x, y and z), occupancy number and B-factor.

Usage:
  • append_atom(['Fe2+', 0.5, 0.5, 0.5, 1, 3.14])

Notes

  • The new atom will be allocated in the last index of the atoms array.

  • For the current version, append atoms one-by-one.

delete_atom(index: str)[source]

Deletes a set of atoms.

Parameters

index (str) – Array indices of the atoms to be deleted.

Notes

There are many ways to pass indices as arguments: only a number, numbers separated by commas, an interval of indices (first and last indices separated by “:” ) and intervals separated by commas. A string is expected.

Usage:
  • delete_atom('1')

  • delete_atom('1, 2, 3')

  • delete_atom('1:3')

  • delete_atom('1:3, 5:6, 7:8')

save_infile(fout='')[source]

Saves the .in file.

Parameters

fout (str) – Filename. Default: datetime_fname


pyddt.AMD class

This class is used for performing compatibility analysis.

class pyddt.AMD(fexp: str, mnames: list = [])[source]

Given the experimental asymmetries and structural models, returns a new amd object.

Parameters
  • fexp (str) – Filename of experimental asymmetries.

  • mnames (list) – Names of .in files (structural models).

Notes

  • fexp file must present hkl indices, asymmetry type, and diffraction geometry in columns (this order), including primary reflection and X-ray energy in 1st line. This file is automatically generated by the expdata class (.red extension).

experimental_asymmetries(hl: str = 'cyan', lh: str = 'gold')[source]

Shows the experimental asymmetries in the diagram.

Parameters
  • hl (str or tuple) – Color of HL asymmetries. Default: cyan.

  • lh (str or tuple) – Color of LH asymmetries. Default: gold.

Notes

hl and lh must be color names or RGB values ranging between 0 and 1.

Usage:
  • exp_plot('red', 'blue')

  • exp_plot((1, 0, 0), (0, 0, 1))

diagram_positions()[source]

Shows the MD positions in the asymmetry matching diagram.

theoretical_asymmetries()[source]

Calculates the theoretical asymmetries.

matching_matrix()[source]

Generates the matching matrix.

twovariable_plot(xmax: float, xmin: float, dx: float, ymax: float, ymin: float, dy: float, xlabel: str = 'x', ylabel: str = 'y', color_empty: str = 'whitesmoke', incp: str = 'red', cp: str = 'lime', showlegend: bool = True)[source]

Plots the asymmetry matching diagram (AMD) for structural models with two differential variables.

Parameters
  • xmax (float) – Maximum value in horizontal axis.

  • xmin (float) – Minimum value in horizontal axis.

  • dx (float) – Step of the horizontal axis.

  • ymax (float) – Maximum value in vertical axis.

  • ymin (float) – Minimum value in vertical axis.

  • dy (float) – Step of the vertical axis.

  • xlabel (str) – Label for the horizontal axis. Default: x.

  • ylabel (str) – Label for the vertical axis. Default: y.

  • color_empty (str or tuple) – Color of the empty cells. Default: whitesmoke.

  • incp (str or tuple) – Color representing the incompatible cases. Default: red.

  • cp (str or tuple) – Color representing the compatible cases. Default: lime.

  • showlegend (bool) – Display legend (True/False). Default: True.

Notes

color_empty, incp and cp must be color names or RGB values ranging between 0 and 1.

Usage:
  • plot(xmax=1, xmin=0, dx=0.1, ymax=60, ymin=10, dy=5, xlabel='H effective charge', ylabel='N displacement (pm)', color_empty='gray', incp='blue', cp='green')

  • plot(xmax=1, xmin=0, dx=0.1, ymax=60, ymin=10, dy=5, xlabel='H effective charge', ylabel='N displacement (pm)', color_empty=(0.5, 0.5, 0.5), incp=(0, 0, 1), cp=(0, 1, 0))

onevariable_plot(ncols: int, nrows: int, color_empty: str = 'whitesmoke', incp: str = 'red', cp: str = 'lime', showlegend: bool = True)[source]

Plots the asymmetry matching diagram (AMD) for structural models with one differential variable.

Parameters
  • ncols (int) – Number of columns.

  • nrows (int) – Number of rows.

  • color_empty (str or tuple) – Color of the empty cells. Default: whitesmoke.

  • incp (str or tuple) – Color representing the incompatible cases. Default: red.

  • cp (str or tuple) – Color representing the compatible cases. Default: lime.

  • showlegend (bool) – Display legend (True/False). Default: True.

Notes

color_empty, incp and cp must be color names or RGB values ranging between 0 and 1.

Usage:
  • onevariable_plot(5, 2, color_empty=(0.5, 0.5, 0.5), incp=(0, 0, 1), cp=(0, 1, 0))


pyddt.funcs module

Functions required by the main classes. Unuseful for external users.

pyddt.funcs.delete_multiple(*args: ndarray, idx: list) list[numpy.ndarray][source]

Deletes the same indices of multiple arrays.

Parameters
  • args (list[np.ndarray]) – Arrays.

  • idx (list or np.ndarray or int) – Indices.

Returns

New array after deleting the indicated indices.

Return type

ndarray

Usage:
  • delete_multiple(arr1, arr2, arr3, arr4, ...,  idx=0)

  • delete_multiple(arr1, arr2, arr3, arr4, ...,  idx=[0, 1, 2])

  • delete_multiple(arr1, arr2, ...,  idx=np.arange(0, 100))

Notes

Call this function explicitly using idx=.

pyddt.funcs.search_reflection(HKL: ndarray, G: ndarray) int[source]

Finds the primary reflection.

Parameters
  • HKL (np.ndarray) – Array of Miller indices.

  • G (np.ndarray) – Miller indices of the primary reflection (eg [1, 0, 0]).

Returns

Position of the primary reflection in the HKL array.

Return type

int or list

pyddt.funcs.coupling_reflection(F: ndarray, H: ndarray, G: ndarray) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, list[int]][source]

Defines the coupling reflections and finds the corresponding structure factors.

Parameters
  • F (np.ndarray) – Complex structure factors of the secondary reflections.

  • H (np.ndarray) – Secondary reflections.

  • G (np.ndarray) – Primary reflection.

Returns

Secondary reflections, structure factors of secondary reflections, coupling reflections, structure factors of coupling reflections, index of not found coupling reflections.

Return type

tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, list[int]]

pyddt.funcs.comparison_plot(dataframe: DataFrame, zlabel: str, xlabel: str, color: str = 'darkred')[source]

Comparison of phase (three-dimensional plot).

Parameters
  • dataframe (pd.DataFrame) – Dataframe with x, y and z coordinates labeled as F, Q and Z.

  • zlabel (str) – Title for Z axes (phase difference).

  • xlabel (str) – Title for X axes (scattering amplitude - F or W).

  • color (str) – Color of markers. Default: darkred.

pyddt.funcs.str_append(s: str, text: str) str[source]

Appends new text to an existent string.

Parameters
  • s (str) – Existing string.

  • text (str) – New text.

Returns

Concatenation of s and text.

Return type

str