%plantarcticStationGrid_nbp0104.m

%ploting up sampling grid using the new station positions provided

%by John Klinck

%% modified by kef10@cornell.edu 8/29/01

%% load and plot simrad data from gzipped dat files.

clear

leveler=75;

freqer=1;

%% troubles:207 first half wacked to 388664;

%% 211 line 1267 out of freq 2 

%% 215 at 14573 (last line), and 217 18294 fixed manually 

dayser=[206;207;208;209;210;211;212;213;214;...

        215;216;217;218;219;220;...

        221;222;223;224;225;226;227;228;229;...

        230;231;232;233;234;235;236;237;238;...

        239;240;241];

[ld, cd]=size(dayser);

figure;hold on

for rtimes=1:ld

    clear SIM*

dayo=dayser(rtimes,:);

day=num2str(dayo)

freq=num2str(freqer);

level=num2str(leveler);

eval(['!gunzip SIMf', day, 'out', freq, '.dat.gz']);

load(['SIMf' day 'out' freq '.dat']);

eval(['simdat=SIMf', day, 'out', freq, '(:,', level, ');']);

%figure

%clf

m_proj('albers equal-area','lat',[-70 -64],'long',[-78.5 -65.5],'rect','on');

%m_proj('albers equal-area','lat',[-70.5 -65.5],'long',[-85 0],'rect','on');  %use this one with m_gshhs_h to get coastline that will plot

%m_gshhs_h('save','marguerite'); %do this only when to extract portion of intermdiate resolution data base 

m_usercoast('marguerite','patch',[.2 .4 .5]);

m_grid('linewidth',2,'tickdir','out','fontsize',[16]);

%m_text(-66.5,43.5,'GSHHS\_L (low)','color','m','fontweight','bold','fontsize',14);

hold on

% load positions of possible stations

load nbp0104_st %Consec# Sta# lat lon depth with additional dive station

stalat=nbp0104(:,3);

stalon=nbp0104(:,4);

[X,Y]=m_ll2xy(stalon,stalat);

%h1=line(X,Y,'marker','square','markersize',4,'color','r','LineStyle','none','MarkerFaceColor','b');

%h2=line(X,Y,'LineStyle','-');



%addpath c:\matbak\seawater

%[dist,phaseangle]=sw_dist(nbp0104(:,3),nbp0104(:,4));  %(3=lat, 4=lon,units)

%disp(['trackline distance (nm) = ', num2str(sum(dist))]);



%return  %don't plot bathymetry

load etopo2.mat 





%v=[-600,-400,-200 -100];

%[CS,H]=m_contour(lon,lat,elevations,v);

v=[-100, -500,-1000, -3000];

%v2=[-500,-1000];

%v=[-10,-50,-100,-200,-300,-400,-500,-750,-1000,-1500,-2000,-3000,-4000];

[cs,h]=m_contour(lon,lat,elevations,v);

%clabel(cs,h,v2,'LabelSpacing',216);

colormap(gray);

%return%just plot station locations and bathymetry, and don't add MOCNESS stuff

%MOCNESS Station locations

%%i=[3 10 13 15 19 21 25 28 34 37 41 44 51 54 57 66 69 76 84]; = nbp0103 planned

%%i=[3 10 13 15 19 22 25 28 34 37 41 44 51 55 64 66 69 76 81 84]; nbp0103 actual

%%i=[4 11 15 17 21 23 26 32 40 43 47 50 56 62 71 73 76 83 89 92]; %nbp0104 new numbersa to correspond with nbp0103 acutual

%%i=[1 13 19 22 34 46 48 51 87 71]; %Tucker Trawl station locations NBP0104

%%i=[39 53 60 63 83 87 14 16]; %Plummet net sation locations NBP0104

hold on



%also plot underway data

load(['SIMf' day 'llt' freq '.dat'])

eval(['simtime=SIMf', day, 'llt', freq, ';']);

xx=-simtime(:,3);

