A PoleFigure object is then created using this microstructure and the pole figures
    (both direct and inverse) are drawn by calling the plot_pole_figures() method.
    '''
    micro = Microstructure(name='Au_6grains', overwrite_hdf5=True)
    micro.autodelete = True
    gid_list = [1158, 1349, 1585, 1805, 1833, 2268]
    euler_list = [(344.776, 52.2589, 53.9933), 
                  (344.899, 125.961, 217.330),
                  (228.039, 57.4791, 143.171),
                  (186.741, 60.333, 43.311),
                  (151.709, 55.0406, 44.1051),
                  (237.262, 125.149, 225.615),
                  ]
    micro.add_grains(euler_list, grain_ids=gid_list)

    # create pole figure (both direct and inverse)
    pf = PoleFigure(hkl='111', axis='Z', proj='stereo', microstructure=micro)
    pf.mksize = 100
    pf.set_map_field('grain_id')
    pf.pflegend = True  # this works well for a few grains
    pf.plot_pole_figures(plot_sst=True, display=False, save_as='png')
    del pf
    del micro

    image_name = os.path.splitext(__file__)[0] + '.png'
    print('writing %s' % image_name)

    from matplotlib import image

    image.thumbnail(image_name, 'thumb_' + image_name, 0.2)
Exemple #2
0
eulers = Orientation.read_orientations('../data/EBSD_20grains.txt',
                                       data_type='euler',
                                       usecols=[1, 2, 3])
grain_sizes = np.genfromtxt('../data/EBSD_20grains.txt', usecols=[9])
micro = Microstructure(name='test')
for i in range(20):
    micro.grains.append(Grain(i + 1, eulers[i + 1]))
    micro.get_grain(i + 1).volume = grain_sizes[i]

# build a custom pole figure
pf = PoleFigure(microstructure=micro, hkl='001')  #, lattice=Ti7Al)
#pf.resize_markers = True
pf.mksize = 100
pf.set_map_field('strain',
                 grain_sizes,
                 field_min_level=0.0,
                 field_max_level=1000.,
                 lut='jet')
fig = plt.figure(figsize=(8, 5))
ax1 = fig.add_axes([0.05, 0.05, 0.8, 0.9], aspect='equal')
pf.plot_sst(ax=ax1, mk='o')
ax1.set_title('%s-axis SST inverse %s projection' % (pf.axis, pf.proj))

# to add the color bar
ax2 = fig.add_axes([0.85, 0.05, 0.05, 0.9])
norm = colors.Normalize(vmin=0., vmax=1000.)
cb = colorbar.ColorbarBase(ax2, cmap=cm.jet, norm=norm, orientation='vertical')
cb.set_label('Grain size (pixels)')

image_name = os.path.splitext(__file__)[0] + '.png'
print('writting %s' % image_name)
Exemple #3
0
    poles are colored according using IPF coloring and resized proportionally 
    to each grain volume.
    """
    # create a microstructure with a random texture and 200 grains
    micro = Microstructure.random_texture(n=200)
    micro.autodelete = True

    # set random values for the grain volumes
    np.random.seed(22)
    for g in micro.grains:
        g['volume'] = 100 * np.random.random()**3
        g.update()
    micro.grains.flush()

    # first pole figure
    pf = PoleFigure(microstructure=micro)
    pf.resize_markers = True
    pf.set_hkl_poles('001')
    pf.axis = 'Z'
    pf.set_map_field('ipf')
    pf.plot_pole_figures(plot_sst=True, display=False, save_as='png')
    del pf
    del micro

    image_name = os.path.splitext(__file__)[0] + '.png'
    print('writing %s' % image_name)

    from matplotlib import image

    image.thumbnail(image_name, 'thumb_' + image_name, 0.2)
Exemple #4
0
from matplotlib import pyplot as plt, colors, colorbar, cm

'''
An inverse pole figure with symbols colored by the grain size.
'''
euler_list = np.genfromtxt('../data/EBSD_20grains.txt', usecols=[1, 2, 3]).tolist()
grain_sizes = np.genfromtxt('../data/EBSD_20grains.txt', usecols=[9])
micro = Microstructure(name='test', autodelete=True)
micro.add_grains(euler_list)
micro.set_volumes(grain_sizes)

# build a custom pole figure
pf = PoleFigure(microstructure=micro, hkl='001')#, lattice=Ti7Al)
#pf.resize_markers = True
pf.mksize = 100
pf.set_map_field('grain_size', field_min_level=0.0, field_max_level=1000., lut='jet')
fig = plt.figure(figsize=(8, 5))
ax1 = fig.add_axes([0.05, 0.05, 0.8, 0.9], aspect='equal')
pf.plot_sst(ax=ax1, mk='o')
ax1.set_title('%s-axis SST inverse %s projection' % (pf.axis, pf.proj))

# to add the color bar
ax2 = fig.add_axes([0.85, 0.05, 0.05, 0.9])
norm = colors.Normalize(vmin=0., vmax=1000.)
cb = colorbar.ColorbarBase(ax2, cmap=cm.jet, norm=norm, orientation='vertical')
cb.set_label('Grain size (pixels)')

image_name = os.path.splitext(__file__)[0] + '.png'
print('writing %s' % image_name)
plt.savefig(image_name, format='png')
del pf