示例#1
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)
示例#2
0
from pymicro.crystal.texture import PoleFigure
from pymicro.crystal.microstructure import Microstructure, Grain, Orientation
from matplotlib import pyplot as plt

if __name__ == '__main__':
    '''
    A pole figure plotted using contours.
    '''
    eulers = Orientation.read_orientations('../data/pp100', data_type='euler')
    micro = Microstructure(name='test')
    for i in range(100):
        micro.grains.append(Grain(i + 1, eulers[i + 1]))

    pf = PoleFigure(microstructure=micro)
    pf.mksize = 40
    pf.proj = 'stereo'
    pf.set_hkl_poles('111')
    fig = plt.figure(1, figsize=(12, 5))
    ax1 = fig.add_subplot(121, aspect='equal')
    ax2 = fig.add_subplot(122, aspect='equal')
    pf.create_pf_contour(ax=ax1, ang_step=20)
    pf.plot_pf(ax=ax2)

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

    from matplotlib import image

    image.thumbnail(image_name, 'thumb_' + image_name, 0.2)