function plotsim3(fname, qntity, cells, clr)
% PLOTSIM3 - plot specified simulation results coming from CTMSIM in 3D.
%
% Call: plotsim3(fname, qntity)
%
% Parameters:
% fname - name of the file with simulation stored by CTMSIM;
% qntity - quantity that needs to be plotted:
% 'density' - mainline density,
% 'flow' - mainline flow,
% 'speed' - mainline speed,
% 'demand' - on-ramp demand,
% 'orflow' - on-ramp flow,
% 'queue' - on-ramp queue,
% 'frflow' - off-ramp flow,
% 'beta' - off-ramp split ratio,
% 'vht' - Vehicle Hours Traveled,
% 'vmt' - Vehicle Miles Traveled,
% 'delay' - travel delay,
% 'ploss' - productivity loss.
%
% Returns: none.
%
% See also: PLOTSIM, CTMSIM, FWCONFIG.
%
% Last modified: 03/25/2007.
%
% Alex Kurzhanskiy <akurzhan@eecs.berkeley.edu>
%
load(fname);
if ~isstruct(ctmGUI_data)
error('PLOTSIM: no simulation data found in the specified file.')
end
s = ctmGUI_data; % just to make the name shorter
str = sprintf('per %.2f minutes', (60 * s.plotPeriod * s.TS));
% time series contours or aggregates
switch lower(qntity)
case 'density'
surf(s.pmData, s.timeMinutes, s.densityData');
colormap(s.densityCMF);
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel('Density (vpm)');
title(sprintf('%s: Density', s.freeway));
case 'flow'
surf(s.pmData, s.timeMinutes, s.flowData');
colormap(s.flowCMF);
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel('Flow (vph)');
title(sprintf('%s: Flow', s.freeway));
case 'speed'
surf(s.pmData, s.timeMinutes, s.speedData');
colormap(s.speedCMF);
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel('Speed (mph)');
title(sprintf('%s: Speed', s.freeway));
case 'demand'
surf(s.pmData, s.timeMinutes, s.demandData');
colormap(s.orflowCMF);
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel('On-Ramp Demand (vph)');
title(sprintf('%s: On-Ramp Demand', s.freeway));
case 'orflow'
surf(s.pmData, s.timeMinutes, s.orflowData');
colormap(s.orflowCMF);
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel('On-Ramp Flow (vph)');
title(sprintf('%s: On-Ramp Flow', s.freeway));
case 'queue'
surf(s.pmData, s.timeMinutes, s.orqueueData');
colormap(s.orqueueCMF);
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel('On-Ramp Queue Size');
title(sprintf('%s: On-Ramp Queue Size', s.freeway));
case 'frflow'
surf(s.pmData, s.timeMinutes, s.frflowData');
colormap(s.frflowCMF);
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel('Off-Ramp Flow (vph)');
title(sprintf('%s: Off-Ramp Flow', s.freeway));
case 'beta'
surf(s.pmData, s.timeMinutes, s.frbetaData');
colormap(s.frbetaCMF);
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel('Off-Ramp Split Ratio');
title(sprintf('%s: Off-Ramp Split Ratio', s.freeway));
case 'vht'
surf(s.pmData, s.timeMinutes, s.vhtData');
colormap(jet(s.numColors));
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel(sprintf('VHT %s', str));
title(sprintf('%s: VHT', s.freeway));
case 'vmt'
surf(s.pmData, s.timeMinutes, s.vmtData');
colormap(jet(s.numColors));
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel(sprintf('VMT %s', str));
title(sprintf('%s: VMT', s.freeway));
case 'delay'
surf(s.pmData, s.timeMinutes, s.delayData');
colormap(jet(s.numColors));
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel(sprintf('Delay (vh) %s', str));
title(sprintf('%s: Delay', s.freeway));
case 'ploss'
surf(s.pmData, s.timeMinutes, s.plossData');
colormap(jet(s.numColors));
shading flat;
xlabel('Post Mile');
ylabel('Time (min)');
zlabel(sprintf('Productivity Loss (lmh) %s', str));
title(sprintf('%s: Productivity Loss', s.freeway));
otherwise
error('PLOTSIM: invalid quantity.');
end
return;