clear
load Argos.mat
load etl.mat
load flux.mat
etl_flux=flux;
clear flux
load gps.mat
load vos.mat
save s10_realtime.mat sys1 sys2 etl etl_flux vos gps


% now truncate to comparison period, about
% Apr 7 21:22 to Apr 9 11:06
set_up
addpath([matlabroot '/toolbox/local/m_map'])
s11_lat=-19 -(41.4783/60); s11_lon=-85 -(34.0093/60);
anchor_over=datenum(2011,4,6,19,30,0);


gps.yday=gps.mday-day1;
ix = find (gps.yday > 97 & gps.yday < 99.5);
gps=structtrunc(gps,ix);
dist_km=ones(length(gps.mday),1);
for iil=1:length(gps.mday),
    jla=[s11_lat gps.lat(iil)];
    jlo=[s11_lon gps.lon(iil)];
    dist_km(iil) = m_lldist(jlo,jla);
end


figure(1)
plot(gps.yday,dist_km,gps.yday,dist_km,'.')
grid on
ax=axis;
datestr(97.55 + day1)
min(dist_km)
datestr(gps.mday(find(dist_km == min(dist_km))))
grid on
title ('stratus 11 intercomparison')
ylabel('Distance (km)')
xlabel('yearday 2011')
print -dpng min_dist2.png

% truncate gps
ix=find(gps.yday > 97.89 & gps.yday < 99.5);
gps=structtrunc(gps,ix);
fprintf('now %s to %s\n', datestr(gps.mday(1)),datestr(gps.mday(end)));

% truncate argos: times are all @ 30 minutes
ix=find(sys1.yday >= 97.5 & sys1.yday <= 99.5);
sys1=structtrunc(sys1,ix);
fprintf('now %s to %s\n', datestr(sys1.mday(1)),datestr(sys1.mday(end)));

ix=find(sys2.yday >= 97.5 & sys2.yday <= 99.5);
sys2=structtrunc(sys2,ix);
fprintf('now %s to %s\n', datestr(sys2.mday(1)),datestr(sys2.mday(end)));

load etl.mat
elt.yday=elt.mday-day1;
ix=find(etl.yday >= 97.5 & etl.yday <= 99.5);
etl=structtrunc(etl,ix);
fprintf('now %s to %s\n', datestr(etl.mday(1)),datestr(etl.mday(end)));



