%  cod with Hydrography & drifters

path('/home3/ocn/jmanning/atsee',path)
path('/home3/ocn/jmanning/gbs95/drift/mfiles',path)


% set base map
  georbat
  hold on;

%load sj9507 data
load /home3/ocn/jmanning/gbs95/bongo/sj9507/bongoll2.dat
b=bongoll2;

%pick out the portion of grid desired
%misn=input('minimum sta#: ');
misn=120
%masn=input('maximum sta#: ');
masn=187
idd=find(b(:,3)>=misn&b(:,3)<=masn);

%note we have to reverse the order since that
% is hoe this file came
xc=b(idd(length(idd):-1:1),2);
yc=b(idd(length(idd):-1:1),1);
sn=b(idd(length(idd):-1:1),3);

load /home3/ocn/jmanning/gbs95/bongo/sj9507/bongostd2.dat
bstd=bongostd2;
c=bstd(idd,11);
h=bstd(idd,14);
% define standardized
cs=bstd(idd,13);
hs=bstd(idd,16);

clear bstd b;

% set axis and labels 
  mila=min(yc)-.05;
  mala=max(yc)+.25;
  milo=min(xc)-.05;
  malo=max(xc)+.05;
  inta=30;
  into=30;
  axis([milo malo mila mala]);
  lllabel(inta,into,mila,mala,milo,malo)

% read in the gridded results from surfer and contour
  fid=fopen('/home3/ocn/jmanning/gbs95/bongo/sj9507/bot.grd');
  fscanf(fid,'%s',1);
  nx=fscanf(fid,'%f',1);
  ny=fscanf(fid,'%f',1);
  nmilo=fscanf(fid,'%f',1);
  nmalo=fscanf(fid,'%f',1);
  nmila=fscanf(fid,'%f',1);
  nmala=fscanf(fid,'%f',1);
  mi=fscanf(fid,'%f',1);
  ma=fscanf(fid,'%f',1);
  loinc=(nmalo-nmilo)/nx;
  lainc=(nmala-nmila)/ny;

% now we can form the xyz points
  for i=1:ny;
    for k=1:nx;
      t(i,k)=fscanf(fid,'%f',1);
      if t(i,k)>200000;
         t(i,k)=NaN;
      end;
      lo(i,k)=nmilo+k*loinc-loinc;
      la(i,k)=nmila+i*lainc-lainc;
    end;
  end;

  econtour(lo(1,:),la(:,1),t,'fill','label',100);
%  econtour(lo(1,:),la(:,1),t,'fill');
  colormap('jet');

  axis([milo malo mila mala])
  lllabel(inta,into,mila,mala,milo,malo)
  set(gca,'position',[.1 .1 .8 .8],'xticklabels',' ');

  xlabel(' ');
  set(gca,'box','on','aspectratio',[1 .78]);

% Here's where we substitute model adjusted cod
  madj=1;
  if madj==1;
    load /data5/jmanning/model/bank150/midmay95/r33/a.dat
    xc=a(:,5);yc=a(:,6);cs=a(:,10);
  end;

% Hydroid or Cod
% set base map
  hold on;
  ms=20+cs*(100/max(cs));
  for ii=1:length(cs);
    if cs(ii)~=0;
      plot(xc(ii),yc(ii),'.','MarkerSize',ms(ii),'color','w')
    else
      plot(xc(ii),yc(ii),'.','MarkerSize',8,'color','w')
    end;
  end;

% now post the actual values
for ik=1:length(cs);
  if cs(ik)>0;
    h1=text(xc(ik),yc(ik),num2str(ceil(cs(ik))));
    set(h1,'verticalalignment','middle','horizontalalignment','center');
    set(h1,'fontsize',8,'color','k')
  end;
end;
 
axis([milo malo mila mala])
lllabel(inta,into,mila,mala,milo,malo)
set(gca,'position',[.1 .1 .8 .8]);
ylabel('Latitude ');
xlabel('Longitude ');

%TEXT
%  text(-68.7,41.5,'SJ9507  11-14 May, 1995','fontsize',16)
  title('Redistribution of Cod by Model Run (May 17)','fontsize',16)
  text(-68.25,41.4,'Cod per 100 Cubic Meter (Circles)')
  text(-68.25,41.35,'Bottom Temperature (Contoured)');
  text(-68.25,41.3,'Drifters @15m (thin lines)');
  text(-68.25,41.25,'Depth: 60,100,200m (bold lines)')
  text(-68.25,41.2,'Moorings (red dots)')
  plot([-67.6264 -67.5588],[40.956 40.864],'r.','markersize',30)
%text(max(xc)-0.3,max(yc)+.40,'3','FontSize',10)
set(gca,'box','on','aspectratio',[1 .78]);
disp('Dont forget to add bathy lables!!!')

% add drifters

sumplt
