Home > utilities > do_residual_plot.m

# do_residual_plot

## PURPOSE

Take the output of do_residual and plot as a vector figure. Summarises a

## SYNOPSIS

function [Plots]=do_residual_plot(plotOPTS,FVCOM,dt)

## DESCRIPTION

``` Take the output of do_residual and plot as a vector figure. Summarises a
specified interval of time as a single long-term direction and magnitude.```

## CROSS-REFERENCE INFORMATION

This function calls:
• do_residual DO_RESIDUAL Takes the u and v vectors of a model output and calculates
• m_ll2ll M_ll2LL Converts LON,LAT to long,lat coordinates using the current projection
This function is called by:

## SOURCE CODE

```0001 function [Plots]=do_residual_plot(plotOPTS,FVCOM,dt)
0002 % Take the output of do_residual and plot as a vector figure. Summarises a
0003 % specified interval of time as a single long-term direction and magnitude.
0004 m_mappath;
0005
0006 warning('on','FVCOM:Plot:ResidualAnalysis')
0007
0008 figure(plotOPTS.figure); clf
0009 m_proj('UTM','lon',[plotOPTS.range_lon],'lat',[plotOPTS.range_lat],'zon',30,'ell','grs80');
0010 m_grid('box','fancy');
0011 m_usercoast(plotOPTS.coastline_file,'Color','k','LineWidth',3);
0012 [x,y]=m_ll2ll(FVCOM.xc,FVCOM.yc); x=x+6;
0013
0014 igood = find (x < plotOPTS.range_lon(2) & x > plotOPTS.range_lon(1) &...
0015     y < plotOPTS.range_lat(2) & y > plotOPTS.range_lat(1));
0016 igood=igood(1:plotOPTS.data_dec:end);
0017
0018 if isfield(plotOPTS,'nz_plot_vec')
0019     nLayers=size(plotOPTS.nz_plot_vec,2);
0020     nLayersRange=plotOPTS.nz_plot_vec;
0021 else
0022     nLayers=size(plotOPTS.nz_plot,2);
0023     nLayersRange=plotOPTS.nz_plot;
0024 end
0025
0026 % Check we're not depth averaging values.
0027 if isfield(plotOPTS,'depth_average') && plotOPTS.depth_average
0028     if nLayers>1
0029         warning('FVCOM:Plot:ResidualAnalysis','Depth averaging has been set as well as a specific number of layers to extract. Usually one or the other is preferred.')
0030     end
0031     nLayers=1;
0032     nLayersRange=1;
0033     % Average through all depths. Don't squeeze() here as that's taken
0034     % care of in do_residual().
0035     uIn=mean(FVCOM.u,2);
0036     vIn=mean(FVCOM.v,2);
0037 else
0038     uIn=FVCOM.u(:,nLayersRange,:);
0039     vIn=FVCOM.v(:,nLayersRange,:);
0040 end
0041
0042 if nLayers==1
0043     colourSpec=[0 0 0];
0044 else
0045     colourSpec=colormap(hsv(nLayers));
0046     setColourMap=1;
0047 end
0048
0049 % We're not using uRes and vRes here, but if you wanted to do a PVD, then
0050 % you would use:
0051 %   plot(uRes(someElement,someLayer,:),vRes(someElement,someLayer,:),'.-'),
0052 % for example.
0053 [rDir,rMag,uRes,vRes]=do_residual(uIn,vIn,dt);
0054
0055 % Mesh goes underneath the vectors
0056 if plotOPTS.do_mesh
0057     % plot vertices
0058     [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0059     Plots(plotOPTS.figure).handles=patch('Vertices',[X,Y],...
0060         'Faces',plotOPTS.mesh.tri,'EdgeColor',[0.6 0.6 0.6],...
0061         'FaceColor','none'); hold on
0062 end
0063
0064 for ii=1:nLayers
0065     % Decompose to vector components for m_vec.
0066     uVec=rMag(:,ii,:).*sind(rDir(:,ii,:));
0067     vVec=rMag(:,ii,:).*cosd(rDir(:,ii,:));
0068     [Plots(plotOPTS.figure).handles(ii),~]=m_vec(plotOPTS.vel_sca,...
0069         x(igood),y(igood),squeeze(uVec(igood)),squeeze(vVec(igood)),...