yy=-simtime(:,2);

%nbp0104_uw %load converted jgofs file

%t=decday;

%first_day=204 ;

%last_day=max(t);

%m=find(t>=first_day & t<=last_day);

%x=lon(m);y=lat(m);

%convert lat and lon to x y coordinates

%[x,y]=m_ll2xy(x,y);



%% PLOT SCALED DATA (64 colors) ON TOP OF SOME MAP

ssf=simdat;

minscat=-90;

maxscat=-80;

diffscat=maxscat-minscat;

mymy=find(ssf>minscat & ssf<=maxscat);

xx=xx(mymy); yy=yy(mymy); ssf=ssf(mymy);

my=find(xx>-180 & yy>-90);

GODAT=ssf(my);

%%factorby=(mean(GODAT)-min(GODAT))./7

xxx=xx(my);

yyy=yy(my);

[xsim,ysim]=m_ll2xy(xxx,yyy);

pieceplot1=plot(xsim, ysim, 'k.');

grayt=jet;  %% gray or jet works ...

%set(pieceplot1, 'linew', 8)

set(pieceplot1, 'markersize', 7);

%% max of fluor on NBP0104 is 10.34 whatsits.

for j=1:64

hiGO=ceil(((GODAT-maxscat)./-diffscat)*63)+1;

ec=grayt(hiGO, :);

i=find(abs(hiGO)>=j & abs(hiGO)<(j+1));

%pieceplot=plot(xreplot(i), yreplot(i), coldots(j,:));

pieceplot=plot(xsim(i), ysim(i), 'w.');



set(pieceplot, 'markersize', 3, 'markerfacecol', grayt(j,:), ...

'markeredgecol', grayt(j,:), 'marker', 'o')

ax1=gca;

end

%title(['Variation in  Fluorescence on ' cruise])

intscat=diffscat/6;

multscat=[0 1 2 3 4 5 ];

scatplus=intscat*multscat;

vecscat=repmat(minscat,1,6);

vecscat=vecscat+scatplus;

h=colorbar;colormap(jet);

set(h, 'yticklabel',num2str(vecscat'));

%%'0|0.5|1.0|1.5|2.0|2.5|3.0|3.5|4.0|4.5|5.0 VOLTS')



		xf=xlabel('Degrees Longitude ')

		yf=ylabel('Degrees Latitude ')

		set(xf, 'fontsize', 14, 'fontweight', 'bold');

		set(yf, 'fontsize', 14, 'fontweight', 'bold');

		set(ax1, 'fontsize', 16, 'fontweight', 'bold');

		orient landscape

      %%  print -djpeg99 dataorth.jpg



%work on fluorescence

%%ssf=ssfluor(m);



%%my=find(ssf>0 & ssf<=.4);

%%mc=find(ssf>.41 & ssf<=.8);

%%mg=find(ssf>.81 & ssf<=10);



%%yh=plot(x(my),y(my),'y.','markersize',10);

%%ch=plot(x(mc),y(mc),'c.','markersize',10);

%%gh=plot(x(mg),y(mg),'g.','markersize',10);

%%legend([yh ch gh], '<0.4 volts','0.4 to 0.8 volts', '0.8 to 10 volts')

title('Simrad 300 meters NBP0104','FontSize',14)



%Put in odd station numbers

z=nbp0104(:,1);

for i=1:2:length(nbp0104(:,1));

   h3=text(X(i,1),Y(i,1),num2str(z(i,1)));

   set(h3,'FontSize',10, 'Fontweight', 'bold');

   set(h3,'col','r');

end

eval(['!gzip SIMf', day, 'out', freq, '.dat']);

end





%put in ROV stations

%i=[4 11 17 40 35 43 47 49 59 63 75 78 87 71 16]; %ROV station locations NBP0104

%h=plot(X(i),Y(i),'ok');

%set(h,'markersize',9)

%set(h,'markersize',8,'MarkerFaceColor','r')



%%hold off

