%plot_oceansites3
%ver 31 dec 2009-jadb
%
% i/p ascii files created by kelan (ie OS_ntas_200103_M.asc)
% order of vars:
%                       7    8        9   10     11   12  13    14   15    16
% yyyy mo da hh mm ss airt atms(prs) relh lw    rain temp sw   uwnd vwnd   psal 
%  utc                degC mbar       %   wm-2  mm/h degc wm-2  m/s  m/s   psu
%  
%  calls: signature.m
%         clfall.m
%
infiles=dirr('*.asc');
[nf,nc]=size(infiles);
disp([num2str(nf),' input files']);
for f=6:nf
    figure(f)
    data=load(infiles(f,:));
    xdate=datenum(data(:,1:6));
    fdot=findstr(infiles(f,:),'_M')-1;
    plotfile=([infiles(f,1:fdot),'.jpg'])
    proj=infiles(f,4:6);
    switch proj
        case 'nta'
            ctitle='NTAS';
            teax=[20 30];%temp axis
            rnax=[0 150];%rain axis
        case 'str'
            ctitle = 'Stratus';
            teax=[10 30];
            rnax=[0 100]
        case 'who'
            ctitle='WHOTS';
            teax=[10 30];
            rnax=[0 150];
        otherwise
            disp(['unknown project:  ',proj]);
    end
        
    %1  air & sea temp
      axes('Position',[.12 .8 .78 .09]);
      p1=plot(xdate,data(:,7),'r',xdate,data(:,12),'b');
        datetick('x','mmm');
        xlim=get(gca,'xlim');
        axis([xlim teax]);
        t1=text(xlim(2)+1,teax(2)-2,'Air','color','r');
        t2=text(xlim(2)+1,teax(1)+2,'Sea','color','b');
        set(gca,'xticklabel',[]);
        yy=ylabel({'Temp';'Deg C'});  
        tt=title([ctitle,' Meteorological Data ',datestr(xdate(1),23),' to ',datestr(xdate(end),23)]);
        set(tt,'fontsize',14);
        hold on
      
    %2  
      axes('Position',[.12 .7 .78 .09]);
      p2=plot(xdate,data(:,8));
        xlim=get(gca,'xlim');
        axis([xlim 1000 1030]);
        datetick('x','mmm');
        set(gca,'xticklabel',[],'yaxislocation','right');
        ylabel({'Bar. Pres';'mbar'});     
      
    %3 shortwave
      axes('Position',[.12 .6 .78 .09]);
      p3=plot(xdate,data(:,13),'b'); 
        xlim=get(gca,'xlim');
        axis([xlim 0 1800]);
        datetick('x','mmm');
        set(gca,'xticklabel',[]);
        ylabel({'Shortwave';'Radiation';'Wm-2'});
    
    %4 longwave
      axes('Position',[.12 .5 .78 .09]);
      p4=plot(xdate,data(:,10),'b');
        xlim=get(gca,'xlim');
        axis([xlim 300 500]);
        datetick('x','mmm');
        set(gca,'xticklabel',[],'yaxislocation','right');
        ylabel({'Longwave';'Radiation';'Wm-2'});
      
    %5 Wind E & N
      axes('Position',[.12 .4 .78 .09]);
      p5a=plot(xdate,data(:,14),'r',xdate,data(:,15),'b'); %east then north
                datetick('x','mmm');

        xlim=get(gca,'xlim');
        axis([xlim -20 20]);
%        datetick('x','mmm');
        t1=text(xlim(2)+1,20 -5,'East','color','r');
        t2=text(xlim(2)+1,-20 +5,'North','color','b');
        set(gca,'xticklabel',[]);
        ylabel({'Wind Vel';'m/s'});

        
    %6 Humidity
       axes('Position',[.12 .3 .78 .09]);
       p6=plot(xdate,data(:,9));
         xlim=get(gca,'xlim');
         axis([xlim 30 100]);
         datetick('x','mmm');
         set(gca,'xticklabel',[],'yaxislocation','right');
         ylabel({'Relative';'Humidity';'%'}); 
      
    %7 Rain
       axes('Position',[.12 .2 .78 .09]);
       p7=plot(xdate,data(:,11));
       %  xlim=get(gca,'xlim');
       %  axis([xlim 0 150]);
         datetick('x','mmm');
         set(gca,'xticklabel',[]);
         ylabel({'Rainfall';'mm/hr'});
  
    %8 Salt
       axes('Position',[.12 .1 .78 .09]);
       p8=plot(xdate,data(:,16));
        % xlim=get(gca,'xlim');
        % axis([xlim 34 38]);
         datetick('x','mmm');
         ylabel({'Salinity';'PSU'});
         set(gca,'yaxislocation','right'); 
      
    %date plot
       orient tall
       signature;
      
    % save
       eval(['print -djpeg ',plotfile]);
      
       clear data plotfile p* 
      % clfall
      
end% file loop f
      
      
