

%lon lat at Ft Myers SFWMD sensor
lon_sp=-81.8692488;
lat_sp=26.65201666;

ksfc=19;  %sigma coord starts at bottom, so k=19 s/b near surface
kbot=5;

cd ../OUTWET2

time=[];

% u=[];
% v=[];
% zeta=[];
saltsfc=[];
saltbot=[];
salt=[];

d=dir('calus2008_his_*.nc');

for f=1:27, %length(d),
    
      fn=d(f).name
% nc=netcdf(fn);  %opens file 
% time=nc{'ocean_time'}(:);
% lon=nc{'lon_u'}(:,:);
% lat=nc{'lat_u'}(:,:);

if f==1,
lon=nc_varget(fn,'lon_u');
lat=nc_varget(fn,'lat_u');


[i,j,dist_km]=near2d(lon,lat,lon_sp,lat_sp)

end

time=[time;nc_varget(fn,'ocean_time')];

%load salinity

salt_=nc_varget(fn,'salt');

% v_=nc_varget(fn,'vbar');
% 
% zeta_=nc_varget(fn,'zeta');

% u=[u ;u_(:,i,j)]; %j)  %,i);
% v=[v ;v_(:,i,j)]; % j),i);
% zeta=[zeta;zeta_(:,i,j)];
saltsfc=[saltsfc;salt_(:,ksfc,i,j)];
saltbot=[saltbot;salt_(:,kbot,i,j)];
salt=[salt;salt_(:,:,i,j)];
clear salt_
end

%close(nc)
cd ../analout

jd=datenum(1968,5,23)+time./(3600.*24);


load FtMyersdat jdFM salsfc salbot

jdFM=jdFM+5./24;  %convert to GMT



%inclusive days for files 10:34

 %  733611.7186799189    733616.9994107370  

%infm=find(jdFM>=733611.7186799189 & jdFM<=733616.9994107370 );

infm=find(jdFM>=min(jd) & jdFM<=max(jd));
%inmod=find(jd>=733611.7186799189 & jd<=733616.9994107370 );

README=['salt vars from model, sal vars from Fort Myers'];

clear f i j d

save verifysaltdat

figure
subplot(211)
plot(jd,saltsfc,'b.-',jd,saltbot,'m.-',jdFM(infm),salsfc(infm),'g-',...
    jdFM(infm),salbot(infm),'r-')
grid
legend('model sfc','model bot','SFWMD sfc','SWFMD bot')
title('Observed and Predicted Values at Fort Myers')
ylabel('Salinity (psu)')
datetick('x','keeplimits','keepticks')

figure
subplot(211)
plot(jd,saltsfc,'b.-',jd,saltbot,'m.-',jdFM(infm),mean([salsfc(infm) salbot(infm)]'),'r-')
grid
legend('model sfc','model bot','Mean SFWMD')
title('Observed and Predicted Values at Fort Myers')
ylabel('Salinity (psu)')
datetick('x','keeplimits','keepticks')


figure
subplot(211)
plot(jd,mean(salt,2),'b.-',jdFM(infm),mean([salsfc(infm) salbot(infm)]'),'r-')
grid

legend('Model','Observed')
title('Observed and Predicted Values at Fort Myers')
ylabel('Salinity (psu)')
datetick('x','keeplimits','keepticks')

