1 |
function ifig = DiagPlot(pagename,page,data,xax,yax,time,pltslc,... |
2 |
outputdir,LoadGridData,SavePlots,DiagDebug); |
3 |
|
4 |
% Function: DiagPlot |
5 |
% Author: Daniel Enderton |
6 |
% |
7 |
% Input Fields: |
8 |
% |
9 |
% Field Type (Brief) Description |
10 |
% ----------------------------------------------------------------------- |
11 |
% ifig integer Figure counter |
12 |
% field cell array Experiment and plot configuration information |
13 |
% data cell array Plotting data |
14 |
% datatime array Iterations ('Int') or months ('Tav') of data |
15 |
% outputdir string Output directory name |
16 |
% LoadGridData 0/1 Optionally load grid data |
17 |
% SavePlots 0/1 Optionally save plot to .eps file |
18 |
% |
19 |
% Descripton: |
20 |
% This is the plotting function for the diagnostics package. This |
21 |
% function should allow you to plot all sorts of things, and is |
22 |
% reasonably versitile. Unfortunately, this also means that things get |
23 |
% quite comlicated. The code is broken up into little scripts to make it |
24 |
% more managable, though unfortunately this makes it rather difficult to |
25 |
% track variables and make changes throughout the function. |
26 |
|
27 |
% Load diagnostics parameters: Plot, general, and field information. |
28 |
DiagGenParam; |
29 |
DiagPlotDefaults; |
30 |
DiagFieldParamA; |
31 |
DiagFieldParamO; |
32 |
DiagFieldParamC; |
33 |
DiagFieldParamI; |
34 |
diagrunparam = ReadVariables('DiagRunDefaults.m'); |
35 |
nrow = length(page); |
36 |
|
37 |
% Initiate figure, with number 'ifig', set oreiention. |
38 |
figure; clf; set(gca,'fontsize',fs_tick); eval(['orient ',Orientation,';']); |
39 |
|
40 |
% Loop over subplots and make plots. |
41 |
for inrow = 1:nrow |
42 |
|
43 |
ntrl = length(page{inrow}); if ntrl ~= 1, ntrl = ntrl - 1; end |
44 |
if ntrl == 1, cmp = 'Sep'; else, cmp = page{inrow}{end}; end |
45 |
if ntrl == 1, ncol = 1; elseif cmp == 'Sbs', ncol = ntrl; else ncol = 1; end |
46 |
|
47 |
dx = (1-dxl-dxr-(ncol-1)*dxm)/ncol; |
48 |
dy = (1-dyb-dyt-(nrow-1)*dym)/nrow; |
49 |
|
50 |
for incol = 1:ncol |
51 |
|
52 |
if size(data{inrow}{incol}) == [6*hres,hres], isCS = 1; else, isCS = 0; end |
53 |
fln = page{inrow}{incol}{ifln}; |
54 |
pst = page{inrow}{incol}{ipst}; |
55 |
flu = page{inrow}{incol}{iflu}; |
56 |
|
57 |
% Set panel settings to default values, override with optional |
58 |
% settings. |
59 |
ExpInfo = page{inrow}{incol}; |
60 |
for iarg = 14:2:length(ExpInfo) |
61 |
if ~ismember(ExpInfo{iarg},diagrunparam) |
62 |
ivalue=ExpInfo{iarg+1}; |
63 |
if isstr(ivalue), fvalue=['''',ivalue,'''']; |
64 |
elseif prod(size(ivalue))>1, fvalue=mat2str(ivalue); |
65 |
else fvalue=num2str(ivalue); end |
66 |
evalexpr = [ExpInfo{iarg},'=',fvalue,';']; |
67 |
if DiagDebug, disp([' Optional plot parameter evaluation: ',evalexpr]); end |
68 |
eval(evalexpr); |
69 |
end |
70 |
end |
71 |
|
72 |
disp([' Row: ',num2str(inrow),'/',num2str(nrow),... |
73 |
'; Col: ',num2str(incol),'/',num2str(ncol),... |
74 |
'; Cmp: ',cmp]); |
75 |
|
76 |
% Load contour intervals, units (loaded in 'DiagFieldParam[A,O]'). |
77 |
try, contint; catch |
78 |
try, eval(['contint = ',fln,'contour',flu,';']); |
79 |
catch, disp(['***Warning*** No contour information for ',fln]); |
80 |
disp([' Using 10 generic contour levels.']); |
81 |
contint = 10; end, end |
82 |
try, units; catch |
83 |
try, eval(['units = ',fln,'units',flu,';']); |
84 |
catch, disp(['***Warning*** No unit information found for ',fln]); |
85 |
disp([' Using question mark.']); |
86 |
units = '?'; end, end |
87 |
|
88 |
xi = dxl + (incol-1)*(dx+dxm); |
89 |
yi = 1-dyt-inrow*dy-(inrow-1)*dym; |
90 |
|
91 |
isp = (inrow-1)*ncol+incol; |
92 |
if DiagDebug, disp([' DiagDebug: Subplot: ',mat2str([nrow,ncol,isp])]); end |
93 |
if DiagDebug, disp([' DiagDebug: SP Range: ',mat2str([xi,yi,dx,dy])]); end |
94 |
subplot(nrow,ncol,isp); hold on; |
95 |
set(gca,'position',[xi,yi,dx,dy],'fontsize',fs_axis); |
96 |
|
97 |
% (Re)set axes and color axis -- Accounts for things like a possible |
98 |
% colorbar, or trimming the axis in certain ways. |
99 |
% Apply desired colorbar, contour label, tick labels, box, grid, and |
100 |
% other such odds and ends. |
101 |
DiagPlotMakePlot; |
102 |
DiagPlotResetAxes; |
103 |
DiagPlotMisc; |
104 |
DiagPlotTitles; |
105 |
clear contint units |
106 |
end |
107 |
end |
108 |
|
109 |
|
110 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
111 |
% Save plot, update figure counter % |
112 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
113 |
|
114 |
% Save plot as desired. |
115 |
if SavePlots |
116 |
if isequal(outputdir,'') |
117 |
outputfile = [pagename,'.eps']; |
118 |
else |
119 |
outputfile = [outputdir,'/',pagename,'.eps']; |
120 |
end |
121 |
print('-depsc2',outputfile); |
122 |
end |