Home > utilities > do_ph_vertical_profile.m

do_ph_vertical_profile

PURPOSE ^

For a supplied transect, plot the vertical profile through the water

SYNOPSIS ^

function [Plots]=do_ph_vertical_profile(plotOPTS,FVCOM,transectPoints)

DESCRIPTION ^

 For a supplied transect, plot the vertical profile through the water
 column supplied in FVCOM.var_plot.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Plots]=do_ph_vertical_profile(plotOPTS,FVCOM,transectPoints)
0002 % For a supplied transect, plot the vertical profile through the water
0003 % column supplied in FVCOM.var_plot.
0004 
0005 % Get the relevant time intervals
0006 if isempty(plotOPTS.save_intervals)
0007     plotOPTS.save_intervals=1:length(plotOPTS.Time_record);
0008     dontSave=1;
0009 else
0010     dontSave=0;
0011 end
0012 
0013 if isfield(plotOPTS,'altColours') && plotOPTS.altColours==1
0014     colourSpec=flipud(jet);
0015 else
0016     clear nColours nColourIn nColourOut colourSpec
0017     % Build a colour palette which matches Jerry's ranges.
0018     % Dark Red -> Red -> Amber -> Yellow -> Green -> Blue
0019     nColours=200;
0020     nColourIn=[1,nColours*0.15,nColours*0.6,nColours*0.75,nColours*0.9,nColours];
0021     nColourOut=1:nColours; % Gives a nice continuous palette.
0022     %                          DR    R     A    Y    G     B
0023     cRed=interp1(nColourIn,  [0.62, 0.9, 1    , 1  , 0  , 0.46],nColourOut);
0024     cGreen=interp1(nColourIn,[0   , 0  , 0.52 , 1  , 0.8, 0.63],nColourOut);
0025     cBlue=interp1(nColourIn, [0.2 , 0.2, 0    , 0  , 0  , 0.83],nColourOut);
0026     colourSpec=[cRed;cGreen;cBlue]';
0027 end
0028 
0029 dataToUse=single(FVCOM.(plotOPTS.var_plot));
0030 
0031 saveInc=1;
0032 for aa=1:length(plotOPTS.Time_record)
0033 
0034     verticalProfile=squeeze(dataToUse(transectPoints.trn_nodes.idx,:,plotOPTS.save_intervals(aa)));
0035     
0036 %     xValues=repmat(transectPoints.trn_dis,1,size(verticalProfile,2));
0037     % Not sure about those distance values...
0038     xNorm=transectPoints.trn_nodes.x-min(transectPoints.trn_nodes.x);
0039     yNorm=transectPoints.trn_nodes.y-min(transectPoints.trn_nodes.y);
0040     xDist=sqrt(xNorm.^2+yNorm.^2);
0041     xValues=repmat(xDist,1,size(verticalProfile,2));
0042 
0043     zeta=squeeze(FVCOM.zeta(transectPoints.trn_nodes.idx,plotOPTS.save_intervals(aa)));
0044     waterDepth=FVCOM.h(transectPoints.trn_nodes.idx);
0045     zValues=(zeta+waterDepth)*FVCOM.siglay(1,:);
0046 
0047     % plot profile
0048     fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record))
0049     figure(plotOPTS.figure); clf
0050     hold on
0051     Plots(1).handles=contourf(...
0052         xValues/1000,... % km
0053         zValues,...
0054         fliplr(verticalProfile),... % get vertical right way up
0055         200,'edgecolor','none');
0056 %     ylim([-max(FVCOM.h(:)) -0.5])
0057     xlabel('Distance along transect (km)')
0058     ylabel('Depth (m)')
0059     colormap(colourSpec)
0060     ch=colorbar;
0061     set(ch,'FontSize',10);
0062     ylabel(ch,'pH')
0063 
0064     if ~isempty(plotOPTS.vlims)
0065         caxis(plotOPTS.vlims);
0066         % Get sensible tick formatting (if necessary)
0067         if plotOPTS.vlims(2)-plotOPTS.vlims(1)<1e-4
0068             xx=0:length(plotOPTS.vlims)-1;
0069             yy=plotOPTS.vlims;
0070             xxi=0:1/6:1; % six ticks
0071             cticks=interp1(xx,yy,xxi);
0072             set(ch,'YTick',double(cticks))
0073             set(ch,'yticklabel',cticks)
0074         end
0075     end
0076 
0077 
0078 
0079     pause(plotOPTS.pause)
0080     if plotOPTS.save_output % Are we even trying to save figures?
0081         if saveInc<=length(plotOPTS.save_intervals) && plotOPTS.save_intervals(aa)==plotOPTS.save_intervals(saveInc) && ~dontSave
0082             % Save output
0083             fprintf('Saving figure... ')
0084             set(findobj(gcf,'Type','text'),'FontSize',10)
0085             %set(gcf,'PaperSize',fliplr(get(gcf,'PaperSize')))
0086             set(gcf,'PaperPositionMode','auto');
0087             set(gcf,'renderer','painters'); % for vector output in pdfs
0088             print(gcf,'-dpdf','-r600',[plotOPTS.FVCOM_plot_dir,plotOPTS.var_plot,'/pdf/',plotOPTS.fig_name,'_vertical_profile_',plotOPTS.var_plot,'_',num2str(plotOPTS.save_intervals(aa)),'.pdf']); % pdf
0089             %print(gcf,'-dpng','-r600',[plotOPTS.FVCOM_plot_dir,plotOPTS.var_plot,'/png/',plotOPTS.fig_name,'_layer=',num2str(plotOPTS.nz_plot),'_',plotOPTS.var_plot,'_change_',num2str(plotOPTS.save_intervals(aa)),'.png']); % png
0090             saveInc=saveInc+1;
0091             fprintf('done.\n')
0092         end
0093     end
0094 
0095     if aa~=length(plotOPTS.Time_record)
0096         clf
0097     end
0098 end
0099 
0100 return

Generated on Thu 19-Mar-2015 12:20:56 by m2html © 2005