Documentation of vel_to_strfnc


Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)


Function Synopsis

[strf, lat_out, lon_out] = vel_to_strfnc(vg, lat, lon);

Help text


  [strf, lat_out, lon_out] = vel_to_strfnc(vg, lat, lon);

  This assumes that the western-most boundary is all NaN's,
    and that the eastern boundary is incorporated in the data
    set


Listing of function vel_to_strfnc

function [strf, lat_out, lon_out] = vel_to_strfnc(vg, lat, lon);

[ny, nx] = size(vg);

%  Find eastern and western boundaries

wb = NaN*ones(ny,1);
eb = NaN*ones(ny,1);
for i = 1:ny;
  land = find(isnan(vg(i,:)));
  if length(land) < nx-2;
    ind = min(find(diff(land) > 2));
    wb(i) = land(ind)+1;
    eb(i) = land(ind+1)-1;
  else
    wb(i) = NaN;
    eb(i) = NaN;
  end
end

%  Get longitudes of strf

global RADIAN DEGREE RADUS

dx = mean(diff(lon));
lon_out = [(lon(1) - dx/2); (lon + dx/2)];

%  Get vg * f * dx for integration

vint = vg .* (RADUS * cos(RADIAN * lat) * diff(RADIAN * lon_out)');

%  Integrate westward

strf = NaN * ones(ny, nx+1);
for i = 1:ny;
  if ~isnan(wb(i));
    strf(i, eb(i)+1) = 0;
    tem = vint(i, wb(i):eb(i));
    tem = fliplr(cumsum(fliplr(tem)));
    strf(i, wb(i):eb(i)) = tem;
  end
end

lat_out = lat;