""" Export selection as ang file """ import matplotlib.pyplot as plt import pyebsd from builtins import input import os angfile = os.path.join('..', 'data', 'ADI_bcc_fcc.ang') scan = pyebsd.load_scandata(angfile) # enable matplotlib interactive mode plt.ion() # plot IPF ipf = scan.plot_IPF(gray=scan.IQ, sel=scan.ph == 2) # enable lasso selector ipf.lasso_selector() key = input('Press ENTER to process selected data ') # disable interactive mode plt.ioff() # plot ipf of the selection ipfsel = scan.plot_IPF(sel=ipf.sel, gray=scan.IQ) # save selection as selection.ang scan.save_ang_file('selection.ang', ipf.sel) # This also works: # pyebsd.save_ang_file('selection.ang', scan, ipf.sel)
from builtins import input import pyebsd if 'fname_local' not in locals() or 'fname_local' not in globals(): fname_local = '' # fname = os.path.join('..', 'data', 'ADI_bcc_fcc.ang') fname = os.path.join('..', 'data', 'QP_bcc_fcc_single_austenite_grain.ang') basename = os.path.basename(fname) basename = os.path.splitext(basename)[0] if fname != fname_local: fname_local = fname scan = pyebsd.load_scandata(fname_local) plt.ion() ipf0 = scan.plot_IPF(gray=scan.IQ, d=[0, 0, 1]) # ipf0.fig.savefig(basename + '_IPF.pdf', bbox_inches='tight', pad_inches=0) plt.close(ipf0.fig) phmap = scan.plot_phase(gray=scan.IQ) # phmap.fig.savefig(basename + '_ph.pdf', bbox_inches='tight', pad_inches=0) plt.close(phmap.fig) ipf = scan.plot_IPF(sel=(scan.ph == 2) & (scan.CI > .2), gray=scan.IQ, d=[0, 0, 1]) fig = ipf.fig
Lasso selector to select areas """ import matplotlib.pyplot as plt import pyebsd from builtins import input import os # .ang file available in the data folder # Replace angfile variable with the path to your .ang file angfile = os.path.join('..', 'data', 'ADI_bcc_fcc.ang') # load ebsd scandata # So far, pyebsd only supports loading .ang files generated # by the TSL OIM software scan = pyebsd.load_scandata(angfile) # Enable matplotlib.pyplot interactive node, which means # that the plots open automatically and do not interrupt # the python interpreter. # If plt.ion() is not called, you must to run plt.show() # after calling pyebsd plot functions. plt.ion() # Plot IPF map for only the fcc phase (ph == 2) ipf = scan.plot_IPF(sel=(scan.ph == 2), gray=scan.IQ) # Enable lasso_selector. Click with the mouse in the open IPF # plot and select an area. # Use the left button to create a new vertex and the right button
data.drop(columns='level_0', inplace=True) except: pass try: data.drop(columns='index', inplace=True) except: pass return nrows - 1 if __name__ == '__main__': fname = os.path.join('..', 'data', 'ADI_bcc_fcc_cropped.ang') kwargs = dict(tiling='hex') # Test 1: ncols_odd > ncols_even and odd number of rows scan1 = pyebsd.load_scandata(fname) plot_tests(scan1, **kwargs) # Test 2: ncols_odd > ncols_even and even number of rows data = scan1.data.copy() nrows, ncols_odd, ncols_even = scan1.nrows, scan1.ncols_odd, scan1.ncols_even nrows = drop_last_row(data, nrows, ncols_odd, ncols_even) scan2 = pyebsd.ScanData(data, 'HexGrid', scan1.dx, scan1.dy, ncols_odd, ncols_even, nrows, scan1.header) plot_tests(scan2, **kwargs) # Test 3: ncols_odd < ncols_even and odd number of rows data = scan1.data.copy() nrows, ncols_odd, ncols_even = scan1.nrows, scan1.ncols_odd, scan1.ncols_even # drops last column in a odd row twice ncols_odd, ncols_even = drop_first_and_last_columns(
# -*- coding: utf-8 -*- """ [1] C. Moussa, M. Bernacki, R. Besnard, N. Bozzolo, Ultramicroscopy 179 (2017) 63–72. """ import os import numpy as np import matplotlib.pyplot as plt import pyebsd if __name__ == '__main__': scan = pyebsd.load_scandata( os.path.join('..', 'data', 'ADI_bcc_fcc_cropped.ang')) selection = (scan.ph == 1) # Selects phase indexed as 1 indices, = np.where(selection) distance = [] # real distance in (normally um) to n-th nearest neighbor kam = [] # list with KAM values for every pixel for each distance convention, maxmis, nneighbors = 'OIM', 5., 5 # convention, maxmis, nneighbors = 'fixed', 5., 15 for d in range(1, nneighbors + 1): distance.append( scan.get_distance_neighbors(distance=d, distance_convention=convention)) kam.append( scan.get_KAM(distance=d, distance_convention=convention, sel=selection, maxmis=maxmis))