From 453f4fdfe026c9982eae28338d33f5309cbff2f7 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 25 Sep 2015 08:02:08 +0200 Subject: [PATCH] worked on --- 15_brasil/matlab/ebsdExample.m | 28 +++++--- 15_brasil/matlab/exercises.m | 36 ++++++++-- 15_brasil/matlab/grainExample.m | 105 ++++++++++++++++++++++++----- 15_brasil/matlab/grainExercises.m | 2 +- 15_brasil/matlab/odfExample.m | 30 +++++++-- 15_brasil/matlab/twinningExample.m | 4 +- 6 files changed, 167 insertions(+), 38 deletions(-) diff --git a/15_brasil/matlab/ebsdExample.m b/15_brasil/matlab/ebsdExample.m index 7674e70..cca483e 100644 --- a/15_brasil/matlab/ebsdExample.m +++ b/15_brasil/matlab/ebsdExample.m @@ -22,6 +22,9 @@ ebsd = loadEBSD('Forsterite.ctf','convertEuler2SpatialReferenceFrame') +ebsd = reduce(ebsd,4) + + %% plot phase information % adjust plotting convention @@ -40,11 +43,11 @@ plot(ebsd,ebsd.bc) -%mtexColorMap black2white -%mtexColorbar +mtexColorMap black2white +mtexColorbar -% gcm % this is the current MTEX figure object -%CLim(gcm,[0,150]) +gcm; % this is the current MTEX figure object +CLim(gcm,[0,150]) %% visualize orientations @@ -56,6 +59,8 @@ % visualize the color map plot(oM) +set(gcf,'renderer','zBuffer') + %% @@ -78,8 +83,8 @@ %% the inverse -plotIPDF(ori,colors,[vector3d.X, vector3d.Y, vector3d.Z],... - 'points',250,'MarkerSize',7,'MarkerEdgeColor','k') +plotIPDF(ori,[xvector,yvector,zvector],... + 'points',250,'MarkerSize',7,'MarkerEdgeColor','k','property',colors) %% combine with other plots @@ -100,6 +105,9 @@ %% remove data according to properties +plot(ebsd(ebsd.bc<50),'Facecolor','r') + +%% ebsd(ebsd.bc<50).phase = 0; plot(ebsd) @@ -125,13 +133,17 @@ %% rotate the data set -rot = rotation('axis',zvector,'angle',2*degree); +rot = rotation('axis',zvector,'angle',20*degree); plot(rotate(ebsd_roi,rot)) %% -plot(ebsd,ebsd.KAM) +plot(ebsd,ebsd.KAM('threshold',5*degree)) CLim(gcm,[0,0.1]) +%% + +plot(reduce(ebsd,4)) + diff --git a/15_brasil/matlab/exercises.m b/15_brasil/matlab/exercises.m index 0249fa9..20f4dc4 100644 --- a/15_brasil/matlab/exercises.m +++ b/15_brasil/matlab/exercises.m @@ -75,14 +75,40 @@ % a) plot the misorientation angle to the reference orientation % (104,90,175) % -% b) plot the misorientation angle to the mean orientation -% (104,90,175) -% -% c) use an ipf key with inverse pole figure direction such that the mean + +ori_ref = orientation('Euler',104*degree,90*degree,175*degree,ebsd('Fo').CS); + +omega = angle(ori_ref, ebsd('Fo').orientations); + +plot(ebsd('fo'),omega./degree) + +CLim(gcm,[0,2.5]) + +%% b) plot the misorientation angle to the mean orientation +% + +ori_ref = mean(ebsd('Fo').orientations) + +omega = angle(ori_ref, ebsd('Fo').orientations); + +plot(ebsd('fo'),omega./degree) + +CLim(gcm,[0,2.5]) + +%% c) use an ipf key with inverse pole figure direction such that the mean % orientation is colored white % % useful commands: angle, caxis, ipdfHSVOrientationMapping, -% + +oM = ipdfHSVOrientationMapping(ebsd('Fo')); + +oM.inversePoleFigureDirection = zvector; +oM.whiteCenter = inv(mean(ebsd('Fo').orientations)) * zvector +oM.maxAngle = 2.5*degree + +plot(ebsd('Fo'),oM.orientation2color(ebsd('Fo').orientations)); + + %% % a) diff --git a/15_brasil/matlab/grainExample.m b/15_brasil/matlab/grainExample.m index 684df00..2fcace3 100644 --- a/15_brasil/matlab/grainExample.m +++ b/15_brasil/matlab/grainExample.m @@ -26,11 +26,11 @@ mtexdata forsterite plot(ebsd) -poly = selectPolygon +%poly = selectPolygon %% -% poly = [5 2 10 5]*10^3 +poly = [5 2 10 5]*10^3 ebsd = ebsd(ebsd.inpolygon(poly)); plot(ebsd) @@ -51,13 +51,35 @@ % stop overide mode hold off +%% + +[m,id] = max(grains.area) + +plot(grains) +hold on +plot(grains(id).boundary,'linecolor','y','linewidth',2) +hold off + + +%plot(grains,grains.area) + + %% -ebsd(grains(33)) +ebsd(grains(id)) + +plot(ebsd(grains(id)),ebsd(grains(id)).mis2mean.angle ./ degree) + +hold on +plot(grains(id).boundary) +hold off + % ebsd(ebsd.grainId == 33) %equivalent to the command %% Grain properties +% shapeFactor boundarySize aspectRatio diameter perimeter hasHole grainSize +% neighbors pricipal components plot(grains,grains.shapeFactor) @@ -66,6 +88,9 @@ %plot(grains,grains.area) +hist(grains.area) + +%% hist(grains) @@ -76,11 +101,24 @@ plot(grains) hold on -plot(x,y,'o','markerFaceColor','r') -%idString = cellstr(int2str(largeGrains.id)); -%text(x,y,idString) +%plot(x,y,'o','markerFaceColor','r') +idString = cellstr(int2str(largeGrains.id)); +text(x,y,idString) +hold off + +%% direction of the grains + +plot(grains) + +pc = largeGrains.principalComponents; + +hold on +u = pc(1,1,:); +v = pc(2,1,:); +quiver(x,y,u(:),v(:),0.5,'color','k','linewidth',2); hold off + %% Misorientation to mean orientation plot(ebsd,ebsd.mis2mean.angle ./ degree) @@ -104,7 +142,7 @@ hold on plot(ebsd(myGrain),ebsd(myGrain).mis2mean.angle ./ degree) hold off -%colorbar +mtexColorbar %% Filling not indexed holes @@ -197,6 +235,30 @@ % stop overide mode hold off +%% + +onePixelGrains = grains(grains.grainSize == 1) + +%plot(onePixelGrains) + +ebsd_corrected = ebsd; + +ebsd_corrected(onePixelGrains) = []; + +%% + +[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd) + +onePixelGrains = grains(grains.grainSize == 1) + +plot(grains) + + +%% + + + + %% Grain smoothing % The reconstructed grains show the typicaly staircase effect. This effect % can be reduced by smoothing the grains. This is particulary important @@ -255,14 +317,18 @@ figure(1) plot(grains(931).boundary) +%% + +grains.boundary('indexed') + %% % lets combine it with the orientation measurements inside % define the colorcoding such that the meanorientation becomes white oM = ipdfHSVOrientationMapping(grains(931)); %oM.inversePoleFigureDirection = grains(931).meanOrientation * oM.whiteCenter; -%oM.whiteCenter = inv(grains(931).meanOrientation) * oM.inversePoleFigureDirection -%oM.maxAngle = 10*degree; +oM.whiteCenter = inv(grains(931).meanOrientation) * oM.inversePoleFigureDirection +oM.maxAngle = 10*degree; figure(2), plot(oM,'resolution',0.5*degree) % get the ebsd data of grain 931 @@ -299,8 +365,8 @@ legend off hold on plot(gB_Fo,gB_Fo.misorientation.angle./degree,'linewidth',1.5) +mtexColorbar hold off -%colorbar %% Classifing special boundaries @@ -308,20 +374,27 @@ mAngle = gB_Fo.misorientation.angle./ degree; -hist(mAngle) +hist(mAngle,20) -[~,id] = histc(mAngle,0:30:120); +gB_Fo(angle(gB_Fo.misorientation,CSL(3))<3*degree) +%% +plot(grains,'facealpha',0.3) +hold on +plot(gB_Fo(mAngle > 58 & mAngle < 63),'linewidth',3,'linecolor','r') +hold off %% plot(grains.boundary,'linecolor','k') +[~,id] = histc(mAngle,0:30:120); + hold on -plot(gB_Fo(id==1),'linecolor','b','linewidth',2,'DisplayName','>40^\circ') -plot(gB_Fo(id==2),'linecolor','g','linewidth',2,'DisplayName','20^\circ-40^\circ') -plot(gB_Fo(id==3),'linecolor','r','linewidth',2,'DisplayName','10^\circ-20^\circ') -plot(gB_Fo(id==4),'linecolor','m','linewidth',2,'DisplayName','< 10^\circ') +plot(gB_Fo(id==1),'linecolor','b','linewidth',2,'DisplayName','>90^\circ') +plot(gB_Fo(id==2),'linecolor','g','linewidth',2,'DisplayName','60^\circ-90^\circ') +plot(gB_Fo(id==3),'linecolor','r','linewidth',2,'DisplayName','30^\circ-60^\circ') +plot(gB_Fo(id==4),'linecolor','m','linewidth',2,'DisplayName','< 30^\circ') hold off diff --git a/15_brasil/matlab/grainExercises.m b/15_brasil/matlab/grainExercises.m index 537aeed..15fb392 100644 --- a/15_brasil/matlab/grainExercises.m +++ b/15_brasil/matlab/grainExercises.m @@ -55,7 +55,7 @@ %% Exercise 6 -% Find all CSL(3) boundaries with the list of iron to iron grain +% Find all CSL(3) boundaries within the list of iron to iron grain % boundaries. As a threshold use 3 degree. % What is the relative length of CSL(3) grain boundaries in comparison to % all iron to iron grain boundaries? diff --git a/15_brasil/matlab/odfExample.m b/15_brasil/matlab/odfExample.m index ea8dcfc..7111f4c 100644 --- a/15_brasil/matlab/odfExample.m +++ b/15_brasil/matlab/odfExample.m @@ -46,12 +46,12 @@ %% plot measurements in orientation space -plotSection(ebsd.orientations,'sections',6) -%plotSection(ebsd.orientations,'sections',6,'contourf','all') % this takes some time +%plotSection(ebsd.orientations,'sections',6) +plotSection(ebsd.orientations,'sections',6,'contourf','all') % this takes some time %% compute an ODF from the EBSD data -odf = calcODF(ebsd.orientations,'halfwidth',5*degree) +odf = calcODF(ebsd.orientations,'halfwidth',7.5*degree) %% and plot it in the traditional way @@ -67,6 +67,25 @@ plotPDF(odf,Miller({1,0,0},{0,1,0},{0,0,1},odf.CS)) +%% + +plotIPDF(odf,xvector,odf.CS) + +%% + +ori = calcModes(odf,2) + +%% + +plot(odf,'sections',12) + +%% + +hold on +plot(ori,'MarkerFaceColor','k','marker','s') +hold off + + %% what is the volume of the fibre % there seems to be a fibre visible in (010) pole figure @@ -152,11 +171,10 @@ %% maybe we should use a histogram -y = randomPoints(400); +y = randomPoints(400000); hist(y,100) - %% not so good, it is not smooth at all, other idea: kernel density estimators clf @@ -167,7 +185,7 @@ % some discretisation x = linspace(0,1,500); -s = 0.02; +s = 0.2; z = zeros(1,length(x)); ssz = []; diff --git a/15_brasil/matlab/twinningExample.m b/15_brasil/matlab/twinningExample.m index a11a6da..9e27f75 100644 --- a/15_brasil/matlab/twinningExample.m +++ b/15_brasil/matlab/twinningExample.m @@ -63,7 +63,7 @@ %% compute the misorientation between two grains -mori = inv(grains(65).meanOrientation) * grains(74).meanOrientation; +mori = inv(grains(65).meanOrientation) * grains(74).meanOrientation %% select twinning boundaries @@ -87,7 +87,7 @@ %% Other properties that might help to identify grain boundaries % a shortcut: check for twinning -gBM2M.isTwinning(twinMori,5*degree) +gBM2M.isTwinning(twinMori,5*degree); % the direction - antipodal!! gBM2M.direction