filenum  = 4;
date     = datestr(ssttime-3,'yyyymmdd');
filename = ['pioneer_avg_', date,'_0000_000', num2str(filenum),'.nc'];

url      = ['http://tds.marine.rutgers.edu/thredds/dodsC/roms/doppio/Pio1wDopRTV1R3/avg/files/',filename];
grid     = roms_get_grid(url,url);
otime    = datetime(2006,1,1,0,0,0)+ncread(url,'ocean_time')/86400;

temp = ncread(url,'temp');
ubar = ncread(url,'ubar');
vbar = ncread(url,'vbar');
u    = ncread(url,'u');
v    = ncread(url,'v');

figure;clf;
orient PORTRAIT
colormap('jet');

axes('pos',[0.05 0.1 0.85 0.8]);
pcolorjw(grid.lon_rho, grid.lat_rho, squeeze(temp(:,:,end))');
caxis(clrlim);
xlim([min(plonlim) max(plonlim)]);
ylim([min(platlim) max(platlim)]);

hold on;
[cc,hh] = contour(blon,blat,bdpth,[40:10:100 200 500 1000 2000 3000]);
set(hh,'color','k','linewidth',1);
[cc,hh] = contour(blon,blat,bdpth,[100 200]);
set(hh,'color','k','linewidth',2);
clabel(cc,hh,'color',[0.5 0.5 0.5],'fontsize',15,'labelspacing',350);

pnc;
pmc('fill',[0.5 0.5 0.5],[0.5 0.5 0.5]);
xlim(plonlim);ylim(platlim);
set(gca,'xtick',[plonlim(1):0.5:plonlim(2)],'ytick',[platlim(1):0.25:platlim(2)]);
set(gca,'layer','top','tickdir','out','fontsize',15);
%ylabel('Latitude');
hclb = colorbar;
set(hclb,'location','eastoutside');
set(hclb,'pos',[0.75 0.2 0.02 0.6],'ytick',[clrlim(1):2:clrlim(2)],'tickdir','out','fontsize',15);
text(plonlim(2)+0.1,41,'(^oC)','fontsize',15);
%xlabel('Longitude');
plot(mrlon,mrlat,'pk','markersize',6,'linewidth',2);
plot(zdlon,zdlat,'dk','markersize',6,'linewidth',2);
figname = [figdir 'sst_ROMS_' datestr(otime,'yyyymmdd') '.png'];
tttxt = ['ROMS SST on ' datestr(otime)];
htt = title(tttxt);
set(htt,'fontsize',14,'fontname','Times');



figure;clf;
orient PORTRAIT
colormap('jet');

axes('pos',[0.05 0.1 0.85 0.8]);
pcolorjw(grid.lon_rho, grid.lat_rho, squeeze(temp(:,:,end))');
caxis(clrlim);
xlim([min(plonlim) max(plonlim)]);
ylim([min(platlim) max(platlim)]);

hold on;
[cc,hh] = contour(blon,blat,bdpth,[40:10:100 200 500 1000 2000 3000]);
set(hh,'color','k','linewidth',1);
[cc,hh] = contour(blon,blat,bdpth,[100 200]);
set(hh,'color','k','linewidth',2);
clabel(cc,hh,'color',[0.5 0.5 0.5],'fontsize',15,'labelspacing',350);

pnc;
pmc('fill',[0.5 0.5 0.5],[0.5 0.5 0.5]);
xlim(plonlim);ylim(platlim);
set(gca,'xtick',[plonlim(1):0.5:plonlim(2)],'ytick',[platlim(1):0.25:platlim(2)]);
set(gca,'layer','top','tickdir','out','fontsize',15);
%ylabel('Latitude');
hclb = colorbar;
set(hclb,'location','eastoutside');
set(hclb,'pos',[0.75 0.2 0.02 0.6],'ytick',[clrlim(1):2:clrlim(2)],'tickdir','out','fontsize',15);
text(plonlim(2)+0.1,41,'(^oC)','fontsize',15);
%xlabel('Longitude');
plot(mrlon,mrlat,'pk','markersize',6,'linewidth',2);
plot(zdlon,zdlat,'dk','markersize',6,'linewidth',2);

[han,data] =roms_quivergrd(ubar',vbar',grid,2,1);
figname = [figdir 'sst_ROMS_' datestr(otime,'yyyymmdd') '.png'];
tttxt = ['ROMS SST and integrated velocity on ' datestr(otime)];
htt = title(tttxt);
set(htt,'fontsize',14,'fontname','Times');

figure;clf;
orient PORTRAIT
colormap('jet');

axes('pos',[0.05 0.1 0.85 0.8]);
pcolorjw(grid.lon_rho, grid.lat_rho, squeeze(temp(:,:,end))');
caxis(clrlim);
xlim([min(plonlim) max(plonlim)]);
ylim([min(platlim) max(platlim)]);

hold on;
[cc,hh] = contour(blon,blat,bdpth,[40:10:100 200 500 1000 2000 3000]);
set(hh,'color','k','linewidth',1);
[cc,hh] = contour(blon,blat,bdpth,[100 200]);
set(hh,'color','k','linewidth',2);
clabel(cc,hh,'color',[0.5 0.5 0.5],'fontsize',15,'labelspacing',350);

pnc;
pmc('fill',[0.5 0.5 0.5],[0.5 0.5 0.5]);
xlim(plonlim);ylim(platlim);
set(gca,'xtick',[plonlim(1):0.5:plonlim(2)],'ytick',[platlim(1):0.25:platlim(2)]);
set(gca,'layer','top','tickdir','out','fontsize',15);
%ylabel('Latitude');
hclb = colorbar;
set(hclb,'location','eastoutside');
set(hclb,'pos',[0.75 0.2 0.02 0.6],'ytick',[clrlim(1):2:clrlim(2)],'tickdir','out','fontsize',15);
text(plonlim(2)+0.1,41,'(^oC)','fontsize',15);
%xlabel('Longitude');
plot(mrlon,mrlat,'pk','markersize',6,'linewidth',2);
plot(zdlon,zdlat,'dk','markersize',6,'linewidth',2);

[han,data] =roms_quivergrd(squeeze(u(:,:,end))',squeeze(v(:,:,end))',grid,3,1);
figname = [figdir 'sst_ROMS_' datestr(otime,'yyyymmdd') '.png'];
tttxt = ['ROMS SST and surface velocity on ' datestr(otime)];
htt = title(tttxt);
set(htt,'fontsize',14,'fontname','Times');


% larger scale figs
figure;clf;
orient PORTRAIT
colormap('jet');

axes('pos',[0.05 0.1 0.85 0.8]);
pcolorjw(grid.lon_rho, grid.lat_rho, squeeze(temp(:,:,end))');
caxis(clrlim);

hold on;
[cc,hh] = contour(blon,blat,bdpth,[100 500 1000 2000 3000]);
set(hh,'color','k','linewidth',1);

pnc;
pmc('fill',[0.5 0.5 0.5],[0.5 0.5 0.5]);
set(gca,'xtick',[lonlim(1):1:lonlim(2)],'ytick',[latlim(1):1:latlim(2)]);
set(gca,'layer','top','tickdir','out','fontsize',15);
%ylabel('Latitude');
hclb = colorbar;
set(hclb,'location','eastoutside');
set(hclb,'ytick',[clrlim(1):2:clrlim(2)],'tickdir','out','fontsize',15);
%xlabel('Longitude');
plot(zdlon,zdlat,'dk','markersize',4,'linewidth',2);
line([plonlim(1) plonlim(1)],[platlim(1) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(2) plonlim(2)],[platlim(1) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(1) plonlim(2)],[platlim(1) platlim(1)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(1) plonlim(2)],[platlim(2) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
figname = [figdir 'sst_ROMS_' datestr(otime,'yyyymmdd') '.png'];
tttxt = ['ROMS SST on ' datestr(otime)];
htt = title(tttxt);
set(htt,'fontsize',14,'fontname','Times');


figure;clf;
orient PORTRAIT
colormap('jet');

axes('pos',[0.05 0.1 0.85 0.8]);
pcolorjw(grid.lon_rho, grid.lat_rho, squeeze(temp(:,:,end))');
caxis(clrlim);

hold on;
[cc,hh] = contour(blon,blat,bdpth,[100 500 1000 2000 3000]);
set(hh,'color','k','linewidth',1);

pnc;
pmc('fill',[0.5 0.5 0.5],[0.5 0.5 0.5]);
set(gca,'xtick',[lonlim(1):1:lonlim(2)],'ytick',[latlim(1):1:latlim(2)]);
set(gca,'layer','top','tickdir','out','fontsize',15);
%ylabel('Latitude');
hclb = colorbar;
set(hclb,'location','eastoutside');
set(hclb,'ytick',[clrlim(1):2:clrlim(2)],'tickdir','out','fontsize',15);
%xlabel('Longitude');
plot(zdlon,zdlat,'dk','markersize',4,'linewidth',2);
line([plonlim(1) plonlim(1)],[platlim(1) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(2) plonlim(2)],[platlim(1) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(1) plonlim(2)],[platlim(1) platlim(1)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(1) plonlim(2)],[platlim(2) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
[han,data] =roms_quivergrd(ubar',vbar',grid,5,1);
figname = [figdir 'sst_ROMS_' datestr(otime,'yyyymmdd') '.png'];
tttxt = ['ROMS SST and integrated velocity on ' datestr(otime)];
htt = title(tttxt);
set(htt,'fontsize',14,'fontname','Times');


figure;clf;

orient PORTRAIT
colormap('jet');

axes('pos',[0.05 0.1 0.85 0.8]);
pcolorjw(grid.lon_rho, grid.lat_rho, squeeze(temp(:,:,end))');
caxis(clrlim);

hold on;
[cc,hh] = contour(blon,blat,bdpth,[100 500 1000 2000 3000]);
set(hh,'color','k','linewidth',1);

pnc;
pmc('fill',[0.5 0.5 0.5],[0.5 0.5 0.5]);
set(gca,'xtick',[lonlim(1):1:lonlim(2)],'ytick',[latlim(1):1:latlim(2)]);
set(gca,'layer','top','tickdir','out','fontsize',15);
%ylabel('Latitude');
hclb = colorbar;
set(hclb,'location','eastoutside');
set(hclb,'ytick',[clrlim(1):2:clrlim(2)],'tickdir','out','fontsize',15);
%xlabel('Longitude');
plot(zdlon,zdlat,'dk','markersize',4,'linewidth',2);
line([plonlim(1) plonlim(1)],[platlim(1) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(2) plonlim(2)],[platlim(1) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(1) plonlim(2)],[platlim(1) platlim(1)],'color',[0.5 0.5 0.5],'linewidth',2);
line([plonlim(1) plonlim(2)],[platlim(2) platlim(2)],'color',[0.5 0.5 0.5],'linewidth',2);
[han,data] =roms_quivergrd(squeeze(u(:,:,end))',squeeze(v(:,:,end))',grid,5,1);
figname = [figdir 'sst_ROMS_' datestr(otime,'yyyymmdd') '.png'];
tttxt = ['ROMS SST and surface velocity on ' datestr(otime)];
htt = title(tttxt);
set(htt,'fontsize',14,'fontname','Times');

