hikari.dataframes.hkl ===================== .. py:module:: hikari.dataframes.hkl Classes ------- .. autoapisummary:: hikari.dataframes.hkl.HklKeyRegistrar hikari.dataframes.hkl.HklKey hikari.dataframes.hkl.HklKeyImperativeInt8 hikari.dataframes.hkl.HklKeyAveragedFloat64 hikari.dataframes.hkl.HklKeyKeptFloat64 hikari.dataframes.hkl.HklKeyIndexH hikari.dataframes.hkl.HklKeyIndexK hikari.dataframes.hkl.HklKeyIndexL hikari.dataframes.hkl.HklKeyStructureFactor hikari.dataframes.hkl.HklKeyIntensity hikari.dataframes.hkl.HklKeyIntensityCalculated hikari.dataframes.hkl.HklKeyIntensityUncertainty hikari.dataframes.hkl.HklKeyStructureFactorUncertainty hikari.dataframes.hkl.HklKeyStructureFactorToUncertaintyRatio hikari.dataframes.hkl.HklKeyBatchNumber hikari.dataframes.hkl.HklKeyCrystalNumber hikari.dataframes.hkl.HklKeyMultiplicity hikari.dataframes.hkl.HklKeyWavelength hikari.dataframes.hkl.HklKeyPhase hikari.dataframes.hkl.HklKeyRadius hikari.dataframes.hkl.HklKeyTransmissionPathLength hikari.dataframes.hkl.HklKeyCosineU1 hikari.dataframes.hkl.HklKeyCosineU2 hikari.dataframes.hkl.HklKeyCosineU3 hikari.dataframes.hkl.HklKeyCosineV1 hikari.dataframes.hkl.HklKeyCosineV2 hikari.dataframes.hkl.HklKeyCosineV3 hikari.dataframes.hkl.HklKeyCoordinateX hikari.dataframes.hkl.HklKeyCoordinateY hikari.dataframes.hkl.HklKeyCoordinateZ hikari.dataframes.hkl.HklKeyZeta hikari.dataframes.hkl.HklKeyZetaSquared hikari.dataframes.hkl.HklKeyCalculatedIntensityToSigma hikari.dataframes.hkl.HklKeyObservedIntensityToSigma hikari.dataframes.hkl.HklKeyEquivalenceCode hikari.dataframes.hkl.HklKeyDummy hikari.dataframes.hkl.HklFrame hikari.dataframes.hkl.HklIo hikari.dataframes.hkl.HklReader hikari.dataframes.hkl.HklWriter hikari.dataframes.hkl.HklToResConverter Module Contents --------------- .. py:class:: HklKeyRegistrar Bases: :py:obj:`type` Metaclass for `HklKey`s which registers them if they define `name`. .. py:attribute:: REGISTRY .. py:attribute:: default :type: None .. py:attribute:: dtype :type: numpy.dtype .. py:property:: IMPERATIVES .. py:class:: HklKey Base Class for every subsequent HklKey. .. py:attribute:: name :type: str :value: '' .. py:attribute:: default :value: None .. py:attribute:: dtype :type: str :value: '' .. py:attribute:: imperative :type: bool :value: False .. py:attribute:: reduce_behaviour :type: str :value: 'keep' .. py:attribute:: type :type: HklKey.type .. py:class:: HklKeyImperativeInt8 Bases: :py:obj:`HklKey` Base Class for every subsequent HklKey. .. py:attribute:: default :value: 0 .. py:attribute:: dtype .. py:attribute:: imperative :value: True .. py:class:: HklKeyAveragedFloat64 Bases: :py:obj:`HklKey` Base Class for every subsequent HklKey. .. py:attribute:: default :value: 0.0 .. py:attribute:: dtype .. py:attribute:: reduce_behaviour :value: 'average' .. py:class:: HklKeyKeptFloat64 Bases: :py:obj:`HklKey` Base Class for every subsequent HklKey. .. py:attribute:: default :value: 0.0 .. py:attribute:: dtype .. py:attribute:: reduce_behaviour :value: 'keep' .. py:class:: HklKeyIndexH Bases: :py:obj:`HklKeyImperativeInt8` Reciprocal lattice Miller index h .. py:attribute:: name :value: 'h' .. py:class:: HklKeyIndexK Bases: :py:obj:`HklKeyImperativeInt8` Reciprocal lattice Miller index k .. py:attribute:: name :value: 'k' .. py:class:: HklKeyIndexL Bases: :py:obj:`HklKeyImperativeInt8` Reciprocal lattice Miller index l .. py:attribute:: name :value: 'l' .. py:class:: HklKeyStructureFactor Bases: :py:obj:`HklKeyAveragedFloat64` Crystallographic structure factor F .. py:attribute:: name :value: 'F' .. py:attribute:: default :value: 1.0 .. py:class:: HklKeyIntensity Bases: :py:obj:`HklKeyAveragedFloat64` Crystallographic intensity I_obs .. py:attribute:: name :value: 'I' .. py:attribute:: default :value: 1.0 .. py:class:: HklKeyIntensityCalculated Bases: :py:obj:`HklKeyAveragedFloat64` Crystallographic calculated intensity I_calc .. py:attribute:: name :value: 'Ic' .. py:attribute:: default :value: 1.0 .. py:class:: HklKeyIntensityUncertainty Bases: :py:obj:`HklKeyAveragedFloat64` Uncertainty of intensity I determination .. py:attribute:: name :value: 'si' .. py:class:: HklKeyStructureFactorUncertainty Bases: :py:obj:`HklKeyAveragedFloat64` Uncertainty of structure factor F determination .. py:attribute:: name :value: 'sf' .. py:class:: HklKeyStructureFactorToUncertaintyRatio Bases: :py:obj:`HklKeyAveragedFloat64` Structure factor to its uncertainty ratio .. py:attribute:: name :value: 'u' .. py:class:: HklKeyBatchNumber Bases: :py:obj:`HklKey` Batch or run number .. py:attribute:: name :value: 'b' .. py:attribute:: default :value: 0 .. py:attribute:: dtype .. py:attribute:: reduce_behaviour :value: 'discard' .. py:class:: HklKeyCrystalNumber Bases: :py:obj:`HklKey` Crystal domain or twin number .. py:attribute:: name :value: 'c' .. py:attribute:: default :value: 0 .. py:attribute:: dtype .. py:attribute:: reduce_behaviour :value: 'discard' .. py:class:: HklKeyMultiplicity Bases: :py:obj:`HklKey` Multiplicity i.e. how many observation contributed to this reflection .. py:attribute:: name :value: 'm' .. py:attribute:: default :value: 1 .. py:attribute:: dtype .. py:attribute:: imperative :value: True .. py:attribute:: reduce_behaviour :value: 'add' .. py:class:: HklKeyWavelength Bases: :py:obj:`HklKey` Wavelength expressed in Angstrom .. py:attribute:: name :value: 'la' .. py:attribute:: default :value: 0.0 .. py:attribute:: dtype .. py:attribute:: reduce_behaviour :value: 'discard' .. py:class:: HklKeyPhase Bases: :py:obj:`HklKeyAveragedFloat64` Reflection phase expressed in radians .. py:attribute:: name :value: 'ph' .. py:attribute:: default :value: 0.0 .. py:class:: HklKeyRadius Bases: :py:obj:`HklKey` Distance from 000 node, i.e. double the sin(th)/la resolution in A^-1 .. py:attribute:: name :value: 'r' .. py:attribute:: dtype .. py:class:: HklKeyTransmissionPathLength Bases: :py:obj:`HklKeyKeptFloat64` Absorption-weighted transmission path length in centimeters .. py:attribute:: name :value: 't' .. py:class:: HklKeyCosineU1 Bases: :py:obj:`HklKeyKeptFloat64` Direction cosines of a vector (unused, see XD manual for reference) .. py:attribute:: name :value: 'u1' .. py:class:: HklKeyCosineU2 Bases: :py:obj:`HklKeyKeptFloat64` Direction cosines of a vector (unused, see XD manual for reference) .. py:attribute:: name :value: 'u2' .. py:class:: HklKeyCosineU3 Bases: :py:obj:`HklKeyKeptFloat64` Direction cosines of a vector (unused, see XD manual for reference) .. py:attribute:: name :value: 'u3' .. py:class:: HklKeyCosineV1 Bases: :py:obj:`HklKeyKeptFloat64` Direction cosines of a vector (unused, see XD manual for reference) .. py:attribute:: name :value: 'v1' .. py:class:: HklKeyCosineV2 Bases: :py:obj:`HklKeyKeptFloat64` Direction cosines of a vector (unused, see XD manual for reference) .. py:attribute:: name :value: 'v2' .. py:class:: HklKeyCosineV3 Bases: :py:obj:`HklKeyKeptFloat64` Direction cosines of a vector (unused, see XD manual for reference) .. py:attribute:: name :value: 'v3' .. py:class:: HklKeyCoordinateX Bases: :py:obj:`HklKeyKeptFloat64` Reciprocal space coordinate x* .. py:attribute:: name :value: 'x' .. py:attribute:: dtype .. py:class:: HklKeyCoordinateY Bases: :py:obj:`HklKeyKeptFloat64` Reciprocal space coordinate x* .. py:attribute:: name :value: 'y' .. py:attribute:: dtype .. py:class:: HklKeyCoordinateZ Bases: :py:obj:`HklKeyKeptFloat64` Reciprocal space coordinate x* .. py:attribute:: name :value: 'z' .. py:attribute:: dtype .. py:class:: HklKeyZeta Bases: :py:obj:`HklKeyAveragedFloat64` weighted diff. in observed I - calculated Ic intensity .. py:attribute:: name :value: 'ze' .. py:class:: HklKeyZetaSquared Bases: :py:obj:`HklKeyAveragedFloat64` weighted diff. in observed I - calculated Ic intensity, squared .. py:attribute:: name :value: 'ze2' .. py:class:: HklKeyCalculatedIntensityToSigma Bases: :py:obj:`HklKeyAveragedFloat64` Calculated intensity of reflection divided by experimental sigma .. py:attribute:: name :value: 'Icsi' .. py:attribute:: default :value: 1.0 .. py:class:: HklKeyObservedIntensityToSigma Bases: :py:obj:`HklKeyAveragedFloat64` Observed intensity of reflection divided by experimental sigma .. py:attribute:: name :value: 'Iosi' .. py:attribute:: default :value: 1.0 .. py:class:: HklKeyEquivalenceCode Bases: :py:obj:`HklKey` Integer unique for each set of symmetrically equivalent reflections .. py:attribute:: name :value: 'equiv' .. py:attribute:: default :value: 0 .. py:attribute:: dtype .. py:class:: HklKeyDummy Bases: :py:obj:`HklKey` Dummy column for loading or holding irrelevant string data .. py:attribute:: name :value: 'None' .. py:attribute:: default :value: '' .. py:attribute:: dtype .. py:class:: HklFrame Bases: :py:obj:`hikari.dataframes.BaseFrame` A master object which manages single-crystal diffraction files. It utilises other `Hkl*` classes to import, store, manipulate and output information about single-crystal diffraction patterns. HklFrame acts as a container which stores the diffraction data (Pandas dataframe, :attr:`table`) and elementary crystal cell data (:class:`hikari.dataframes.Base`). Demanding methods belonging to this class are vectorized, providing relatively satisfactory performance and high memory capacity. HklFrame methods are designed to work in-place, so the work strategy is to create a new instance of HklFrame for each reflection dataset, manipulate it using methods, eg. :func:`merge` or :func:`trim`, and :func:`copy` to other object or output using :func:`write` if needed. The HklFrame always initiates empty and does not accept any arguments. Some magic methods, such as :func:`__len__` and :func:`__add__` are defined and describe/operate on the :attr:`frame`. .. py:attribute:: HKL_LIMIT :value: 127 Highest absolute value of h, k or l index, which can be interpreted correctly by current version of the software. .. py:attribute:: __la :value: 0.71069 Wavelength of radiation used in experiment. .. py:attribute:: table Pandas dataframe containing diffraction data information. Each row represents one reflection observation, while each column has one piece of information about the reflections. For a list of available keys, see :class:`HklKeys`, whose instance is used to menage the keys of this table. .. py:method:: __add__(other) :param other: HklFrame to be added to data :type other: HklFrame :return: concatenated :attr:`table` dataframes with metadata from first :rtype: HklFrame .. py:method:: __len__() :return: Number of rows (individual reflections) in `self.data` :rtype: int .. py:method:: __str__() :return: Human-readable representation of `self.data` :rtype: str .. py:property:: la Wavelength of radiation used in the diffraction experiment. Can be set using popular abbreviations such as "MoKa" or "CuKb", where *a* and *b* stand for *alpha* and *beta*. Implemented cathode materials include: "Ag", "Co", "Cr", "Cu", "Fe", "Mn", "Mo", "Ni", "Pd", "Rh", "Ti", "Zn" and have been imported from International Tables of Crystallography, Volume C, Table 4.2.4.1, 3rd Edition. :return: wavelength of radiation used in experiment :rtype: float .. py:property:: r_lim Radius of limiting sphere in A^-1 calculated as 2/:attr:`la` :rtype: float :type: return .. py:method:: _in_dacs(opening_angle, vectors) .. py:method:: dac_trim(opening_angle = 35.0, vector=None) Remove reflections outside the opening_angle DAC-accessible volume. Sample/DAC orientation can be supplied either via specifying crystal orientation in :class:`hikari.dataframes.BaseFrame`, in :attr:`orientation` or providing a xyz\* *vector* perpendicular to the dac-accessible disc. For further details, see `*TchoƄ & Makal, IUCrJ 8, 1006-1017 (2021)* `_. :param opening_angle: DAC single opening angle in degrees, default 35. :type opening_angle: float :param vector: Provides information about orientation of crystal relative to DAC. If None, :attr:`orientation` is used instead. :type vector: tuple[float] :return: HklFrame containing only reflections in dac-accessible region. :rtype: HklFrame .. py:method:: dacs_count(opening_angle = 35.0, vectors = np.array((1, 0, 0))) Count unique dac-accessible reflections for n crystals placed such that vector n is perpendicular to diamond. For details see :meth:`dac_trim`. :param opening_angle: DAC single opening angle in degrees, default 35. :type opening_angle: float :param vectors: Array with rotational axes of available DAC-discs. :type vectors: np.array :return: Array with numbers of unique reflns in DAC-accessible region. :rtype: np.array .. py:method:: copy() :return: An exact deep copy of this HklFrame. :rtype: HklFrame .. py:method:: extinct(space_group = SG['P1']) Removes from dataframe reflections which should be extinct based on space :class:`hikari.symmetry.group.Group`. For ref. see ITC-A12.3.5. :param space_group: Space group used to extinct the reflections. :type space_group: hikari.symmetry.group.Group .. py:method:: find_equivalents(point_group = PG['1']) Assign each reflection its symmetry equivalence identifier and store it in the `hikari.dataframes.HklFrame.data['equiv']` column. The ID is an integer unique for each set of equivalent reflections. In order to provide an information about equivalence, a *point_group* of reciprocal space must be provided (default PG['1']). Point groups and their notation can be found in :mod:`hikari.symmetry` sub-package. :param point_group: Point group used to determine symmetry equivalence :type point_group: hikari.symmetry.Group .. py:method:: from_dict(dictionary) Construct the `self.data` using information stored in dictionary. The dictionary keys must be valid strings, see :class:`HklKeys` for a list of valid keys. The dictionary values must be iterable of equal size, preferably `numpy.ndarray`. :param dictionary: Dictionary with "key - iterable of values" pairs. :type dictionary: Dict[str, numpy.ndarray] .. py:method:: fill(radius = 2.0) Fill dataframe with all reflections within *radius* from space origin. :param radius: Maximum distance from the reciprocal space origin to placed reflection (in reciprocal Angstrom). .. py:method:: stats(bins = 10, space_group = SG['P1']) Returns completeness, redundancy, number of all, unique & theoretically possible reflections within equal-volume `bins` in given `space group`. :param bins: Number of equal-volume bins to divide the data into. :type bins: int :param space_group: Group used to calculate equivalence and extinctions :type space_group: hikari.symmetry.Group :return: String containing table with stats as a function of resolution :rtype: str .. py:method:: merge(point_group=PG['1']) Average down each set of redundant reflections present in the table, to one reflection. The redundancy is determined using the :meth:`find_equivalents` method with appropriate point group. Thus, the merging can be used in different ways depending on point group: - For PG['1'], only reflections with exactly the same h, k, l indices will be merged. Resulting dataframe will not contain any duplicates. - For PG['-1'] reflections with the same h, k and l as well as their Friedel pairs will be merged together to one reflection. - For PG['mmm'] all equivalent reflections of "mmm" point group will be merged. Since "mmm" is centrosymmetric, Friedel pairs will be merged. - For PG['mm2'] symmetry-equivalent reflections within the "mmm" point group will be merged, but the Friedel pairs will be preserved. The procedure will have a different effect on different dataframe keys, depending on their "reduce_behaviour" specified in :class:`HklKeys`. Fixed parameters *h, k, l, x, y, z, r* and *equiv* will be preserved; Floating points such as intensity *I*, structure factor *F* and their uncertainties *si* and *sf* will be averaged using arithmetic mean; Multiplicity *m* will be summed; Other parameters which would lose their meaning such as batch number *b* will be discarded. The merging inevitably removes some information from the dataframe, but it can be necessary for some operations. For example, the drawing procedures work faster and provide clearer image if multiple points occupying the same position in space are reduced to one instance. :param point_group: Point Group used to determine symmetry equivalence :type point_group: hikari.symmetry.Group .. py:method:: place() Assign reflections their positions in reciprocal space ("x", "y", "z") and calculate their distance from origin ("r") in reciprocal Angstrom. Save four new keys and their values into the dataframe. .. py:method:: calculate_fcf_statistics() Calculate values of zeta (I - Ic) / si on other stats based on contents of fcf files. Save new key and its values into the dataframe. .. py:method:: read(hkl_path, hkl_format='shelx_4') Read the contents of .hkl file as specified by path and format, and store them in the pandas dataframe in `self.data`. For a list of all available .hkl formats, please refer to :attr:`hikari.dataframes.HklIo.format`. :param hkl_path: Absolute or relative path to the .hkl file. :type hkl_path: str :param hkl_format: Format of provided .hkl file. :type hkl_format: union[int, str, dict] .. py:method:: _recalculate_structure_factors_and_intensities() Calculate 'I' and 'si' or 'F' and 'sf', depending on which are missing. .. py:method:: _recalculate_structure_factors_from_intensities() Recalculate the structure factor F and its uncertainty sf. Structure factor is calculated as follows: *F = signum(I) \* sqrt(abs(I))*. Structure factor's uncertainty is calculated as follows: *sf = si / (2 \* sqrt(abs(I)))*. .. py:method:: _recalculate_intensities_from_structure_factors() Recalculate the intensity I and its uncertainty si. Intensity is calculated as follows: *I = signum(F) \* F \*\* 2*. Intensity's uncertainty is calculated as follows: *si = 2 \* sf \* abs(F)*. .. py:method:: transform(operations) Apply a symmetry operation or list of symmetry operations to transform the diffraction pattern. If one symmetry operation (3x3 or 4x4 numpy array) is provided, it effectively multiplies the hkl matrix by the operation matrix and accordingly alters the `self.data` dataframe. As a result, the length of `self.data` before and after transformation is the same. However, the function behaves slightly counter-intuitively if two or more operation matrices are provided. In such case the method applies the transformation procedure independently for each operation, and then *concatenates* resulting matrices. Resulting self.data is len(operations) times longer than the initial. The function can use 3x3 or larger (e.g. 4x4) matrices, as it selects only the upper-left 3x3 segment for the sake of calculations. Also, while reconstructing the symmetry of merged reflection file it is important to use all symmetry operations, not only generators. Single symmetry operations or their lists belonging to certain point groups can be imported from :py:mod:`hikari.symmetry` module. :param operations: Iterable of operation matrices to be applied :type operations: Union[Iterable[np.ndarray], np.ndarray] .. py:method:: thin_out(target_cplt=1.0) Randomly remove reflections from dataframe in order to decrease the completeness to *target_cplt* (relatively to initial completeness). :param target_cplt: Percentage of data not removed from dataframe :type target_cplt: float .. py:method:: to_res(path='hkl.res', colored='m') Export the reflection information from table to .res file, so that a software used to visualize .res files can be used to visualize a diffraction data in three dimensions. :param colored: Which key of dataframe should be visualized using color :type colored: str :param path: Absolute or relative path where the file should be saved :type path: str .. py:method:: trim(limit) Remove reflections further than *limit* from reciprocal space origin. :param limit: Radius of the trimming sphere in reciprocal Angstrom :type limit: float .. py:method:: write(hkl_path, hkl_format='shelx_4') Write the contents of dataframe to a .hkl file using specified *path* and *format*. For a list of all available .hkl formats, please refer to :attr:`hikari.dataframes.HklIo.format`. :param hkl_path: Absolute or relative path to the .hkl file. :type hkl_path: str :param hkl_format: Desired format of .hkl file. :type hkl_format: union[int, str, dict] .. py:class:: HklIo(hkl_file_path, hkl_file_format) A helper class supporting HklFrame. Manages reading and writing hkl files into and out of HklFrame's dataframe. .. py:attribute:: use_separator :value: True .. py:attribute:: file_path :value: '' .. py:attribute:: formats_defined .. py:attribute:: formats_aliases .. py:attribute:: __format :value: 'shelx_4' .. py:property:: format Return a name of currently used hkl file format. Available file formats and their aliases are defined internally in .json files and have been presented in a table below: +----------+----------+------------------------+------+------+--------+ | Name | Aliases | Contents |Prefix|Suffix| Free | | | | (format string) | | | format | +==========+==========+========================+======+======+========+ | free_2 | | h -4 k -4 l -4 I -8 | NO | YES | YES | | | | si -8 b -4 la -8 | | (a) | | +----------+----------+------------------------+------+------+--------+ | free_3 | | h -4 k -4 l -4 | NO | YES | YES | | | | F -8 sf -8 b -4 | | (a) | | +----------+----------+------------------------+------+------+--------+ | free_4 | | h -4 k -4 l -4 | NO | YES | YES | | | | I -8 si -8 b -4 | | (a) | | +----------+----------+------------------------+------+------+--------+ | free_40 | free | h -4 k -4 l -4 | NO | YES | YES | | | | I -8 si -8 | | (a) | | +----------+----------+------------------------+------+------+--------+ | free_5 | | h -4 k -4 l -4 | NO | YES | YES | | | | I -8 si -8 c -4 | | (a) | | +----------+----------+------------------------+------+------+--------+ | free_6 | | h -4 k -4 l -4 | NO | YES | YES | | | | I -8 si -8 m -4 | | (a) | | +----------+----------+------------------------+------+------+--------+ | m80 | | h 4 k 4 l 4 b 4 F 12 | YES | YES | NO | | | | None 132 | (b) | (b) | | +----------+----------+------------------------+------+------+--------+ | shelx_2 | 2 | h 4 k 4 l 4 I 8 si 8 | NO | YES | NO | | | | b 4 la 8 | | (a) | | +----------+----------+------------------------+------+------+--------+ | shelx_3 | 3 | h 4 k 4 l 4 | NO | YES | NO | | | | F 8 sf 8 b 4 | | (a) | | +----------+----------+------------------------+------+------+--------+ | shelx_4 | 4 | h 4 k 4 l 4 | NO | YES | NO | | | | I 8 si 8 b 4 | | (a) | | +----------+----------+------------------------+------+------+--------+ | shelx_40 | 40 | h 4 k 4 l 4 | NO | YES | NO | | | | I 8 si 8 | | (a) | | +----------+----------+------------------------+------+------+--------+ | shelx_5 | 5 | h 4 k 4 l 4 | NO | YES | NO | | | | I 8 si 8 c 4 | | (a) | | +----------+----------+------------------------+------+------+--------+ | shelx_6 | 6 | h 4 k 4 l 4 | NO | YES | NO | | | | I 8 si 8 m 4 | | (a) | | +----------+----------+------------------------+------+------+--------+ | shelx_fcf| fcf | h 4 k 4 l 4 | YES | NO | NO | | | | Ic 14 I 14 si 13 | (*) | | | +----------+----------+------------------------+------+------+--------+ | tonto_F | | h -4 k -4 l -4 | YES | YES | YES | | | | F -8 sf -8 | (c) | (c) | | +----------+----------+------------------------+------+------+--------+ | tonto_I | tonto | h -4 k -4 l -4 | YES | YES | YES | | | | I -8 si -8 | (c) | (c) | | +----------+----------+------------------------+------+------+--------+ | xd_F6 | | h -4 k -4 l -4 b -3 | YES | NO | YES | | | | F -13 sf -13 | (d) | | | +----------+----------+------------------------+------+------+--------+ | xd_F7 | | h -4 k -4 l -4 b -3 | YES | NO | YES | | | | F -13 sf -13 t -10 | (d) | | | +----------+----------+------------------------+------+------+--------+ | xd_F-7 | | h -4 k -4 l -4 b -3 | YES | NO | YES | | | | F -13 sf -13 ph -10 | (d) | | | +----------+----------+------------------------+------+------+--------+ | xd_F13 | | h -4 k -4 l -4 b -3 | YES | NO | YES | | | | F -13 sf -13 t -10 | (d) | | | | | | u1 -10 u2 -10 u3 -10 | | | | | | | v1 -10 v2 -10 v3 -10 | | | | +----------+----------+------------------------+------+------+--------+ | xd_I6 | xd | h -4 k -4 l -4 b -3 | YES | NO | YES | | | | I -13 si -13 | (d) | | | +----------+----------+------------------------+------+------+--------+ | xd_I7 | | h -4 k -4 l -4 b -3 | YES | NO | YES | | | | I -13 si -13 t -10 | (d) | | | +----------+----------+------------------------+------+------+--------+ | xd_I-7 | | h -4 k -4 l -4 b -3 | YES | NO | YES | | | | I -13 si -13 ph -10 | (d) | | | +----------+----------+------------------------+------+------+--------+ | xd_I13 | | h -4 k -4 l -4 b -3 | YES | NO | YES | | | | I -13 si -13 t -10 | (d) | | | | | | u1 -10 u2 -10 u3 -10 | | | | | | | v1 -10 v2 -10 v3 -10 | | | | +----------+----------+------------------------+------+------+--------+ | *custom* | | custom string as above | NO | NO | if all | | | | with keys and widths | | | widths | | | | | | | in | | | | | | | format | | | | | | | are <0 | +----------+----------+------------------------+------+------+--------+ Three different types of prefix / suffix are supported at the moment: - Suffix (a) is a zero-line: a shelx ending line with h = k = l = 0, - Prefix and suffix (b) express a superflip-style block/start end, - Prefix and suffix (c) are tonto-characteristic beginning/end of file, - Prefix (d) is an xd-characteristic line with info about file content. Pre/suffixes denoted with (*) are not supported in terms of writing. A custom hkl file format can be defined by providing a *format string* instead of 'Name'. The string should look like the ones in column "contents". For the meaning of keys ('I', 'b', 'c' etc.), please refer to :class:`HklKeys`. :return: Returns a name of currently used format. :rtype: str .. py:method:: _build_line_formatter() Prepare :meth:`line_formatter` to format hkl data while writing. :return: String for str.format() to format hkl data while writing. :rtype: str .. py:property:: _format_dict A dictionary with details concerning current format. .. py:property:: _line_formatter A string used by string.format() method to print hkl data. .. py:method:: _import_custom_format(custom_format_string) Import format string such as 'h 4 k 4 l 4 I 8 si 8' as format 'custom'. :param custom_format_string: string containing alternating data labels and column widths (all negative if free format) separated using ' ' :type custom_format_string: str :return: None .. py:property:: is_current_format_free Return true if currently defined format is free, i.e. the columns are separated by whitespace. :return: True if all format widths are negative; False otherwise. :rtype: bool .. py:class:: HklReader(hkl_file_path, hkl_file_format) Bases: :py:obj:`HklIo` A helper class for HklFrame, Manages reading hkl files and importing data and keys from them .. py:method:: _parse_fixed_line(line) Parse data from a line, where data from each *label* has fixed *width*. :param line: string to be parsed based on format dictionary. :type line: str :return: list of strings extracted from parsed line :rtype: list .. py:method:: _parse_free_line(line) Parse data from line, where data from *labels* is separated with space. :param line: string to be parsed based on format dictionary. :type line: str :return: list of strings extracted from parsed line :rtype: list .. py:method:: read() Read the contents of file currently pointed by :attr:`hkl_file_path` and format :attr:`hkl_file_format` and return them to a dictionary. :return: A dictionary containing information read from .hkl file. :rtype: dict .. py:class:: HklWriter(hkl_file_path, hkl_file_format) Bases: :py:obj:`HklIo` A helper class for HklFrame, Manages writing hkl files and exporting data to them .. py:method:: write(hkl_data) Write data from pandas dataframe `hkl_data` to the file specified at :attr:`hkl_file_path` of format :attr:`hkl_file_format`. :param hkl_data: Dataframe containing reflection information. :type hkl_data: pandas.dataframe .. py:class:: HklToResConverter(hkl_dataframe) A class responsible for representing hkl data using .res format .. py:attribute:: MIN_DISTANCE :value: 10.0 .. py:attribute:: ELEMENTS :value: ('H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl',... .. py:attribute:: MIN_U :value: 1e-05 .. py:attribute:: MAX_U :value: 4.99999 .. py:attribute:: df .. py:property:: abc_scale_factor .. py:property:: largest_absolute_hkl .. py:property:: x .. py:property:: y .. py:property:: z .. py:property:: u .. py:property:: c .. py:property:: res_header .. py:property:: atom_list .. py:method:: res_line(_c, _h, _k, _l, _x, _y, _z, _u) :staticmethod: :return: res line filled based on input element, hkl, xyz and u. :rtype: str .. py:method:: convert(path='~')