close all
clear all


load('HF-data-alt.mat');


nelements_total = [];

for lat_idx = 1:3;
for lon_idx = 1:4;

Spd = (Udata(:,lat_idx,lon_idx).^2+Vdata(:,lat_idx,lon_idx).^2).^.5;
idx = find(~isnan(Spd));

if(~isempty(idx))

  figure
  plot(times,Spd);
  datetick('x');
  ylabel('Spd (m/s)');

  idx = find(~isnan(Spd));
  Spd_redacted = Spd(idx);


  [nelements,centers]= hist(Spd_redacted,20);

  if(isempty(nelements_total))
      nelements_total = nelements;
  else
      nelements_total = nelements_total+nelements;
  end
  
  figure
  bar(centers,100*nelements/sum(nelements),1)
  xlabel('Current Speed (m/s)');
  ylabel('Percentage of Observations');
  title(['Histogram of ' num2str(sum(nelements)) ' Hourly Observations at ' num2str(lat(lat_idx)) 'N  ' num2str(abs(lon(lon_idx)))  'W']);

end  
  
  
end
end


  figure('Position',[796 471 1375 983],'PaperOrientation','landscape','PaperPosition',[0 0 11 8.5]);
  bar(centers,100*nelements_total/sum(nelements_total),1,'y')
  xlabel('Current Speed (m/s)');
  ylabel('Percentage of Observations');
  title(['Histogram of all hourly observations near the Catalina ESP Site (~1800 hours of observation since Oct 2011)']);
  
  print('-dpdf','Current Observation Histogram - Alt Site');