% crystal symmetry
CS = {...
'notIndexed',...
crystalSymmetry('mmm', [4.756 10.207 5.98], 'mineral', 'Forsterite', 'color', 'light blue')};
setMTEXpref('xAxisDirection','north');
setMTEXpref('zAxisDirection','outOfPlane');
%% Import the Data
% create an EBSD variable containing the data
ebsd = loadEBSD('/Users/romy/Research/FGRs/EBSD/VigaranoFGR1_forst.ctf',CS,'interface','ctf',...
'convertSpatial2EulerReferenceFrame');
%% clean up data, calculate grains
% calculates grains with default 10 degree misorientations at boundaries
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd);
% sets aside non-indexed grains
notIndexed = grains('notIndexed');
% we want to remove large areas of non-index grains from being smoothed
% over
toRemove = notIndexed(notIndexed.grainSize ./ notIndexed.boundarySize<0.8);
% and remove the corresponding EBSD measurements
ebsd(toRemove) = [];
% and perform grain reconstruction with the reduced EBSD data set
[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd);
% finally, smooth grain boundaries
grains = smooth(grains);
grainsOPG = grains(grains.grainSize > 4,'Forsterite').meanOrientation;
h = [Miller(1,0,0,odf.CS),Miller(0,1,0,odf.CS),Miller(0,0,1,odf.CS)];
figure
plotPDF(grainsOPG, h) % plot one (mean) orientation per grain
% What I want to do is take the orientations that are plotted on the
% pole figures for each miller index and save into an ascii file trend, plunge data
M_index = calcMIndex(odf) % function built into mtex
J_index = textureindex(odf) % function built into mtex