Skip to content

Commit

Permalink
Merge pull request #100 from ralfHielscher/master
Browse files Browse the repository at this point in the history
MTEX 4.1.3
  • Loading branch information
ralfHielscher committed Sep 30, 2015
2 parents 714966a + 51ab28b commit 51dbd18
Show file tree
Hide file tree
Showing 22 changed files with 471 additions and 67 deletions.
2 changes: 1 addition & 1 deletion EBSDAnalysis/@EBSD/private/spatialDecomposition.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

dummyCoordinates = calcBoundary(X,unitCell,varargin{:});

[V,D] = voronoin([X;dummyCoordinates],{'Q5','Q6'});
[V,D] = voronoin([X;dummyCoordinates],{'Q5','Q6','QJ'});

D = D(1:size(X,1));

Expand Down
13 changes: 13 additions & 0 deletions EBSDAnalysis/@EBSD/reduce.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
function ebsd = reduce(ebsd,fak)
% reduce ebsd data by a factor
%
%
% Syntax
% ebsd = reduce(ebsd,2) % take every second pixel horiz. and vert.
% ebsd = reduce(ebsd,3) % take every third pixel horiz. and vert.
%
% Input
% ebsd - @EBSD
%
% Output
% ebsd - @EBSD
%

% generate regular grid
ext = ebsd.extend;
Expand Down
7 changes: 6 additions & 1 deletion EBSDAnalysis/@EBSD/smooth.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [ebsd,filter] = smooth(ebsd,varargin)
function [ebsd,filter,filledId] = smooth(ebsd,varargin)
% smooth spatial EBSD
%
% Input
Expand Down Expand Up @@ -46,9 +46,14 @@
if check_option(varargin,'fill')
F = TriScatteredInterp([ebsd.prop.x(:),ebsd.prop.y(:)],(1:length(ebsd.prop.x)).','nearest'); %#ok<DTRIINT>
idOld = fix(F(xgrid(:),ygrid(:)));

filledId = true(sGrid);
filledId(ind) = false;

% interpolate phaseId
ebsd.phaseId = reshape(ebsd.phaseId(idOld),[],1);

% interpolate grainId
if isfield(ebsd.prop,'grainId')
grainId = reshape(ebsd.prop.grainId(idOld),sGrid);
ebsd.prop.grainId = grainId(:);
Expand Down
2 changes: 1 addition & 1 deletion EBSDAnalysis/@EBSD/subSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

ebsd = subSet@dynProp(ebsd,ind);
ebsd.rotations = ebsd.rotations(ind);
ebsd.phaseId = ebsd.phaseId(ind);
ebsd.phaseId = reshape(ebsd.phaseId(ind),[],1);
ebsd.id = ebsd.id(ind);
%if ~isempty(ebsd.grainId), ebsd.grainId = ebsd.grainId(ind); end
if ~isempty(ebsd.A_D), ebsd.A_D = ebsd.A_D(ind,ind); end
15 changes: 15 additions & 0 deletions EBSDAnalysis/@grain2d/checkInside.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@

% a grain should not contain itself
xy(ind,:) = NaN;
elseif isa(xy,'EBSD')

% extract unit cell
uc = xy.unitCell;

% for EBSD data the complete unitcell should be contained
xy = [xy.prop.x(:),xy.prop.y(:)];

isInside = grains.checkInside(xy+repmat(uc(1,:),size(xy,1),1));
for i = 2:size(uc,1)
isInside = isInside & grains.checkInside(xy+repmat(uc(i,:),size(xy,1),1));
end
isInside = any(isInside,2);
return

end

isInside = false(size(xy,1),length(grains));
Expand Down
10 changes: 9 additions & 1 deletion EBSDAnalysis/@grainBoundary/grainBoundary.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
properties (Dependent = true)
misorientation % misorientation between adjecent measurements to a boundary
direction % direction of the boundary segment
midPoint % x,y coordinates of the midpoint of the segment
I_VF % incidence matrix vertices - faces
I_FG % incidence matrix faces - grains
A_F % adjecency matrix faces - faces
Expand Down Expand Up @@ -68,7 +69,8 @@
gB.CSList = ebsd.CSList;

% sort ebsdId such that first phaseId1 <= phaseId2
doSort = gB.phaseId(:,1) > gB.phaseId(:,2);
doSort = gB.phaseId(:,1) > gB.phaseId(:,2) | ...
(gB.phaseId(:,1) == gB.phaseId(:,2) & gB.grainId(:,1) > gB.grainId(:,2));
gB.phaseId(doSort,:) = fliplr(gB.phaseId(doSort,:));
gB.ebsdId(doSort,:) = fliplr(gB.ebsdId(doSort,:));
gB.grainId(doSort,:) = fliplr(gB.grainId(doSort,:));
Expand Down Expand Up @@ -126,6 +128,12 @@
y = gB.V(unique(gB.F(:)),2);
end

function xy = get.midPoint(gB)
xyA = gB.V(gB.F(:,1),:);
xyB = gB.V(gB.F(:,2),:);
xy = 0.5 * (xyA + xyB);
end

function I_VF = get.I_VF(gB)
[i,~,f] = find(gB.F);
I_VF = sparse(f,i,1,size(gB.V,1),size(gB.F,1));
Expand Down
2 changes: 1 addition & 1 deletion EBSDAnalysis/phaseList.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
function e = end(pL,i,n)

if n==1
e = numel(pL.phaseId);
e = size(pL.phaseId,1);
else
e = size(pL.phaseId,i);
end
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ clean:


# rule for making release
RNAME = mtex-4.1.2
RNAME = mtex-4.1.3
RDIR = ../releases
release:
rm -rf $(RDIR)/$(RNAME)*
Expand Down
3 changes: 2 additions & 1 deletion ODFAnalysis/@FourierComponent/calcPDF.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
% calculate pole figure from Fourier coefficients

% use only even Fourier coefficients?
even = 1 + (check_option(varargin,'antipodal') || r.antipodal);
even = 1 + (check_option(varargin,'antipodal') ...
|| r.antipodal || h.antipodal || component.CS.isLaue);

if length(h) == 1 % pole figures
in = h;
Expand Down
14 changes: 7 additions & 7 deletions ODFAnalysis/@FourierComponent/conv.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function odf = conv(odf,psi,varargin)
function component = conv(component,A,varargin)
% convolute ODF with kernel psi
%
% Input
Expand All @@ -8,12 +8,12 @@
% See also
% ODF_calcFourier ODF_Fourier

%TODO
L = bandwidth(odf);
A = getA(psi);
A(end+1:L+1) = 0;
% multiply Fourier coefficients of odf with Chebyshev coefficients

L = component.bandwidth;
A(end+1:L) = 0;

% multiply Fourier coefficients of odf with Chebyshev coefficients of psi
for l = 0:L
odf.c_hat(deg2dim(l)+1:deg2dim(l+1)) = A(l+1) / (2*l+1) * odf.c_hat(deg2dim(l)+1:deg2dim(l+1));
component.f_hat(deg2dim(l)+1:deg2dim(l+1)) = ...
A(l+1) * component.f_hat(deg2dim(l)+1:deg2dim(l+1));
end
21 changes: 21 additions & 0 deletions ODFAnalysis/@ODF/ODF.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,26 @@
end

end

methods (Static = true)

function odf = ambiguity1(varargin)

cs = crystalSymmetry('222');

orix = orientation('axis',xvector,'angle',90*degree,cs);
oriy = orientation('axis',yvector,'angle',90*degree,cs);
oriz = orientation('axis',zvector,'angle',90*degree,cs);

odf = unimodalODF([orix,oriy,oriz],varargin{:});
end

function odf = ambiguity2(varargin)
cs = crystalSymmetry('222');
ori = orientation('axis',vector3d(1,1,1),'angle',[0,120,240]*degree,cs);
odf = unimodalODF(ori,varargin{:});
end

end

end
16 changes: 7 additions & 9 deletions ODFAnalysis/@ODF/conv.m
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
function odf = conv(odf,psi,varargin)
function odf = conv(odf,A,varargin)
% convolute ODF with kernel psi
%
% Input
% odf - @ODF
% A - Legendre coefficients
% psi - convolution @kernel
%
% See also
% ODF_calcFourier ODF_Fourier


% Fourier ODF
if isa(A,'kernel'), A = psi.A; end

L = bandwidth(odf);
A = getA(psi);
A(end+1:L+1) = 0;
% convert to Fourier ODF
L = length(A)-1;
odf = FourierODF(odf,L);


for l = 0:L
odf.c_hat(deg2dim(l)+1:deg2dim(l+1)) = A(l+1) / (2*l+1) * odf.c_hat(deg2dim(l)+1:deg2dim(l+1)) ;
end
odf.components{1} = conv(odf.components{1},A);
7 changes: 6 additions & 1 deletion ODFAnalysis/@ODF/plotFourier.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ function plotFourier(odf,varargin)

[mtexFig,isNew] = newMtexFigure(varargin{:});

L = get_option(varargin,'bandwidth',32);
if isFourier(odf)
L = odf.components{1}.bandwidth;
else
L = 32;
end
L = get_option(varargin,'bandwidth',L);

odf_hat = calcFourier(odf,'bandwidth',L,'l2-normalization');

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MTEX 4.1.2
MTEX 4.1.3
8 changes: 4 additions & 4 deletions doc/EBSDAnalysis/EBSDSmoothing.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
mtexdata twins

% compute grains
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd('indexed'));
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd,'angle',10*degree);

% restrict data to one single grain
oneGrain = grains(119)
oneGrain = grains(22)
ebsd = ebsd(oneGrain)

plot(ebsd,ebsd.orientations)
Expand All @@ -34,10 +34,10 @@

% set inversePoleFigureDirection such that the mean orientation is
% colorized white
oM.inversePoleFigureDirection = grains(119).meanOrientation * oM.whiteCenter;
oM.inversePoleFigureDirection = grains(22).meanOrientation * oM.whiteCenter;

% concentrate the colors around the mean orientation
oM.colorStretching = 25;
oM.maxAngle = 3*degree;

% plot the colormap
plot(oM)
Expand Down
Loading

0 comments on commit 51dbd18

Please sign in to comment.