% filename='/auto/data/seawinds/L2B/2003/154/SW_S2B02441.20032832239';
filename='/auto/data/seawinds/L2B/2003/154/SW_S2B02448.20032832311';
% filename='/auto/data/seawinds/L2B/2003/156/SW_S2B02470.20032832324';
% filename='/auto/data/seawinds/L2B/2003/152/SW_S2B02413.20032832217';

wind_speed_selection = hdfread(filename, 'wind_speed_selection');
wind_dir_selection = hdfread(filename, 'wind_dir_selection');

% look at region_list_SW.txt for the along and cross track index for each swath
% it is in the documentation folder

% For 02441
% astart = 478;
% astop = 532;
% cstart = 3;
% cstop = 37;

% For 02448
astart = 1099;
astop = 1150;
cstart = 41;
cstop = 74;

% For 02470
% astart = 471;
% astop = 523;
% cstart = 35;
% cstop = 74;

% For 02413
% astart = 470;
% astop = 523;
% cstart = 35;
% cstop = 74;

dir = wind_dir_selection'/90;
speed = wind_speed_selection'/200;

figure;
colormap('gray');
imagesc(dir(cstart:cstop,astart:astop),[0 360]); % (cstart:cstop,astart:astop)

cm=gray;
cm2=cm;
[ncm k]=size(cm);
for k=1:ncm/2
  cm2(k,:)=1-cm(2*k-1,:);
  cm2(ncm-k+1,:)=1-cm(2*k-1,:);
end
colormap(cm2);
colorbar;
axis off

figure;
imagesc(speed(cstart:cstop,astart:astop),[0 50]);
colormap('jet');

%% Read ECMF model winds from HDF file indexed by cross and along track

model_speed = hdfread(filename, 'model_speed');
model_dir = hdfread(filename, 'model_dir');

dir = model_dir'/90;
speed = model_speed'/200;

figure;
colormap('gray');
imagesc(dir(cstart:cstop,astart:astop),[0 360]); % (cstart:cstop,astart:astop)

cm=gray;
cm2=cm;
[ncm k]=size(cm);
for k=1:ncm/2
  cm2(k,:)=1-cm(2*k-1,:);
  cm2(ncm-k+1,:)=1-cm(2*k-1,:);
end
colormap(cm2);
colorbar;
axis off

figure;
imagesc(speed(cstart:cstop,astart:astop),[0 50]);
colormap('jet');

