%Read and Plot Stats of Weimer05 and IDM F13 maxVy locs and mags
close all

date_title = sprintf('Weimer05 and DMSP-F13 N+S 1996, Jul98-Jun99, 2005');

file = sprintf('/home/emery/reu11/3y_good_stats_tbl');
STAT = fopen(file,'r');
% Skip over 17 lines
for i=1:17
 line = fgetl(STAT);
end
% Read 5 Bz bin stats for W05 and F13 IDM
clear y;
face_gcrb = [0 0.5 0  0 1 0  0.57 0.49 0  0 0 1];
for nb=1:5
 line = fgetl(STAT);
 statdat = sscanf(line,'%f %f %f %f %f %f %f %f %f %f %f %s %f');
 bzav(nb) = statdat(10);
 bztot(nb) = statdat(1);
 numgood(nb) = statdat(2);
 numgdmag(nb) = statdat(4);
 numbadmag(nb) = statdat(2) - statdat(4);
 numwpol(nb) = statdat(6);
 numwequ(nb) = statdat(8);
 y(nb,1) = numgdmag(nb);
 y(nb,2) = numbadmag(nb);
 y(nb,3) = numwequ(nb);
 y(nb,4) = numwpol(nb);
end

figure
%[n,xout] = hist(numgood,bzav);
%bar (xout,n,'stack');
bar (bzav,y,'stack');
y
grid on;
set(gca,'layer','top','fontsize',15,'fontweight','bold');
title(date_title,'fontsize',15,'fontweight','bold');
xlabel('Mean Bz (nT)','fontsize',15,'fontweight','bold');
ylabel('Number of Comparisons of Sunward Max','fontsize',15,'fontweight','bold');
text (-9.,300.,'Good loc/magnitude','fontsize',12,'fontweight','bold');
text (-9.,550.,'Good loc/Bad mag','fontsize',12,'fontweight','bold');
text (-9.,900.,'max W05 Equatorward','fontsize',12,'fontweight','bold');
text (-9.,1100.,'max W05 Poleward','fontsize',12,'fontweight','bold');
text (-7.,230.,'~41%','fontsize',12,'fontweight','bold');
text (-7.,480.,'~12%','fontsize',12,'fontweight','bold');
text (-7.,830.,'~33%','fontsize',12,'fontweight','bold');
text (-7.,1030.,'~14%','fontsize',12,'fontweight','bold');
hold off;
