%% Import Script for EBSD Data
%
% This script was automatically created by the import wizard. You should
% run the whoole script or parts of it in order to import your data. There
% is no problem in making any changes to this script.

%% Specify Crystal and Specimen Symmetries

% crystal symmetry
CS = {... 
  'notIndexed',...
  crystalSymmetry('6/mmm', [3 3 4.7], 'X||a*', 'Y||b', 'Z||c*', 'mineral', 'Titanium', 'color', [0.53 0.81 0.98])};

% plotting convention
setMTEXpref('xAxisDirection','east');
setMTEXpref('zAxisDirection','intoPlane');

%% Specify File Names


% which files to be imported
fname = 'CPg4.ctf';

%% Import the Data

% create an EBSD variable containing the data
ebsd = EBSD.load(fname,CS,'interface','ctf');

%% Correct Data

rot = rotation.byEuler(0*degree,90*degree,0*degree);
ebsd = rotate(ebsd,rot,'keepXY');


%%

% plot the ebsd data set - Pattern Quality Map
figure;
plot(ebsd, ebsd.prop.bc);colormap('gray');

% define an explicite map for converting orientations into colors
ipfKey = ipfHSVKey(CS{1,2});

% plot the colorkey
figure(21)
plot(ipfKey)

% plot the ebsd data set - IPFZ map
ipfKey.inversePoleFigureDirection = vector3d.Z;
color = ipfKey.orientation2color(ebsd('Titanium').orientations);
figure;
plot(ebsd('Titanium'),color)

