How to use the orix.crystal_map.PhaseList function in orix

To help you get started, we’ve selected a few orix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyxem / orix / orix / io / plugins / orix_hdf5.py View on Github external
def dict2phaselist(dictionary):
    """Get a :class:`~orix.crystal_map.phase_list.PhaseList` object from a
    dictionary.

    Parameters
    ----------
    dictionary : dict
        Dictionary with phase list information.

    Returns
    -------
    PhaseList
    """
    dictionary = copy.deepcopy(dictionary)
    return PhaseList(phases={int(k): dict2phase(v) for k, v in dictionary.items()})
github pyxem / orix / orix / io / plugins / emsoft_h5ebsd.py View on Github external
step_y = header_group["Step Y"][:][0]
    map_size = ny * nx

    # Some of the data needed to create a CrystalMap object
    phase_name, symmetry, structure = _get_phase(phase_group)
    data_dict = {
        # Get map coordinates ("Y Position" data set is not correct in EMsoft as of
        # 2020-04, see:
        # https://github.com/EMsoft-org/EMsoft/blob/7762e1961508fe3e71d4702620764ceb98a78b9e/Source/EMsoftHDFLib/EMh5ebsd.f90#L1093)
        "x": data_group["X Position"][:],
        # y = data_group["Y Position"][:]
        "y": np.sort(np.tile(np.arange(ny) * step_y, nx)),
        # Get phase IDs
        "phase_id": data_group["Phase"][:],
        # Get phase name, crystal symmetry and structure (lattice)
        "phase_list": PhaseList(
            Phase(name=phase_name, symmetry=symmetry, structure=structure)
        ),
        "scan_unit": "um",
    }

    # Get rotations
    if refined:
        euler = data_group["RefinedEulerAngles"][:]
    else:  # Get n top matches for each pixel
        top_match_idx = data_group["TopMatchIndices"][:][:map_size] - 1
        dictionary_size = data_group["FZcnt"][:][0]
        dictionary_euler = data_group["DictionaryEulerAngles"][:][:dictionary_size]
        euler = dictionary_euler[top_match_idx, :]
    data_dict["rotations"] = Rotation.from_euler(euler)

    # Get number of top matches kept per data point
github pyxem / orix / orix / io / plugins / ang.py View on Github external
"euler2": None,
        "euler3": None,
        "x": None,
        "y": None,
        "phase_id": None,
        "prop": {},
    }
    for column, name in enumerate(column_names):
        if name in data_dict.keys():
            data_dict[name] = file_data[:, column]
        else:
            data_dict["prop"][name] = file_data[:, column]

    # Add phase list to dictionary
    unique_phase_ids = np.unique(data_dict["phase_id"]).astype(int)
    data_dict["phase_list"] = PhaseList(
        names=phase_names,
        symmetries=symmetries,
        structures=structures,
        ids=unique_phase_ids,
    )

    # Set which data points are not indexed
    if vendor == "tsl":
        data_dict["phase_id"][np.where(data_dict["prop"]["ci"] == -1)] = -1
    # TODO: Add not-indexed convention for INDEX ASTAR

    # Set scan unit
    if vendor in ["tsl", "emsoft"]:
        scan_unit = "um"
    else:  # NanoMegas
        scan_unit = "nm"