From c026fad82d1ddc3e0b860831e7b1c3766c2c4973 Mon Sep 17 00:00:00 2001 From: Laura Nervo <lnervo@esrf.fr> Date: Thu, 13 Dec 2012 10:27:46 +0000 Subject: [PATCH] Colour maps : general formatting and small bug fixing (check size(r_vectors,2), saving cmap in 6_rendering folder, get proper cryst(phaseid) info Signed-off-by: Laura Nervo <laura.nervo@esrf.fr> git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@958 4c865b51-4357-4376-afb4-474e03ccb993 --- 6_rendering/gtCaxisCmap.m | 9 ++++- 6_rendering/gtIVPCmap.m | 10 +++-- 6_rendering/gtIVPhexCmap_key.m | 73 ++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/6_rendering/gtCaxisCmap.m b/6_rendering/gtCaxisCmap.m index 91c8f739..788967c1 100644 --- a/6_rendering/gtCaxisCmap.m +++ b/6_rendering/gtCaxisCmap.m @@ -34,6 +34,11 @@ r_vectors = []; load('parameters.mat'); load(fullfile('4_grains',sprintf('phase_%02d',phaseid),'r_vectors.mat')); +if size(r_vectors,2) == 3 + r_vectors(:,2:4) = r_vectors; + r_vectors(:,1) = 1:size(r_vectors,1); +end + all_hkils=[]; hkil = reflection; for i = 1:size(hkil,1) @@ -70,7 +75,7 @@ for i=1:size(r_vectors,1) end end -save('c_axis.mat','c_axis'); % list of the c axis +save('6_rendering/c_axis.mat','c_axis'); % list of the c axis % Get the orientation color defined by HSL color code, translated to RGB rgb = gtVectorOrientationColor(c_axis(:, 2:4)); @@ -82,6 +87,6 @@ for i=1:length(c_axis) end % Save the c-axis colourmap -save('c_axismap.mat','c_axismap'); +save('6_rendering/c_axismap.mat','c_axismap'); end % end of function diff --git a/6_rendering/gtIVPCmap.m b/6_rendering/gtIVPCmap.m index 03b1d740..a29c243c 100644 --- a/6_rendering/gtIVPCmap.m +++ b/6_rendering/gtIVPCmap.m @@ -42,10 +42,14 @@ end r_vectors = []; if exist(fullfile('4_grains', sprintf('phase_%02d', phaseid), 'r_vectors.mat'), 'file') load(fullfile('4_grains', sprintf('phase_%02d', phaseid), 'r_vectors.mat')); - r_vectors = r_vectors(:, 2:4); + if size(r_vectors,2) == 4 + r_vectors = r_vectors(:, 2:4); + end elseif exist('r_vectors.mat', 'file') load('r_vectors.mat'); - r_vectors = r_vectors(:, 2:4); + if size(r_vectors,2) == 4 + r_vectors = r_vectors(:, 2:4); + end elseif exist(fullfile('4_grains', sprintf('phase_%02d', phaseid), 'index.mat'), 'file') grain = []; load(fullfile('4_grains', sprintf('phase_%02d', phaseid), 'index.mat'), 'grain'); @@ -57,7 +61,7 @@ end % Get the symmetry operators if isempty(par.crystal_system) parameters = load('parameters.mat'); - par.crystal_system = parameters.parameters.cryst.crystal_system; + par.crystal_system = parameters.parameters.cryst(phaseid).crystal_system; end tmp = gtCrystGetSymmetryOperators(par.crystal_system); if isfield(tmp, 'g3') diff --git a/6_rendering/gtIVPhexCmap_key.m b/6_rendering/gtIVPhexCmap_key.m index a4345a51..56ea4af5 100644 --- a/6_rendering/gtIVPhexCmap_key.m +++ b/6_rendering/gtIVPhexCmap_key.m @@ -1,5 +1,5 @@ -function gtHexIVPCmap_key() -%make a color space for the reduced color space for a hexagonal system +function hf = gtIVPhexCmap_key() +% make a color space for the reduced color space for a hexagonal system % % for the moment, something quick to produce a figure. @@ -12,7 +12,7 @@ function gtHexIVPCmap_key() %%% to the best of my understanding, blue=(psi/90)*(phi-60)/30 is good. -figure +hf = figure(); hold on i=1;j=1; @@ -24,36 +24,36 @@ psimin=0; psimax=90; for phi=[phimin:inc:(phimax-inc) (phimax-inc)] %around z-axis - j=1; - for psi=[psimin:inc:(psimax+inc) psimax+inc] % out from z-axis - go slightly further to avoid gaps at edge of triangle + j=1; + for psi=[psimin:inc:(psimax+inc) psimax+inc] % out from z-axis - go slightly further to avoid gaps at edge of triangle - % for hexagonal colour map need only psi and phi - red=(90-psi)/90; - green=(psi/90)*(90-phi)/30; - blue=(psi/90)*(phi-60)/30; - - rgb=[red green blue]; - % ensure that we don't leave 0-1 - rgb(find(rgb<0))=0; - rgb(find(rgb>1))=1; - - %do we saturate colours? - if 1 - rgb=rgb./(max(rgb)); - end - -%radius distorted for stereographic proj -r_patch=tand([psi/2 (psi+inc)/2]); -[phi_patch,r_patch]=meshgrid([phi phi+inc]',r_patch); -% to use pol2cartphi should be in radians -% also offset by 90 degrees to get triangle "horizontal" -[x_patch,y_patch]=pol2cart((-pi/2)+phi_patch*pi/180, r_patch); - - p=patch(x_patch([1 2 4 3]), y_patch([1 2 4 3]), rgb); - set(p, 'edgecolor', 'none') - j=j+1; + % for hexagonal colour map need only psi and phi + red=(90-psi)/90; + green=(psi/90)*(90-phi)/30; + blue=(psi/90)*(phi-60)/30; + + rgb=[red green blue]; + % ensure that we don't leave 0-1 + rgb(find(rgb<0))=0; + rgb(find(rgb>1))=1; + + %do we saturate colours? + if 1 + rgb=rgb./(max(rgb)); end - i=i+1; + + %radius distorted for stereographic proj + r_patch=tand([psi/2 (psi+inc)/2]); + [phi_patch,r_patch]=meshgrid([phi phi+inc]',r_patch); + % to use pol2cartphi should be in radians + % also offset by 90 degrees to get triangle "horizontal" + [x_patch,y_patch]=pol2cart((-pi/2)+phi_patch*pi/180, r_patch); + + p=patch(x_patch([1 2 4 3]), y_patch([1 2 4 3]), rgb); + set(p, 'edgecolor', 'none') + j=j+1; + end + i=i+1; end axis ij @@ -132,13 +132,13 @@ set(gca, 'ylim', [-0.56 0.1]) %add a black border % line 0001 - 01-10 (phi 90) -line_psi=0:1:90 +line_psi=0:1:90; line_phi=90*ones(size(line_psi)); line_r=tand(line_psi/2); [line_x,line_y]=pol2cart((-pi/2)+line_phi*pi/180, line_r); plot(line_x, line_y, 'k-') % line 0001 - 11-20 (phi 60) -line_psi=0:1:90 +line_psi=0:1:90; line_phi=60*ones(size(line_psi)); line_r=tand(line_psi/2); [line_x,line_y]=pol2cart((-pi/2)+line_phi*pi/180, line_r); @@ -157,8 +157,8 @@ plot(line_x, line_y, 'k-') % add labels for the poles uvtw_poles = [0 0 0 1; 0 1 -1 0; 1 1 -2 0]; -poles_psi=[0 90 90] -poles_phi=[0 90 60] +poles_psi=[0 90 90]; +poles_phi=[0 90 60]; poles_r=tand(poles_psi/2); [poles_x,poles_y]=pol2cart((-pi/2)+poles_phi*pi/180, poles_r); plot(poles_x, poles_y, 'k*') @@ -172,3 +172,6 @@ text(poles_x(3), poles_y(3), '[1 1 -2 0]', 'fontsize', 20, ... set(gca,'position',[0 0 1 1]) axis equal + + +end %end of function -- GitLab