{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# DefDAP Example notebook\n", "\n", "This notebook will outline basic usage of DefDAP, including loading a DIC and EBSD map, linking them with homologous points and producing maps" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load in packages" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "DefDAP is split into modules for processing EBSD (`defdap.ebsd`) and HRDIC (`defdap.hrdic`) data. There are also modules for manpulating orientations (`defdap.quat`) and creating custom figures (`defdap.plotting`) which is introduced later. We also import some of the usual suspects of the python scientific stack: `numpy` and `matplotlib`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "import defdap.hrdic as hrdic\n", "import defdap.ebsd as ebsd\n", "from defdap.quat import Quat\n", "\n", "# try tk, qt, osx (if using mac) or notebook for interactive plots. If none work, use inline\n", "%matplotlib tk" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load in a HRDIC map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicFilePath = \"../tests/data/\"\n", "dicMap = hrdic.Map(dicFilePath, \"testDataDIC.txt\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set the scale of the map\n", "This is defined as the pixel size in the DIC pattern images, measured in microns per pixel." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fieldWidth = 20 # microns\n", "numPixels = 2048\n", "pixelSize = fieldWidth / numPixels\n", "\n", "dicMap.setScale(pixelSize)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot the map with a scale bar" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.plotMaxShear(vmin=0, vmax=0.10, plotScaleBar=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Crop the map\n", "HRDIC maps often contain spurious data at the edges which should be removed before performing any analysis. The crop is defined by the number of points to remove from each edge of the map, where `xMin`, `xMax`, `yMin` and `yMax` are the left, right, top and bottom edges respectively. Note that the test data doesn not require cropping as it is a subset of a larger dataset." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.setCrop(xMin=0, xMax=0, yMin=0, yMax=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Statistics\n", "Some simple statistics such as the minimum, mean and maximum of the effective shear strain, E11 and E22 components can be printed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.printStatsTable(percentiles=[0, 50, 100], components = ['eMaxShear', 'e11', 'e22', 'e12'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set the location of the DIC pattern images \n", "The pattern images are used later to define the position of homologous material points. The path is relative to the directory set when loading in the map. The second parameter is the pixel binning factor of the image relative to the DIC sub-region size i.e. the number of pixels in the image across a single datapoint in the DIC map. We recommend binning the pattern images by the same factor as the DIC sub-region size, doing so enhances the contrast between microstructure features." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# set the path of the pattern image, this is relative to the location of the DIC data file\n", "dicMap.setPatternPath(\"testDataPat.bmp\", 1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load in an EBSD map\n", "The crystal structure of each phase is read from file and used to set the slip systems for the phase. The orientation in the EBSD are converted to a quaternion representation so calculations can be applied later." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdFilePath = \"../tests/data/testDataEBSD\"\n", "\n", "ebsdMap = ebsd.Map(ebsdFilePath)\n", "ebsdMap.buildQuatArray()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot the EBSD map\n", "Using an Euler colour mapping or inverse pole figure colouring with the sample reference direction passed as a vector." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.plotEulerMap(plotScaleBar=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.plotIPFMap([1,0,0], plotScaleBar=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A KAM map can also be plotted as follows" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.plotKamMap(vmin=0, vmax=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Detect grains in the EBSD\n", "This is done in two stages: first bounaries are detected in the map as any point with a misorientation to a neighbouring point greater than a critical value (`boundDef` in degrees). A flood fill type algorithm is then applied to segment the map into grains, with any grains containining fewer than a critical number of pixels removed (`minGrainSize` in pixels). The data e.g. orientations associated with each grain are then stored (referenced strictly, the data isn't stored twice) in a grain object and a list of the grains is stored in the EBSD map (named `grainList`). This allows analysis routines to be applied to each grain in a map in turn." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.findBoundaries(boundDef=8)\n", "ebsdMap.findGrains(minGrainSize=10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A list of the slip planes, colours and slip directions can be printed for each phase in the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "phase = ebsdMap.phases[0]\n", "print(phase.name)\n", "phase.printSlipSystems()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The Schmid factors for each grain can be calculated and plotted. The `slipSystems` argument can be specified, to only calculate the Schmid factor for certain planes, otherwise the maximum for all slip systems is calculated." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.calcAverageGrainSchmidFactors(loadVector=np.array([1,0,0]), slipSystems=None)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.plotAverageGrainSchmidFactorsMap()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Single grain analysis\n", "The `locateGrainID` method allows interactive selection of a grain of intereset to apply any analysis to. Clicking on grains in the map will highlight the grain and print out the grain ID (position in the grain list) of the grain." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.locateGrainID()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A built-in example is to calculate the average orientation of the grain and plot this orientation in a IPF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grainID = 48\n", "grain = ebsdMap[grainID]\n", "grain.calcAverageOri() # stored as a quaternion named grain.refOri\n", "print(grain.refOri)\n", "grain.plotRefOri(direction=[0, 0, 1])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The spread of orientations in a given grain can also be plotted on an IPF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot = grain.plotOriSpread(direction=np.array([0, 0, 1]), c='b', s=1, alpha=0.2)\n", "grain.plotRefOri(direction=[0, 0, 1], c='k', plot=plot)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The unit cell for the average grain orientation can also be ploted" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grain.plotUnitCell()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Printing a list of the slip plane indices, angle of slip plane intersection with the screen (defined as counter-clockwise from upwards), colour defined for the slip plane and also the slip directions and corresponding Schmid factors, is also built in" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grain.printSlipTraces()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A second built-in example is to calcuate the grain misorientation, specifically the grain reference orientation deviation (GROD). This shows another feature of the `locateGrainID` method, which stores the ID of the last selected grain in a variable called `currGrainId` in the EBSD map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grain = ebsdMap[ebsdMap.currGrainId]\n", "grain.buildMisOriList()\n", "grain.plotMisOri(plotScaleBar=True, vmin=0, vmax=5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Multi grain analysis\n", "Once an analysis routine has been prototyped for a single grain it can be applied to all the grains in a map using a loop over the grains and any results added to a list for use later. Of couse you could also apply to a smaller subset of grains as well." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grainAvOris = []\n", "for grain in ebsdMap:\n", " grain.calcAverageOri()\n", " grainAvOris.append(grain.refOri)\n", "\n", "# Plot all the grain orientations in the map\n", "Quat.plotIPF(grainAvOris, [0, 0, 1], ebsdMap.crystalSym, marker='o', s=10)\n", "plt.tight_layout()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some common grain analysis routines are built into the EBSD map object, including:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.calcGrainAvOris()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.calcGrainMisOri()\n", "ebsdMap.plotMisOriMap(vmin=0, vmax=5, plotGBs=True, plotScaleBar=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are also methods for plotting GND density, phases and boundaries. All of the plotting functions in DefDAP use the same parameters to modify the plot, examples seen so far are `plotGBs`, `plotScaleBar`, `vmin`, `vmax`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Linking the HRDIC and EBSD\n", "### Define homologous points\n", "To register the two datasets, homologous points (points at the same material location) within each map are used to estimate a transformation between the two frames the data are defined in. The homologous points are selected manually using an interactive tool within DefDAP. To select homologous call the method `setHomogPoint` on each of the data maps, which will open a plot window with a button labelled 'save point' in the bottom right. You select a point by right clicking on the map, adjust the position with the arrow and accept the point by with the save point button. Then select the same location in the other map. Note that as we set the location of the pattern image for the HRDIC map that the points can be selected on the pattern image rather than the strain data." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.setHomogPoint(display=\"pattern\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.setHomogPoint()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The points are stored as a list of tuples `(x, y)` in each of the maps. This means the points can be set from previous values." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.homogPoints" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.homogPoints" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here are some example homologous points for this data, after setting these by running the cells below you can view the locations in the maps by running the `setHomogPoint` methods (above) again" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.homogPoints = [\n", " (36, 72), \n", " (279, 27), \n", " (162, 174), \n", " (60, 157)\n", "]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ebsdMap.homogPoints = [\n", " (68, 95), \n", " (308, 45), \n", " (191, 187), \n", " (89, 174)\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Link the maps\n", "Finally the two data maps are linked. The type of transform between the two frames can be affine, projective, polynomial." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.linkEbsdMap(ebsdMap, transformType=\"affine\")\n", "# dicMap.linkEbsdMap(ebsdMap, transformType=\"projective\")\n", "# dicMap.linkEbsdMap(ebsdMap, transformType=\"polynomial\", order=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Show the transformation" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from skimage import transform as tf\n", "\n", "data = np.zeros((2000, 2000), dtype=float)\n", "data[500:1500, 500:1500] = 1.\n", "dataWarped = tf.warp(data, dicMap.ebsdTransform)\n", "\n", "fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8,4))\n", "ax1.set_title('Reference')\n", "ax1.imshow(data)\n", "ax2.set_title('Transformed')\n", "ax2.imshow(dataWarped)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Segment into grains\n", "The HRDIC map can now be segmented into grains using the grain boundaries detected in the EBSD map. Analysis rountines can then be applied to individual grain, as with the EBSD grains. The grain finding process will also attempt to link the grains between the EBSD and HRDIC and each grain in the HRDIC has a reference (`ebsdGrain`) to the corrosponding grain in the EBSD map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.findGrains(minGrainSize=10)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.plotMaxShear(vmin=0, vmax=0.1, plotScaleBar=True, plotGBs=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, a grain can also be selected interactively in the DIC map, in the same way a grain can be selected from an EBSD map. If `displaySelected` is set to true, then a pop-out window shows the map segmented for the grain" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicMap.locateGrainID(displaySelected=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plotting examples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some of the plotting features are shown in examples below." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Built-in plots" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot = dicMap.plotMaxShear(\n", " vmin=0, vmax=0.1, plotScaleBar=True,\n", " plotGBs=True, dilateBoundaries=True\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot = ebsdMap.plotEulerMap(\n", " plotScaleBar=True, plotGBs=True,\n", " highlightGrains=[10, 20, 45], highlightAlpha=0.9, highlightColours=['y']\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicGrainID = 41\n", "dicGrain = dicMap[dicGrainID]\n", "\n", "plot = dicGrain.plotMaxShear(\n", " plotScaleBar=True, plotSlipTraces=True, plotSlipBands=True\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### IPF plotting" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This plot will show the positions of selected grains in an IPF pole figure, with the marker size representing grain area and mean effective shear strain." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# For all grains in the DIC map\n", "\n", "# Make an array of quaternions\n", "grainOris = [grain.ebsdGrain.refOri for grain in dicMap]\n", "\n", "# Make an array of grain area\n", "grainAreas = np.array([len(grain) for grain in dicMap]) * dicMap.scale**2\n", "\n", "# Scaling the grain area, so that the maximum size of a marker is 200 points^2\n", "grainAreaScaling = 200. / grainAreas.max()\n", "\n", "# Make an array of mean effective shear strain\n", "grainStrains = [np.array(grain.maxShearList).mean() for grain in dicMap]\n", "\n", "plot = Quat.plotIPF(grainOris, direction=[1,0,0], symGroup='cubic', marker='o', \n", " s=grainAreas*grainAreaScaling, vmin=0, vmax=0.018, cmap='viridis', c=grainStrains)\n", "plot.addColourBar(label='Mean Effective Shear Strain')\n", "plot.addLegend(scaling=grainAreaScaling)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# For selected grains in the DIC map\n", "\n", "# Select grains from the DIC map\n", "dicGrainIDs = [2, 5, 7, 9, 15, 17, 18, 23, 29, 32, 33, 37, 40, 42, 49, 50, 51, 54, 58, 60]\n", "\n", "# Make an array of quaternions\n", "grainOris = np.array([dicMap[grainID].ebsdGrain.refOri for grainID in dicGrainIDs])\n", "\n", "# Make an array of grain area\n", "grainAreas = np.array([len(dicMap[grainID]) for grainID in dicGrainIDs]) * dicMap.scale**2\n", "\n", "# Scaling the grain area, so that the maximum size of a marker is 200 points^2\n", "grainAreaScaling = 200. / grainAreas.max()\n", "\n", "# Make an array of mean effective shear strain\n", "grainStrains = np.array([np.mean(dicMap[grain].maxShearList) for grain in dicGrainIDs])\n", "\n", "plot = Quat.plotIPF(grainOris, direction=[1,0,0], symGroup='cubic', marker='o', \n", " s=grainAreas*grainAreaScaling, vmin=0, vmax=0.018, cmap='viridis', c=grainStrains)\n", "plot.addColourBar(label='Mean Effective Shear Strain')\n", "plot.addLegend(scaling=grainAreaScaling)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create your own" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from defdap.plotting import MapPlot, GrainPlot, HistPlot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mapData = dicMap.e11\n", "mapData = dicMap.crop(mapData)\n", "\n", "plot = MapPlot.create(\n", " dicMap, mapData,\n", " vmin=-0.1, vmax=0.1, plotColourBar=True, cmap=\"seismic\",\n", " plotGBs=True, dilateBoundaries=True, boundaryColour='black'\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.addScaleBar()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Functions for grain averaging and grain segmentation" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot = dicMap.plotGrainDataMap(\n", " mapData,\n", " vmin=-0.06, vmax=0.06, plotColourBar=True,\n", " cmap=\"seismic\", clabel=\"Axial strain ($e_11$)\",\n", " plotScaleBar=True\n", ")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.addGrainBoundaries(dilate=True, colour=\"white\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot = dicMap.plotGrainDataIPF(\n", " np.array((1,0,0)), mapData, marker='o',\n", " vmin=-0.06, vmax=0.06, plotColourBar=True, \n", " clabel=\"Axial strain ($e_11$)\", cmap=\"seismic\",\n", ")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dicGrainID = 41\n", "dicGrain = dicMap[dicGrainID]\n", "\n", "plot = dicGrain.plotGrainData(\n", " mapData, \n", " vmin=-0.1, vmax=0.1, plotColourBar=True, \n", " clabel=\"Axial strain ($e_11$)\", cmap=\"seismic\",\n", " plotScaleBar=True\n", ")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.addSlipTraces()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Composite plots" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By utilising some additional functionality within matplotlib, composite plots can be produced." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib import gridspec" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create a figure with 3 sets of axes\n", "fig = plt.figure(figsize=(8, 4))\n", "gs = gridspec.GridSpec(2, 2, width_ratios=[3, 1],\n", " wspace=0.15, hspace=0.15, \n", " left=0.02, right=0.98,\n", " bottom=0.12, top=0.95) \n", "ax0 = plt.subplot(gs[:, 0])\n", "ax1 = plt.subplot(gs[0, 1])\n", "ax2 = plt.subplot(gs[1, 1])\n", "\n", "\n", "# add a strain map\n", "plot0 = dicMap.plotMaxShear(\n", " ax=ax0, fig=fig, \n", " vmin=0, vmax=0.08, plotScaleBar=True, \n", " plotGBs=True, dilateBoundaries=True\n", ")\n", "\n", "# add an IPF of grain orientations\n", "dicOris = []\n", "for grain in dicMap:\n", " if len(grain) > 20:\n", " dicOris.append(grain.refOri)\n", "plot1 = Quat.plotIPF(\n", " dicOris, np.array((1,0,0)), 'cubic', \n", " ax=ax1, fig=fig, s=10\n", ")\n", "\n", "# add histrogram of strain values\n", "plot2 = HistPlot.create(\n", " dicMap.crop(dicMap.eMaxShear),\n", " ax=ax2, fig=fig, marker='o', markersize=2,\n", " axesType=\"logy\", bins=50, range=(0,0.06)\n", ")\n", "plot2.ax.set_xlabel(\"Effective shear strain\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Figures can be saved to raster (png, jpg, ..) and vector formats (eps, svg), the format is guessed from the file extension given. The last displayed figure can be saved using:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.savefig(\"test_save_fig.png\", dpi=200)\n", "plt.savefig(\"test_save_fig.eps\", dpi=200)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ((ax0, ax1), (ax2, ax3)) = plt.subplots(2, 2, figsize=(8, 6))\n", "\n", "dicGrainID = 41\n", "dicGrain = dicMap[dicGrainID]\n", "\n", "# add a strain map\n", "plot0 = dicGrain.plotMaxShear(\n", " ax=ax0, fig=fig, \n", " vmin=0, vmax=0.08, plotScaleBar=True,\n", " plotSlipTraces=True\n", ")\n", "\n", "\n", "# add a misorientation\n", "ebsdGrain = dicGrain.ebsdGrain\n", "plot1 = ebsdGrain.plotMisOri(component=0, ax=ax1, fig=fig, vmin=0, vmax=1, clabel=\"GROD\", plotScaleBar=True)\n", "\n", "\n", "# add an IPF\n", "plot2 = ebsdGrain.plotOriSpread(\n", " direction=np.array((1,0,0)), c='b', s=1, alpha=0.2,\n", " ax=ax2, fig=fig\n", ")\n", "ebsdGrain.plotRefOri(\n", " direction=np.array((1,0,0)), c='k', s=100, plot=plot2\n", ")\n", "\n", "# add histrogram of strain values\n", "plot3 = HistPlot.create(\n", " dicMap.crop(dicMap.eMaxShear),\n", " ax=ax3, fig=fig,\n", " axesType=\"logy\", bins=50, range=(0,0.06))\n", " \n", "plot3.ax.set_xlabel(\"Effective shear strain\")\n", "\n", "\n", "plt.tight_layout()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.4" } }, "nbformat": 4, "nbformat_minor": 4 }