set(0, 'defaulttextinterpreter','tex')

subplot(4,1,1)
[nn,xx] = hist(uvdiff,[0:100]);
bar(xx,nn/sum(nn))
title('uvdiff')
xl(0,100)

subplot(4,1,2)
[nn,xx] = hist(absrefsmdiff,[0:100]);
bar(xx,nn/sum(nn))
title('absrefsmdiff')
xl(0,100)


subplot(212)
%this is essentially the bottom of apuv.m
set(0, 'defaulttextinterpreter', 'tex')

minrange = 5; %try to look in a big enough region
lonrange = max(data.lon) - min(data.lon);
if (lonrange >= minrange)
   lonlims = [min(data.lon) max(data.lon)] + lonrange*[-.1 .1];
else
   lonlims = [min(data.lon) max(data.lon)] + minrange*[-.5 .5];
end

latrange = max(data.lat) - min(data.lat);
if (latrange >= minrange)
   latlims = [min(data.lat) max(data.lat)] + latrange*[-.1 .1];
else
   latlims = [min(data.lat) max(data.lat)] + minrange*[-.5 .5];
end

  %make sure it doesn't go over /- 90
  latlims(1) = max(-90, latlims(1));
  latlims(2) = min( 90, latlims(2));


subplot(212)
%set up the colors
topo_cmap = mk_cmap(length(topo_clev), 'topo');
topo_irange =  [1 length(topo_cmap(:,1))]; % indices into topo_cmap
colormap([topo_cmap])
m_proj('lambert', 'long' ,lonlims, 'lat', latlims);


%use sstopo if we're north of 70deg
if ( (latlims(1) < -70) | (latlims(2) > 70))  %then some topo is not in m_elev
   %see whether there's any topography
   [elev, lon, lat] = m_elev([lonlims latlims]);
   enough_gridpoints = (min([length(elev(:,1)) length(elev(1,:))])  >= 3);
   if (enough_gridpoints)
      m_elev('contourf',topo_clev);
   end
else
   [longrid,latgrid,topog]=ss_block(lonlims, latlims);
   m_contourf(longrid,latgrid,topog);
   enough_gridpoints = logical(1);
end
      

m_grid('box','fancy','tickdir','in');
%m_coast;

goodi = find(~isnan(data.uabs_refl_sm.*rl_dtfm));
[hp,ht]=m_vec(mvec_scale,...
              data.lon(goodi),data.lat(goodi),...
              data.uabs_refl_sm(goodi),...
              data.vabs_refl_sm(goodi),...
              'shaftwidth',.1);
set(hp,'facecolor','r')
set(hp,'edgecolor','r')

navtimes = NaN*data.lon;
m_track(data.lon, data.lat, navtimes, 'color', 'g', 'linewidth', 2);

if (enough_gridpoints)
   h_dcb = dcolbar( topo_clev/1000, 'vert', 'Depth (km)');
   h_dcbp = findobj(h_dcb,'Type','patch');
   cf_index(h_dcbp, topo_clev/1000, topo_irange);
end

date_it

startdate = to_date(config.yearbase,min(data.dday));
enddate = to_date(config.yearbase,max(data.dday));
datestr = sprintf('%s to %s', startdate(6:10), enddate(6:10));

subtitle_comment = sprintf('%s (%s)', config.comment, datestr);

subtitle(subtitle_comment)

