source: trunk/src/export_fct/quiver_col_eletta.m @ 1157

Last change on this file since 1157 was 1104, checked in by sommeria, 3 years ago

replicate repaired

File size: 4.0 KB
Line 
1%'export_mat': plot vector fields and save figures for project Coriolis/2019/TUBE
2%------------------------------------------------------------------------
3
4%INPUT:
5% handles: Matlab structure containing all the information displyed in the GUI uvmat
6
7
8function export_mat(handles)
9%------------------------------------------------------------------------
10
11%% get input data
12Data_uvmat=get(handles.uvmat,'UserData');
13Data=Data_uvmat.Field; %get the current plotted field
14requested=isfield(Data,'coord_x')&&isfield(Data,'coord_y')&&isfield(Data,'U')&&isfield(Data,'V')&&isfield(Data,'norm');
15if ~requested
16    msgbox_uvmat('ERROR','unappropriate data: need vectors U, V on a regular grid')
17    return
18end
19RootPath=get(handles.RootPath,'String');
20SubDir=get(handles.SubDir,'String');
21RootFile=get(handles.RootFile,'String');
22FileIndex=get(handles.FileIndex,'String');
23
24%% Calibration:
25% plot parameters
26nBits = 64;
27scale = 0.15;
28decimation = 16;
29% filtering procedure
30method = 'gaussian';
31window = 24;
32
33%% get colormap
34load('BuYlRd.mat')
35BuYlRd = BuYlRd(1:floor(size(BuYlRd)/nBits):end,:);
36
37%% reduce the number of arrows
38x = Data.coord_x(1:decimation:end,1:decimation:end);
39y = flipud(Data.coord_y(1:decimation:end,1:decimation:end));
40[X,Y] = meshgrid(x,y);
41% Filtering data to take away spurious subsampling issues (see Shannon Theorem)
42filtU = smoothdata(flipud(Data.U   ),method,window);
43filtV = smoothdata(flipud(Data.V   ),method,window);
44filtS = smoothdata(flipud(Data.norm),method,window);
45
46U = filtU(1:decimation:end,1:decimation:end);
47V = filtV(1:decimation:end,1:decimation:end);
48S = filtS(1:decimation:end,1:decimation:end);
49zmin = min(min(S));
50zmax = max(max(S));
51bins = linspace(zmin,zmax,nBits);
52
53%% plot size and position in the figure
54width = 6.75;     % Width in inches
55height = 6;    % Height in inches
56alw = 0.75;    % AxesLineWidth
57fsz = 12;      % Fontsize
58lw = 1.25;      % LineWidth
59msz = 8;       % MarkerSize
60
61%% make the plot 
62figure(1)
63ax2 = axes('Visible','off','HandleVisibility','off');
64pos = get(1, 'Position');
65set(1, 'Position', [pos(1) pos(2) width*100, height*100]); %<- Set size
66set(ax2, 'FontSize', fsz, 'LineWidth', lw); %<- Set properties
67set(1, 'defaultTextInterpreter','latex');
68for i = 1:nBits-1
69    ii=find((S - bins(i+1) < 0).*(S - bins(i) > 0));
70    quiver(X(ii),Y(ii),U(ii),V(ii), scale,'Color',BuYlRd(i,:), 'LineWidth',1.2)
71    hold on
72end
73cc=colorbar;
74set(cc,'TickLabelInterpreter','latex')
75cc.Label.String='cm/s';
76caxis([zmin zmax])
77axis equal
78xlim([Data.coord_x(1),Data.coord_x(end)])
79ylim([Data.coord_y(1),Data.coord_y(end)])
80hold off
81xlabel('$x(cm)$')
82ylabel('$y(cm)$')
83
84%% Set the figure size
85set(1,'InvertHardcopy','on');
86set(1,'PaperUnits', 'centimeters');
87papersize = get(1, 'PaperSize');
88left = (papersize(1)- width)/2;
89bottom = (papersize(2)- height)/2;
90myfiguresize = [left, bottom, width, height];
91set(1,'PaperPosition', myfiguresize);
92
93%% Save the figure as a pdf file in the appropriate figure folder
94[pp,camera]=fileparts(RootPath);
95[ppp,exp]=fileparts(pp);
96FigPath=fullfile(fileparts(ppp),'0_FIG')
97if ~exist(FigPath,'dir')
98    [s,msg]=mkdir(FigPath); %create the folder if it does not exist
99    if s
100        disp([FigPath ' created'])
101    else
102        msgbox_uvmat('ERROR',msg)
103        return
104    end
105end
106exppath = fullfile(FigPath,exp);
107if ~exist(exppath,'dir')
108    [s,msg]=mkdir(exppath);%create the folder if it does not exist
109    if s
110        disp([exppath ' created'])
111    else
112        msgbox_uvmat('ERROR',msg)
113        return
114    end
115end
116camerapath=fullfile(exppath,camera);
117if ~exist(camerapath,'dir')
118    [s,msg]=mkdir(camerapath);%create the folder if it does not exist
119    if s
120        disp([camerapath ' created'])
121    else
122        msgbox_uvmat('ERROR',msg)
123        return
124    end
125end
126
127outputname=fullfile(camerapath,[RootFile FileIndex '.pdf']);
128print(1,outputname,'-dpdf')
129 
130%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131
132
Note: See TracBrowser for help on using the repository browser.