Newer
Older
function [cmap, Vsst, Vc_symm] = gtIPFCmap(phaseid, LD, varargin)
Laura Nervo
committed
% GTIPFCMAP Returns a colour map for the specified phase and lab/sample direction.
Yoann Guilhem
committed
%
% [cmap, Vsst, Vc_symm] = gtIPFCmap(phaseid, LD, varargin)
% --------------------------------------------------------
Laura Nervo
committed
% Makes an IPF colourmap of the lab_ direction (LD) in the crystal
% coordinates. This can be specified as a second argument, otherwise we
% assume the z-axis [0 0 1]
Yoann Guilhem
committed
%
Laura Nervo
committed
% INPUT:
% phaseid = <int> ID of the specific phase {1}
Yoann Guilhem
committed
% LD = <double> Lab direction to study {[0 0 1]}
%
% OPTIONAL INPUT (varargin as a list of pairs, see parse_pv_pairs.m)
% 'saturate' = <logical> Saturate colors in the SST {true}
% 'save' = <logical> Save color map to cmap_phase<phaseid>.mat
% {true}
Yoann Guilhem
committed
% 'crystal_system' = <string> Legacy to set (force) the crystal system
% for old datasets
% 'r_vectors' = <double> Rodrigues vectors as N x 3 array
Yoann Guilhem
committed
%
% OUTPUT:
% cmap = <double> RGB color map, color code is the inverse
% pole figure in the SST
Laura Nervo
committed
% Vsst = <double> Row vectors expressed in crystal frame
% moved to the SST triangle
% Vc_symm = <double> Row vectors expressed in crystal frame
%
% Version 002 08-02-2013 by YGuilhem
% Add r_vectors as optional input
Yoann Guilhem
committed
%
Laura Nervo
committed
% Version 003 08-01-2013 by LNervo
% Added second output argument: Vsst
%
% Version 002 03-01-2013 by YGuilhem
% Renamed gtIVPCmap to gtIPFCmap, changed colour saturation
Yoann Guilhem
committed
% Version 001 15-11-2012 by YGuilhem
% Built by gathering old gtIVPcubCmap and gtIVPhexCmap functions
% Default parameters
par.saturate = true;
Yoann Guilhem
committed
par.save = false;
par.crystal_system = '';
Yoann Guilhem
committed
par = parse_pv_pairs(par, varargin);
% Set default phaseid
if ~exist('phaseid', 'var') || isempty(phaseid)
phaseid = 1;
end
% Set default lab direction if LD empty
if ~exist('LD', 'var') || isempty(LD)
LD = [0 0 1];
end
% Get the r-vectors
r_vectors = [];
phaseDir = fullfile('4_grains', sprintf('phase_%02d', phaseid));
if ~isempty(par.r_vectors)
r_vectors = par.r_vectors;
elseif exist(fullfile(phaseDir, 'r_vectors.mat'), 'file')
load(fullfile(phaseDir, 'r_vectors.mat'));
elseif exist(fullfile(phaseDir, 'index.mat'), 'file')
Yoann Guilhem
committed
grain = [];
load(fullfile(phaseDir, 'index.mat'), 'grain');
r_vectors = gtIndexAllGrainValues(grain, 'R_vector', [], 1, 1:3);
Yoann Guilhem
committed
else
Laura Nervo
committed
gtError('gtIPFCmap:missing_file', 'Could not find r_vectors.mat or index.mat file!');
Yoann Guilhem
committed
end
% Resize r_vectors if needed
if size(r_vectors, 2) == 4
r_vectors = r_vectors(:, 2:4);
end
Yoann Guilhem
committed
if isempty(par.crystal_system)
parameters = load('parameters.mat');
par.crystal_system = parameters.parameters.cryst(phaseid).crystal_system;
Yoann Guilhem
committed
end
% Compute all orientation matrices g
Laura Nervo
committed
% Gcry = g Gsam
% g = U = gtMathsRod2OriMat(r_vectors.')
all_g = gtMathsRod2OriMat(r_vectors.');
Yoann Guilhem
committed
% Compute LDc = LD expressed in the crystal CS
LDc = gtVectorLab2Cryst(LD, all_g);
Yoann Guilhem
committed
Laura Nervo
committed
% Get the color and vector in the SST triangle
[map, Vsst, ~, Vc_symm] = gtCrystVector2SST(LDc, par.crystal_system, [], par.saturate);