% This file pulls out the winds from the WW3 output for comparison with
% those from the Gisborne airport, and potentially for incorporation into
% ROMS

Filesw = dir('*wind.200*.grb') % all of them


time=[];
uwind=[];
vwind=[];
U = [];
V = [];
k = 0;
kv = 0;
for i=1:length(Filesw);
    tmp=read_grib(Filesw(i).name,-1);
    for j=1:length(tmp)
        tmp2=tmp(j).stime;
        t(j,:)=datevec(datenum(tmp2));
    end
    time=[time;t];
    range(t)
    clear t
end


U = ones(length(time)./2,288,157);
V = ones(length(time)./2,288,157);
uwind = ones(length(time)./2,1);
vwind = ones(length(time)./2,1);
for i=1:length(Filesw);
    tmp=read_grib(Filesw(i).name,-1);
    for j=1:2:length(tmp)
        k = k+1;
        utmp = tmp(j).fltarray;
        utmp = reshape(utmp,[288 157]);
        uwind(k)=utmp(144,117);
        U(k,:,:) = utmp;
    end
    range(uwind)
    
    for j=2:2:length(tmp)
        kv = kv+1;
        vtmp = tmp(j).fltarray;
        vtmp = reshape(vtmp,[288 157]);
        vwind(kv)=vtmp(144,117);
        V(kv,:,:) = vtmp;
    end
    range(vwind)
end