{ "cells": [ { "cell_type": "code", "execution_count": 3, "metadata": { "pycharm": { "is_executing": false } }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "from defdap.quat import Quat\n", "import defdap.ebsd as ebsd\n", "\n", "from defdap.plotting import PolePlot\n", "\n", "%matplotlib qt" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "pycharm": { "is_executing": false } }, "outputs": [ { "name": "stdout", "text": [ "Loaded EBSD data (dimensions: 285 x 276 pixels, step size: 5.0 um)\n", "Finding grains...new flood 7 \n", "Done " ], "output_type": "stream" } ], "source": [ "EbsdFilePath = \"/Users/mbcx9ma4/Dropbox (The University of Manchester)/Beta Reconstruction/data/triple_point/ZrNb_triplepoint_alpha\"\n", "\n", "EbsdMap = ebsd.Map(EbsdFilePath, \"hexagonal\")\n", "EbsdMap.buildQuatArray()\n", "\n", "boundaryMisOri = 3.\n", "\n", "EbsdMap.findBoundaries(boundDef=boundaryMisOri)\n", "EbsdMap.findGrains(minGrainSize=2)" ] }, { "cell_type": "code", "execution_count": 9, "outputs": [ { "name": "stdout", "text": [ "Done 2.3 s ± 30.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n" ], "output_type": "stream" } ], "source": [ "%timeit EbsdMap.findGrains(minGrainSize=2)" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n", "is_executing": false } } }, { "cell_type": "code", "execution_count": 5, "metadata": { "pycharm": { "is_executing": false } }, "outputs": [ { "data": { "text/plain": "" }, "metadata": {}, "output_type": "execute_result", "execution_count": 5 } ], "source": [ "EbsdMap.plotEulerMap(plotGBs=False)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "pycharm": { "is_executing": false } }, "outputs": [ { "data": { "text/plain": "" }, "metadata": {}, "output_type": "execute_result", "execution_count": 6 } ], "source": [ "plt.figure()\n", "plt.imshow(-EbsdMap.boundaries)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plt.figure()\n", "plt.imshow(EbsdMap.misOriY > 8.)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "pycharm": { "is_executing": false } }, "outputs": [], "source": [ "boundaryPoints = np.where(EbsdMap.misOriX > boundaryMisOri)\n", "boundarySegmentsX = []\n", "for i, j in zip(*boundaryPoints):\n", " boundarySegmentsX.append( ((j+0.5, i-0.5), (j+0.5, i+0.5)) )\n", " " ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "pycharm": { "is_executing": false } }, "outputs": [], "source": [ "boundaryPoints = np.where(EbsdMap.misOriY > boundaryMisOri)\n", "boundarySegmentsY = []\n", "for i, j in zip(*boundaryPoints):\n", " boundarySegmentsY.append( ((j-0.5, i+0.5), (j+0.5, i+0.5)) )\n", " " ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "boundaryPoints = np.where(EbsdMap.boundaries == -1)\n", "boundarySegments = []\n", "for i, j in zip(*boundaryPoints):\n", " boundarySegments.append( ((j-0.5, i+0.5), (j+0.5, i+0.5)) )\n", " boundarySegments.append( ((j+0.5, i-0.5), (j+0.5, i+0.5)) )\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 7, "metadata": { "pycharm": { "is_executing": false } }, "outputs": [], "source": [ "import pylab as pl\n", "from matplotlib import collections as mc\n", "\n", "# plt.figure()\n", "# plt.imshow(-EbsdMap.boundaries)\n", "\n", "# EbsdMap.plotEulerMap()\n", "\n", "EbsdMap.locateGrainID()\n", "\n", "ax = plt.gca()\n", "\n", "boundarySegments = boundarySegmentsX + boundarySegmentsY\n", "lc = mc.LineCollection(boundarySegments, colors=(0,0,0,1), linewidths=2)\n", "ax.add_collection(lc)\n", "ax.autoscale()\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "EbsdMap.plotGrainMap(plotColourBar=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "boundariesX = EbsdMap.misOrix > 3.\n", "\n", "plt.imshow(boundariesX)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 0, 0, -1, ..., -1, 0, 0],\n", " [-1, 0, 0, ..., 0, 0, 0],\n", " [-1, 0, -1, ..., -1, 0, 0],\n", " ...,\n", " [ 0, -1, -1, ..., -1, -1, 0],\n", " [ 0, -1, 0, ..., -1, -1, 0],\n", " [-1, 0, -1, ..., 0, -1, 0]])" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "-boundariesX.astype(int)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n", "2\n", "[(3, 4)]\n" ] } ], "source": [ "edge = [(1, 2), (3, 4)]\n", "\n", "x, y = edge.pop(0)\n", "print(x)\n", "print(y)\n", "print(edge)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.6" }, "pycharm": { "stem_cell": { "cell_type": "raw", "source": [], "metadata": { "collapsed": false } } } }, "nbformat": 4, "nbformat_minor": 4 }