


close all; clear all;
fvcom_mesh = 'skg4.3_grd.dat';
fvcom_bath = 'skg4.3_dep.dat';
lon = -122.4721646 ;
lat = 48.3372476;
zeta_min = -3;
zeta_max = 3;
nZeta = 30;
nTheta = 16;
dry_thresh = 0.1;
darc = 125;
Calculate fetch as a function of free surface height (positive up) and orientation
function [fetch_struct] = fetch_calc(fvcom_mesh,lon,lat,zeta_min,zeta_max,dzeta,dtheta,dry_thresh)
DESCRIPTION:
Calculate fetch as a function of free surface height (positive up) and orientation
INPUT
fvcom_mesh = FVCOM 3.x grid file
fvcom_bath = FVCOM 3.x bathymetry file
lon = longitude of point
lat = latitude of point
zeta_min = minimum value of free surface height (m)
zeta_max = maximum value of free surface height (m)
nZeta = number of zeta partitions
nTheta = number of theta partitions
dry_thresh = threshold for a point to be dry
darc = arc spacing in meters along which fetch is searched
OUTPUT:
fetch_struct = fetch structure containing fetch as a function of angle and free surface
height. Angle is defined using Cartesian Wind Stress. Thus the fetch
corresponding to an angle of pi/2 (90 degrees) is the
fetch corresponding to a South wind (wind from South
with Northward wind stress)
EXAMPLE USAGE
Author(s):
Geoff Cowles (University of Massachusetts Dartmouth)
Revision history
==============================================================================

0001 function [fetch_struct] = fetch_calc(fvcom_mesh,fvcom_bath,lon,lat,zeta_min,zeta_max,nZeta,nTheta,dry_thresh,darc) 0002 % close all; clear all; 0003 % fvcom_mesh = 'skg4.3_grd.dat'; 0004 % fvcom_bath = 'skg4.3_dep.dat'; 0005 % lon = -122.4721646 ; 0006 % lat = 48.3372476; 0007 % zeta_min = -3; 0008 % zeta_max = 3; 0009 % nZeta = 30; 0010 % nTheta = 16; 0011 % dry_thresh = 0.1; 0012 % darc = 125; 0013 % Calculate fetch as a function of free surface height (positive up) and orientation 0014 % 0015 % function [fetch_struct] = fetch_calc(fvcom_mesh,lon,lat,zeta_min,zeta_max,dzeta,dtheta,dry_thresh) 0016 % 0017 % DESCRIPTION: 0018 % Calculate fetch as a function of free surface height (positive up) and orientation 0019 % 0020 % INPUT 0021 % fvcom_mesh = FVCOM 3.x grid file 0022 % fvcom_bath = FVCOM 3.x bathymetry file 0023 % lon = longitude of point 0024 % lat = latitude of point 0025 % zeta_min = minimum value of free surface height (m) 0026 % zeta_max = maximum value of free surface height (m) 0027 % nZeta = number of zeta partitions 0028 % nTheta = number of theta partitions 0029 % dry_thresh = threshold for a point to be dry 0030 % darc = arc spacing in meters along which fetch is searched 0031 % 0032 % OUTPUT: 0033 % fetch_struct = fetch structure containing fetch as a function of angle and free surface 0034 % height. Angle is defined using Cartesian Wind Stress. Thus the fetch 0035 % corresponding to an angle of pi/2 (90 degrees) is the 0036 % fetch corresponding to a South wind (wind from South 0037 % with Northward wind stress) 0038 % 0039 % EXAMPLE USAGE 0040 % 0041 % Author(s): 0042 % Geoff Cowles (University of Massachusetts Dartmouth) 0043 % 0044 % Revision history 0045 % 0046 %============================================================================== 0047 0048 %------------------------------------------------- 0049 % load the mesh metrics 0050 %------------------------------------------------- 0051 0052 % read the Mesh from an FVCOM grid file 0053 Mobj = read_fvcom_mesh(fvcom_mesh); 0054 x = Mobj.x; 0055 y = Mobj.y; 0056 0057 % read the bathymetry from an FVCOM grid file 0058 Mobj.h = read_fvcom_bath(fvcom_bath); 0059 h = Mobj.h; 0060 0061 % set cell center coordinates 0062 Mobj.xc = nodes2elems(x,Mobj); 0063 Mobj.yc = nodes2elems(y,Mobj); 0064 0065 %------------------------------------------------- 0066 % set grids in zeta and theta 0067 %------------------------------------------------- 0068 theta = -pi:2*pi/nTheta:pi; nTheta=numel(theta); 0069 zeta = zeta_min:(zeta_max-zeta_min)/nZeta:zeta_max; 0070 if(zeta_min==zeta_max) 0071 zeta = zeta_min; 0072 nZeta = 1; 0073 else 0074 nZeta = nZeta+1; 0075 end; 0076 0077 %------------------------------------------------- 0078 % project observation point (lon,lat) => (x,y) 0079 %------------------------------------------------- 0080 [xobs,yobs] = my_project(lon,lat,'forward'); 0081 0082 0083 %------------------------------------------------- 0084 % compute elevation (positive up) of observation point 0085 %------------------------------------------------- 0086 zobs = -griddata(x,y,h,xobs,yobs); 0087 0088 %------------------------------------------------- 0089 % loop over angles and depths, compute fetch 0090 %------------------------------------------------- 0091 0092 radline = 0:darc:max(max(x)-min(x),max(y)-min(y)); nRad = numel(radline); 0093 fetch = zeros(nTheta,nZeta); 0094 hc = nodes2elems(Mobj.h,Mobj); 0095 for i=1:nTheta 0096 fprintf('searching theta %f\n',theta(i)*180/pi); 0097 xline = xobs+radline*cos(theta(i)+pi); 0098 yline = yobs+radline*sin(theta(i)+pi); 0099 k = 1; 0100 for j=1:nZeta 0101 elev = zeta(j); depth = hc+elev; 0102 found = 0; 0103 k = 1; 0104 while ~found 0105 cell = inCell(Mobj,xline(k),yline(k)); 0106 if(cell == 0)| (depth(cell) < dry_thresh); 0107 fetch(i,j) = radline(k); 0108 %fprintf('found at k = %d\n',k) 0109 found = true; 0110 end 0111 k = k + 1; 0112 end; 0113 end; 0114 end; 0115 0116 0117 %------------------------------------------------- 0118 % save to a structure 0119 %------------------------------------------------- 0120 0121 fetch_struct.xobs = xobs; 0122 fetch_struct.yobs = yobs; 0123 fetch_struct.zobs = zobs; 0124 fetch_struct.theta = theta; 0125 fetch_struct.zeta = zeta; 0126 fetch_struct.fetch = fetch; 0127 fetch_struct.xmesh = x; 0128 fetch_struct.ymesh = y; 0129 fetch_struct.hmesh = h; 0130 0131