Skip to content

Commit

Permalink
worked on
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfHielscher committed Sep 25, 2015
1 parent a51c4ac commit 453f4fd
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 38 deletions.
28 changes: 20 additions & 8 deletions 15_brasil/matlab/ebsdExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
ebsd = loadEBSD('Forsterite.ctf','convertEuler2SpatialReferenceFrame')


ebsd = reduce(ebsd,4)


%% plot phase information

% adjust plotting convention
Expand All @@ -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

Expand All @@ -56,6 +59,8 @@

% visualize the color map
plot(oM)
set(gcf,'renderer','zBuffer')


%%

Expand All @@ -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
Expand All @@ -100,6 +105,9 @@

%% remove data according to properties

plot(ebsd(ebsd.bc<50),'Facecolor','r')

%%
ebsd(ebsd.bc<50).phase = 0;

plot(ebsd)
Expand All @@ -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))

36 changes: 31 additions & 5 deletions 15_brasil/matlab/exercises.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
105 changes: 89 additions & 16 deletions 15_brasil/matlab/grainExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -66,6 +88,9 @@

%plot(grains,grains.area)

hist(grains.area)

%%
hist(grains)


Expand All @@ -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)
Expand All @@ -104,7 +142,7 @@
hold on
plot(ebsd(myGrain),ebsd(myGrain).mis2mean.angle ./ degree)
hold off
%colorbar
mtexColorbar


%% Filling not indexed holes
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -299,29 +365,36 @@
legend off
hold on
plot(gB_Fo,gB_Fo.misorientation.angle./degree,'linewidth',1.5)
mtexColorbar
hold off
%colorbar

%% Classifing special boundaries

close all

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
2 changes: 1 addition & 1 deletion 15_brasil/matlab/grainExercises.m
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
30 changes: 24 additions & 6 deletions 15_brasil/matlab/odfExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -167,7 +185,7 @@
% some discretisation
x = linspace(0,1,500);

s = 0.02;
s = 0.2;
z = zeros(1,length(x));
ssz = [];

Expand Down
Loading

0 comments on commit 453f4fd

Please sign in to comment.