get_fetch.m 1.26 KB
Newer Older
Geoffrey Cowles's avatar
Geoffrey Cowles committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
function [fetch] = get_fetch(f,uwind,vwind,depth) 
%
% Determine fetch for given Cartesian wind speed or stress components 
%
% function get_fetch(uwind,vwind,f) 
%
% DESCRIPTION:
%   Display fetch relationship from fetch object 
%
% INPUT 
%   f     = fetch structure 
%   uwind = wind U10 or stress or other x-component
%   vwind = wind y-component
%   depth = [optional] depth at the station (default = uses bathymetry)
%   
%
% OUTPUT:
%   fetch in meters for that wind stress 
%
% EXAMPLE USAGE
%
%   fetch = get_fetch(myfetch,10.,0.,2.0)
%
% Author(s):  
%    Geoff Cowles (University of Massachusetts Dartmouth)
%
% Revision history
%   
%==============================================================================

%-------------------------------------------------
% set dimensions 
%-------------------------------------------------

[~,nZeta] = size(f.fetch);

%-------------------------------------------------
% find nearest points in theta/zeta space 
%-------------------------------------------------

% wind angle (-pi < wind angle < pi)
wangle = atan2(vwind,uwind);
[~,itheta] = min( abs(wangle-f.theta));

% zeta
if(exist('depth'));
  myzeta = f.zobs + depth;
else
  myzeta = 0.0;
end;
[~,izeta] = min( abs(myzeta-f.zeta));

% set fetch
fetch = f.fetch(itheta,izeta);